Search in sources :

Example 1 with ProcessApplicationModuleService

use of org.camunda.bpm.container.impl.jboss.service.ProcessApplicationModuleService in project camunda-bpm-platform by camunda.

the class ModuleDependencyProcessor method deploy.

public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    if (deploymentUnit.getParent() == null) {
        // The deployment unit has no parent so it is a simple war or an ear.
        ModuleLoader moduleLoader = Module.getBootModuleLoader();
        // If it is a simpleWar and marked with process application we have to add the dependency
        boolean isProcessApplicationWarOrEar = ProcessApplicationAttachments.isProcessApplication(deploymentUnit);
        AttachmentList<DeploymentUnit> subdeployments = deploymentUnit.getAttachment(Attachments.SUB_DEPLOYMENTS);
        // In cases of war files we have nothing todo.
        if (subdeployments != null) {
            // The deployment unit contains sub deployments which means the deployment unit is an ear.
            // We have to check whether sub deployments are process applications or not.
            boolean subDeploymentIsProcessApplication = false;
            for (DeploymentUnit subDeploymentUnit : subdeployments) {
                if (ProcessApplicationAttachments.isProcessApplication(subDeploymentUnit)) {
                    subDeploymentIsProcessApplication = true;
                    break;
                }
            }
            // Also we have to add the dependency to the current deployment unit which is an ear
            if (subDeploymentIsProcessApplication) {
                for (DeploymentUnit subDeploymentUnit : subdeployments) {
                    final ModuleSpecification moduleSpecification = subDeploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
                    addSystemDependencies(moduleLoader, moduleSpecification);
                }
                // An ear is not marked as process application but also needs the dependency
                isProcessApplicationWarOrEar = true;
            }
        }
        if (isProcessApplicationWarOrEar) {
            final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
            addSystemDependencies(moduleLoader, moduleSpecification);
        }
    }
    // install the pa-module service
    ModuleIdentifier identifyer = deploymentUnit.getAttachment(Attachments.MODULE_IDENTIFIER);
    String moduleName = identifyer.toString();
    ProcessApplicationModuleService processApplicationModuleService = new ProcessApplicationModuleService();
    ServiceName serviceName = ServiceNames.forProcessApplicationModuleService(moduleName);
    phaseContext.getServiceTarget().addService(serviceName, processApplicationModuleService).addDependency(phaseContext.getPhaseServiceName()).setInitialMode(Mode.ACTIVE).install();
}
Also used : ModuleLoader(org.jboss.modules.ModuleLoader) ProcessApplicationModuleService(org.camunda.bpm.container.impl.jboss.service.ProcessApplicationModuleService) ServiceName(org.jboss.msc.service.ServiceName) ModuleSpecification(org.jboss.as.server.deployment.module.ModuleSpecification) ModuleIdentifier(org.jboss.modules.ModuleIdentifier) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Aggregations

ProcessApplicationModuleService (org.camunda.bpm.container.impl.jboss.service.ProcessApplicationModuleService)1 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)1 ModuleSpecification (org.jboss.as.server.deployment.module.ModuleSpecification)1 ModuleIdentifier (org.jboss.modules.ModuleIdentifier)1 ModuleLoader (org.jboss.modules.ModuleLoader)1 ServiceName (org.jboss.msc.service.ServiceName)1