org.jboss.as.server.deployment.module.ModuleDependency Java Examples

The following examples show how to use org.jboss.as.server.deployment.module.ModuleDependency. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LoggingDependencyDeploymentProcessor.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void deploy(final DeploymentPhaseContext phaseContext) {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
    final ModuleLoader moduleLoader = Module.getBootModuleLoader();
    // Add the logging modules
    for (String moduleId : DUP_INJECTED_LOGGING_MODULES) {
        try {
            LoggingLogger.ROOT_LOGGER.tracef("Adding module '%s' to deployment '%s'", moduleId, deploymentUnit.getName());
            moduleLoader.loadModule(moduleId);
            moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, moduleId, false, false, false, false));
        } catch (ModuleLoadException ex) {
            LoggingLogger.ROOT_LOGGER.debugf("Module not found: %s", moduleId);
        }
    }
}
 
Example #2
Source File: ModuleResolvePhaseService.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private static void installService(final ServiceTarget serviceTarget, final ModuleIdentifier moduleIdentifier, int phaseNumber, final Set<ModuleDependency> nextPhaseIdentifiers, final Set<ModuleIdentifier> nextAlreadySeen) {
    final ModuleResolvePhaseService nextPhaseService = new ModuleResolvePhaseService(moduleIdentifier, nextAlreadySeen, phaseNumber);
    ServiceBuilder<ModuleResolvePhaseService> builder = serviceTarget.addService(moduleSpecServiceName(moduleIdentifier, phaseNumber), nextPhaseService);
    for (ModuleDependency module : nextPhaseIdentifiers) {
        builder.addDependency(ServiceModuleLoader.moduleSpecServiceName(module.getIdentifier()), ModuleDefinition.class, new Injector<ModuleDefinition>() {

            ModuleDefinition definition;

            @Override
            public synchronized void inject(final ModuleDefinition o) throws InjectionException {
                nextPhaseService.getModuleSpecs().add(o);
                this.definition = o;
            }

            @Override
            public synchronized void uninject() {
                nextPhaseService.getModuleSpecs().remove(definition);
                this.definition = null;
            }
        });
    }
    builder.install();
}
 
Example #3
Source File: CompositeIndexProcessor.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private Map<ModuleIdentifier, DeploymentUnit> buildSubdeploymentDependencyMap(DeploymentUnit deploymentUnit) {
    Set<ModuleIdentifier> depModuleIdentifiers = new HashSet<>();
    for (ModuleDependency dep: deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION).getAllDependencies()) {
        depModuleIdentifiers.add(dep.getIdentifier());
    }

    DeploymentUnit top = deploymentUnit.getParent()==null?deploymentUnit:deploymentUnit.getParent();
    Map<ModuleIdentifier, DeploymentUnit> res = new HashMap<>();
    AttachmentList<DeploymentUnit> subDeployments = top.getAttachment(Attachments.SUB_DEPLOYMENTS);
    if (subDeployments != null) {
        for (DeploymentUnit subDeployment : subDeployments) {
            ModuleIdentifier moduleIdentifier = subDeployment.getAttachment(Attachments.MODULE_IDENTIFIER);
            if (depModuleIdentifiers.contains(moduleIdentifier)) {
                res.put(moduleIdentifier, subDeployment);
            }
        }
    }
    return res;
}
 
Example #4
Source File: ModuleResolvePhaseService.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void start(final StartContext startContext) throws StartException {
    Set<ModuleDependency> nextPhaseIdentifiers = new HashSet<>();
    final Set<ModuleIdentifier> nextAlreadySeen = new HashSet<>(alreadyResolvedModules);
    for (final ModuleDefinition spec : moduleSpecs) {
        if (spec != null) { //this can happen for optional dependencies
            for (ModuleDependency dep : spec.getDependencies()) {
                if (dep.isOptional()) continue; // we don't care about optional dependencies
                if (ServiceModuleLoader.isDynamicModule(dep.getIdentifier())) {
                    if (!alreadyResolvedModules.contains(dep.getIdentifier())) {
                        nextAlreadySeen.add(dep.getIdentifier());
                        nextPhaseIdentifiers.add(dep);
                    }
                }
            }
        }
    }
    if (nextPhaseIdentifiers.isEmpty()) {
        ServiceModuleLoader.installModuleResolvedService(startContext.getChildTarget(), moduleIdentifier);
    } else {
        installService(startContext.getChildTarget(), moduleIdentifier, phaseNumber + 1, nextPhaseIdentifiers, nextAlreadySeen);
    }
}
 
