Java Code Examples for org.jboss.as.server.deployment.DeploymentPhaseContext#addDeploymentDependency()

The following examples show how to use org.jboss.as.server.deployment.DeploymentPhaseContext#addDeploymentDependency() . 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: CamelEndpointDeploymentSchedulerProcessor.java    From wildfly-camel with Apache License 2.0 6 votes vote down vote up
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    CamelDeploymentSettings depSettings = deploymentUnit.getAttachment(CamelDeploymentSettings.ATTACHMENT_KEY);

    if (!depSettings.isEnabled()) {
        return;
    }
    List<DeploymentUnit> subDeployments = deploymentUnit
            .getAttachmentList(org.jboss.as.server.deployment.Attachments.SUB_DEPLOYMENTS);
    if (subDeployments != null && !subDeployments.isEmpty()) {
        /* do not install CamelEndpointDeploymentSchedulerService for ears */
        return;
    }

    final ServiceTarget serviceTarget = phaseContext.getServiceTarget();
    final ServiceController<CamelEndpointDeploymentSchedulerService> serviceController = CamelEndpointDeploymentSchedulerService
            .addService(deploymentUnit.getServiceName(), deploymentUnit.getName(), serviceTarget);
    phaseContext.addDeploymentDependency(serviceController.getName(),
            CamelConstants.CAMEL_ENDPOINT_DEPLOYMENT_SCHEDULER_REGISTRY_KEY);
}
 
Example 2
Source File: CamelIntegrationProcessor.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    DeploymentUnit depUnit = phaseContext.getDeploymentUnit();
    CamelDeploymentSettings depSettings = depUnit.getAttachment(CamelDeploymentSettings.ATTACHMENT_KEY);

    // No camel dependencies if camel is disabled
    if (!depSettings.isEnabled()) {
        return;
    }

    phaseContext.addDeploymentDependency(CamelConstants.CONTEXT_CREATE_HANDLER_REGISTRY_SERVICE_NAME, CamelConstants.CONTEXT_CREATE_HANDLER_REGISTRY_KEY);
    phaseContext.addDeploymentDependency(CamelConstants.CAMEL_CONTEXT_REGISTRY_SERVICE_NAME, CamelConstants.CAMEL_CONTEXT_REGISTRY_KEY);
    phaseContext.addDeploymentDependency(CamelConstants.CAMEL_CONTEXT_FACTORY_SERVICE_NAME, CamelConstants.CAMEL_CONTEXT_FACTORY_KEY);
}
 
Example 3
Source File: SSLContextDependencyProcessor.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * @see org.jboss.as.server.deployment.DeploymentUnitProcessor#deploy(org.jboss.as.server.deployment.DeploymentPhaseContext)
 */
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    phaseContext.addDeploymentDependency(DefaultSSLContextService.SERVICE_NAME, ElytronExtension.SSL_CONTEXT_KEY);
}
 
Example 4
Source File: ModuleSpecProcessor.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void deployModuleSpec(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {

        final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
        final DeploymentUnit parentDeployment = deploymentUnit.getParent();

        final ResourceRoot mainRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
        if (mainRoot == null)
            return;

        // Add internal resource roots
        final ModuleSpecification moduleSpec = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
        final List<ResourceRoot> resourceRoots = new ArrayList<ResourceRoot>();
        if (ModuleRootMarker.isModuleRoot(mainRoot)) {
            resourceRoots.add(mainRoot);
        }
        final List<ResourceRoot> additionalRoots = deploymentUnit.getAttachmentList(Attachments.RESOURCE_ROOTS);
        for (final ResourceRoot additionalRoot : additionalRoots) {
            if (ModuleRootMarker.isModuleRoot(additionalRoot) && !SubDeploymentMarker.isSubDeployment(additionalRoot)) {
                resourceRoots.add(additionalRoot);
            }
        }

        final List<ResourceRoot> parentResourceRoots = new ArrayList<>();
        if (parentDeployment != null) {
            final List<ResourceRoot> additionalParentRoots = parentDeployment.getAttachmentList(Attachments.RESOURCE_ROOTS);
            for (final ResourceRoot additionalParentRoot : additionalParentRoots) {
                if (ModuleRootMarker.isModuleRoot(additionalParentRoot) && !SubDeploymentMarker.isSubDeployment(additionalParentRoot)) {
                    parentResourceRoots.add(additionalParentRoot);
                }
            }
        }

        final ModuleIdentifier moduleIdentifier = deploymentUnit.getAttachment(Attachments.MODULE_IDENTIFIER);
        if (moduleIdentifier == null) {
            throw ServerLogger.ROOT_LOGGER.noModuleIdentifier(deploymentUnit.getName());
        }

        // create the module service and set it to attach to the deployment in the next phase
        final ServiceName moduleServiceName = createModuleService(phaseContext, deploymentUnit, resourceRoots, parentResourceRoots, moduleSpec, moduleIdentifier);
        phaseContext.addDeploymentDependency(moduleServiceName, Attachments.MODULE);

        for (final DeploymentUnit subDeployment : deploymentUnit.getAttachmentList(Attachments.SUB_DEPLOYMENTS)) {
            ModuleIdentifier moduleId = subDeployment.getAttachment(Attachments.MODULE_IDENTIFIER);
            if (moduleId != null) {
                phaseContext.addToAttachmentList(Attachments.NEXT_PHASE_DEPS, ServiceModuleLoader.moduleSpecServiceName(moduleId));
            }
        }

        if (parentDeployment == null) {
            //only top level deployment adds additional modules
            final List<AdditionalModuleSpecification> additionalModules = deploymentUnit.getAttachmentList(Attachments.ADDITIONAL_MODULES);
            for (final AdditionalModuleSpecification module : additionalModules) {
                addAllDependenciesAndPermissions(moduleSpec, module);
                List<ResourceRoot> roots = module.getResourceRoots();
                ServiceName serviceName = createModuleService(phaseContext, deploymentUnit, roots, parentResourceRoots, module, module.getModuleIdentifier());
                phaseContext.addToAttachmentList(Attachments.NEXT_PHASE_DEPS, serviceName);
            }
        }
    }