Example #5
Source File: KeycloakProviderDependencyProcessor.java    From keycloak with Apache License 2.0 6 votes vote down vote up
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    KeycloakAdapterConfigService config = KeycloakAdapterConfigService.INSTANCE;
    String deploymentName = deploymentUnit.getName();

    if (config.isKeycloakServerDeployment(deploymentName)) {
        return;
    }

    KeycloakDeploymentInfo info = getKeycloakProviderDeploymentInfo(deploymentUnit);
    if (info.hasServices()) {
        final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
        final ModuleLoader moduleLoader = Module.getBootModuleLoader();
        moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_COMMON, false, false, false, false));
        moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_CORE, false, false, false, false));
        moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_SERVER_SPI, false, false, false, false));
        moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_SERVER_SPI_PRIVATE, false, false, false, false));
        moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, JAXRS, false, false, false, false));
        moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, RESTEASY, false, false, false, false));
        moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, APACHE, false, false, false, false));
        moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_JPA, false, false, false, false));
    }
}
 
Example #6
Source File: ModuleLoadService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private ModuleLoadService(final List<ModuleDependency> systemDependencies, final List<ModuleDependency> localDependencies, final List<ModuleDependency> userDependencies) {
    this.systemDependencies = systemDependencies;
    this.localDependencies = localDependencies;
    this.userDependencies = userDependencies;

    this.allDependencies = new ArrayList<>();
    this.allDependencies.addAll(systemDependencies);
    this.allDependencies.addAll(localDependencies);
    this.allDependencies.addAll(userDependencies);
}
 
Example #7
Source File: KeycloakDependencyProcessor.java    From keycloak with Apache License 2.0 5 votes vote down vote up
private void addCommonModules(ModuleSpecification moduleSpecification, ModuleLoader moduleLoader) {
    // ModuleDependency(ModuleLoader moduleLoader, ModuleIdentifier identifier, boolean optional, boolean export, boolean importServices, boolean userSpecified)
    moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_JBOSS_CORE_ADAPTER, false, false, false, false));
    moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_CORE_ADAPTER, false, false, false, false));
    moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_CORE, false, false, false, false));
    moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_COMMON, false, false, false, false));
}
 
Example #8
Source File: KeycloakDependencyProcessor.java    From keycloak with Apache License 2.0 5 votes vote down vote up
private void addCommonModules(ModuleSpecification moduleSpecification, ModuleLoader moduleLoader) {
    // ModuleDependency(ModuleLoader moduleLoader, ModuleIdentifier identifier, boolean optional, boolean export, boolean importServices, boolean userSpecified)
    moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_JBOSS_CORE_ADAPTER, false, false, false, false));
    moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_CORE_ADAPTER, false, false, false, false));
    moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_CORE, false, false, false, false));
    moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_COMMON, false, false, false, false));
}
 
Example #9
Source File: KeycloakDependencyProcessorWildFly.java    From keycloak with Apache License 2.0 5 votes vote down vote up
@Override
protected void addPlatformSpecificModules(DeploymentPhaseContext phaseContext, ModuleSpecification moduleSpecification, ModuleLoader moduleLoader) {
    if (isElytronEnabled(phaseContext)) {
        moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_ELYTRON_ADAPTER, true, false, true, false));
    } else {
        moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_WILDFLY_ADAPTER, false, false, true, false));
        moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_UNDERTOW_ADAPTER, false, false, false, false));
    }
}
 
Example #10
Source File: KeycloakDependencyProcessor.java    From keycloak with Apache License 2.0 5 votes vote down vote up
private void addCommonModules(ModuleSpecification moduleSpecification, ModuleLoader moduleLoader) {
    // ModuleDependency(ModuleLoader moduleLoader, ModuleIdentifier identifier, boolean optional, boolean export, boolean importServices, boolean userSpecified)
    moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_JBOSS_CORE_ADAPTER, false, false, false, false));
    moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_CORE_ADAPTER, false, false, false, false));
    moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_API_ADAPTER, false, false, false, false));
    moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_COMMON, false, false, false, false));
}
 
Example #11
Source File: ModuleLoadService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static ServiceName installAliases(final ServiceTarget target, final ModuleIdentifier identifier, final List<ModuleIdentifier> aliases) {
    final ArrayList<ModuleDependency> dependencies = new ArrayList<ModuleDependency>(aliases.size());
    for (final ModuleIdentifier i : aliases) {
        dependencies.add(new ModuleDependency(null, i, false, false, false, false));
    }
    final ModuleLoadService service = new ModuleLoadService(dependencies);
    return install(target, identifier, service);
}
 
Example #12
Source File: ModuleLoadService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public synchronized void start(StartContext context) throws StartException {
    try {
        final ServiceModuleLoader moduleLoader = serviceModuleLoader.getValue();
        final Module module = moduleLoader.loadModule(moduleDefinitionInjectedValue.getValue().getModuleIdentifier());
        moduleLoader.relinkModule(module);
        for (ModuleDependency dependency : allDependencies) {
            if (dependency.isUserSpecified()) {
                final ModuleIdentifier id = dependency.getIdentifier();
                try {
                    String val = moduleLoader.loadModule(id).getProperty("jboss.api");
                    if (val != null) {
                        if (val.equals("private")) {
                            ServerLogger.PRIVATE_DEP_LOGGER.privateApiUsed(moduleDefinitionInjectedValue.getValue().getModuleIdentifier().getName(), id);
                        } else if (val.equals("unsupported")) {
                            ServerLogger.UNSUPPORTED_DEP_LOGGER.unsupportedApiUsed(moduleDefinitionInjectedValue.getValue().getModuleIdentifier().getName(), id);
                        } else if (val.equals("deprecated")) {
                            ServerLogger.DEPRECATED_DEP_LOGGER.deprecatedApiUsed(moduleDefinitionInjectedValue.getValue().getModuleIdentifier().getName(), id);
                        }
                    }
                } catch (ModuleNotFoundException ignore) {
                    //can happen with optional dependencies
                }
            }
        }
        this.module = module;
    } catch (ModuleLoadException e) {
        throw ServerLogger.ROOT_LOGGER.failedToLoadModule(moduleDefinitionInjectedValue.getValue().getModuleIdentifier(), e);
    }
}
 
Example #13
Source File: ModuleLoadService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private ModuleLoadService(final List<ModuleDependency> aliasDependencies) {
    this.systemDependencies = Collections.emptyList();
    this.localDependencies = Collections.emptyList();
    this.userDependencies = Collections.emptyList();

    this.allDependencies = new ArrayList<>(aliasDependencies);
}
 
Example #14
Source File: KeycloakDependencyProcessor.java    From keycloak with Apache License 2.0 5 votes vote down vote up
private void addCommonModules(ModuleSpecification moduleSpecification, ModuleLoader moduleLoader) {
    // ModuleDependency(ModuleLoader moduleLoader, ModuleIdentifier identifier, boolean optional, boolean export, boolean importServices, boolean userSpecified)
    moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_JBOSS_CORE_ADAPTER, false, false, false, false));
    moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_CORE_ADAPTER, false, false, false, false));
    moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_API_ADAPTER, false, false, false, false));
    moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_COMMON, false, false, false, false));
}
 
Example #15
Source File: KeycloakDependencyProcessorWildFly.java    From keycloak with Apache License 2.0 5 votes vote down vote up
@Override
protected void addPlatformSpecificModules(DeploymentPhaseContext phaseContext, ModuleSpecification moduleSpecification, ModuleLoader moduleLoader) {
    if (isElytronEnabled(phaseContext)) {
        moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_ELYTRON_ADAPTER, true, false, false, false));
    } else {
        moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_WILDFLY_ADAPTER, false, false, true, false));
        moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_UNDERTOW_ADAPTER, false, false, false, false));
    }
}
 
Example #16
Source File: DeploymentListModulesHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private ModelNode buildDependenciesInfo(List<ModuleDependency> dependencies, boolean verbose) {
    ModelNode deps = new ModelNode().setEmptyList();
    for (ModuleDependency dependency : dependencies) {
        ModelNode depData = new ModelNode();
        ModuleIdentifier identifier = dependency.getIdentifier();
        depData.get("name").set(identifier.toString());
        if (verbose) {
            depData.get("optional").set(dependency.isOptional());
            depData.get("export").set(dependency.isExport());
            depData.get("import-services").set(dependency.isImportServices());
        }
        deps.add(depData);
    }
    return deps;
}
 
Example #17
Source File: DependencyProcessor.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void deploy(DeploymentPhaseContext context) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = context.getDeploymentUnit();
    final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
    final ModuleLoader moduleLoader = Module.getBootModuleLoader();

    moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, elytronIdentifier, false, false, true, false));
}
 
Example #18
Source File: Seam2Processor.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    if (deploymentUnit.getParent() != null) {
        return;
    }

    final List<DeploymentUnit> deploymentUnits = new ArrayList<DeploymentUnit>();
    deploymentUnits.add(deploymentUnit);
    deploymentUnits.addAll(deploymentUnit.getAttachmentList(Attachments.SUB_DEPLOYMENTS));

    for (DeploymentUnit unit : deploymentUnits) {

        final ResourceRoot mainRoot = unit.getAttachment(Attachments.DEPLOYMENT_ROOT);
        if (mainRoot == null)
            continue;

        VirtualFile root = mainRoot.getRoot();
        for (String path : SEAM_FILES) {
            if (root.getChild(path).exists()) {
                final ModuleSpecification moduleSpecification = deploymentUnit
                        .getAttachment(Attachments.MODULE_SPECIFICATION);
                final ModuleLoader moduleLoader = Module.getBootModuleLoader();
                moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, VFS_MODULE, false, false, false,
                        false)); // for VFS scanner

                try {
                    ResourceLoader resourceLoader = ResourceLoaders.createJarResourceLoader(SEAM_INT_JAR, new JarFile(
                            getSeamIntResourceRoot().getRoot().getPathName()));
                    moduleSpecification.addResourceLoader(ResourceLoaderSpec.createResourceLoaderSpec(resourceLoader));
                } catch (Exception e) {
                    throw new DeploymentUnitProcessingException(e);
                }

                unit.addToAttachmentList(Attachments.RESOURCE_ROOTS, getSeamIntResourceRoot());
                return;
            }
        }
    }
}
 
Example #19
Source File: EESecurityDependencyProcessor.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void deploy(DeploymentPhaseContext phaseContext) {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final ModuleLoader moduleLoader = Module.getBootModuleLoader();
    final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);

    moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, JACC_API, false, false, true, false));
    moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, AUTH_MESSAGE_API, false, false, true, false));
}
 
Example #20
Source File: ModuleDependencyProcessor.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
private void addSystemDependency(ModuleLoader moduleLoader, final ModuleSpecification moduleSpecification, ModuleIdentifier dependency) {
  moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, dependency, false, false, false, false));
}
 
Example #21
Source File: KeycloakDependencyProcessorAS7.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
protected void addPlatformSpecificModules(ModuleSpecification moduleSpecification, ModuleLoader moduleLoader) {
    // ModuleDependency(ModuleLoader moduleLoader, ModuleIdentifier identifier, boolean optional, boolean export, boolean importServices, boolean userSpecified)
    moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_AS7_ADAPTER, false, false, true, false));
}
 
Example #22
Source File: ModuleDependencyProcessor.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
private void addSystemDependency(ModuleLoader moduleLoader, final ModuleSpecification moduleSpecification, ModuleIdentifier dependency) {
  moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, dependency, false, false, false, false));
}
 
Example #23
Source File: KeycloakDependencyProcessorAS7.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
protected void addPlatformSpecificModules(ModuleSpecification moduleSpecification, ModuleLoader moduleLoader) {
    // ModuleDependency(ModuleLoader moduleLoader, ModuleIdentifier identifier, boolean optional, boolean export, boolean importServices, boolean userSpecified)
    moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_AS7_ADAPTER, false, false, true, false));
}
 
Example #24
Source File: ModuleLoadService.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public List<ModuleDependency> getLocalDependencies() {
    return new ArrayList<>(localDependencies);
}
 
Example #25
Source File: ModuleLoadService.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public List<ModuleDependency> getUserDependencies() {
    return new ArrayList<>(userDependencies);
}
 
Example #26
Source File: ModuleLoadService.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public List<ModuleDependency> getSystemDependencies() {
    return new ArrayList<>(systemDependencies);
}
 
Example #27
Source File: ModuleLoadService.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static ServiceName install(final ServiceTarget target, final ModuleIdentifier identifier, final List<ModuleDependency> systemDependencies, final List<ModuleDependency> localDependencies, final List<ModuleDependency> userDependencies) {
    final ModuleLoadService service = new ModuleLoadService(systemDependencies, localDependencies, userDependencies);
    return install(target, identifier, service);
}
 
Example #28
Source File: ModuleDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public Set<ModuleDependency> getDependencies() {
    return Collections.unmodifiableSet(dependencies);
}
 
Example #29
Source File: ModuleDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public ModuleDefinition(final ModuleIdentifier moduleIdentifier, final Set<ModuleDependency> dependencies, final ModuleSpec moduleSpec) {
    this.moduleIdentifier = moduleIdentifier;
    this.dependencies = dependencies;
    this.moduleSpec = moduleSpec;
}
 
Example #30
Source File: ModuleStructureSpec.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public List<ModuleDependency> getModuleDependencies() {
    return Collections.unmodifiableList(moduleDependencies);
}