Search in sources :

Example 21 with DeploymentUnit

use of org.jboss.as.server.deployment.DeploymentUnit 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)

Example 22 with DeploymentUnit

use of org.jboss.as.server.deployment.DeploymentUnit in project camunda-bpm-platform by camunda.

the class ProcessApplicationDeploymentProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    if (!ProcessApplicationAttachments.isProcessApplication(deploymentUnit)) {
        return;
    }
    final ComponentDescription paComponent = getProcessApplicationComponent(deploymentUnit);
    final ServiceName paViewServiceName = getProcessApplicationViewServiceName(paComponent);
    Module module = deploymentUnit.getAttachment(Attachments.MODULE);
    final String moduleName = module.getIdentifier().toString();
    final ServiceName paStartServiceName = ServiceNames.forProcessApplicationStartService(moduleName);
    final ServiceName paStopServiceName = ServiceNames.forProcessApplicationStopService(moduleName);
    final ServiceName noViewStartService = ServiceNames.forNoViewProcessApplicationStartService(moduleName);
    List<ServiceName> deploymentServiceNames = new ArrayList<ServiceName>();
    ProcessApplicationStopService paStopService = new ProcessApplicationStopService();
    ServiceBuilder<ProcessApplicationStopService> stopServiceBuilder = phaseContext.getServiceTarget().addService(paStopServiceName, paStopService).addDependency(phaseContext.getPhaseServiceName()).addDependency(ServiceNames.forBpmPlatformPlugins(), BpmPlatformPlugins.class, paStopService.getPlatformPluginsInjector()).setInitialMode(Mode.ACTIVE);
    if (paViewServiceName != null) {
        stopServiceBuilder.addDependency(paViewServiceName, ComponentView.class, paStopService.getPaComponentViewInjector());
    } else {
        stopServiceBuilder.addDependency(noViewStartService, ProcessApplicationInterface.class, paStopService.getNoViewProcessApplication());
    }
    stopServiceBuilder.install();
    // deploy all process archives
    List<ProcessesXmlWrapper> processesXmlWrappers = ProcessApplicationAttachments.getProcessesXmls(deploymentUnit);
    for (ProcessesXmlWrapper processesXmlWrapper : processesXmlWrappers) {
        ProcessesXml processesXml = processesXmlWrapper.getProcessesXml();
        for (ProcessArchiveXml processArchive : processesXml.getProcessArchives()) {
            ServiceName processEngineServiceName = getProcessEngineServiceName(processArchive);
            Map<String, byte[]> deploymentResources = getDeploymentResources(processArchive, deploymentUnit, processesXmlWrapper.getProcessesXmlFile());
            // add the deployment service for each process archive we deploy.
            ProcessApplicationDeploymentService deploymentService = new ProcessApplicationDeploymentService(deploymentResources, processArchive, module);
            String processArachiveName = processArchive.getName();
            if (processArachiveName == null) {
                // use random name for deployment service if name is null (we cannot ask the process application yet since the component might not be up.
                processArachiveName = UUID.randomUUID().toString();
            }
            ServiceName deploymentServiceName = ServiceNames.forProcessApplicationDeploymentService(deploymentUnit.getName(), processArachiveName);
            ServiceBuilder<ProcessApplicationDeploymentService> serviceBuilder = phaseContext.getServiceTarget().addService(deploymentServiceName, deploymentService).addDependency(phaseContext.getPhaseServiceName()).addDependency(paStopServiceName).addDependency(processEngineServiceName, ProcessEngine.class, deploymentService.getProcessEngineInjector()).setInitialMode(Mode.ACTIVE);
            if (paViewServiceName != null) {
                // add a dependency on the component start service to make sure we are started after the pa-component (Singleton EJB) has started
                serviceBuilder.addDependency(paComponent.getStartServiceName());
                serviceBuilder.addDependency(paViewServiceName, ComponentView.class, deploymentService.getPaComponentViewInjector());
            } else {
                serviceBuilder.addDependency(noViewStartService, ProcessApplicationInterface.class, deploymentService.getNoViewProcessApplication());
            }
            JBossCompatibilityExtension.addServerExecutorDependency(serviceBuilder, deploymentService.getExecutorInjector(), false);
            serviceBuilder.install();
            deploymentServiceNames.add(deploymentServiceName);
        }
    }
    AnnotationInstance postDeploy = ProcessApplicationAttachments.getPostDeployDescription(deploymentUnit);
    AnnotationInstance preUndeploy = ProcessApplicationAttachments.getPreUndeployDescription(deploymentUnit);
    // register the managed process application start service
    ProcessApplicationStartService paStartService = new ProcessApplicationStartService(deploymentServiceNames, postDeploy, preUndeploy, module);
    ServiceBuilder<ProcessApplicationStartService> serviceBuilder = phaseContext.getServiceTarget().addService(paStartServiceName, paStartService).addDependency(phaseContext.getPhaseServiceName()).addDependency(ServiceNames.forDefaultProcessEngine(), ProcessEngine.class, paStartService.getDefaultProcessEngineInjector()).addDependency(ServiceNames.forBpmPlatformPlugins(), BpmPlatformPlugins.class, paStartService.getPlatformPluginsInjector()).addDependencies(deploymentServiceNames).setInitialMode(Mode.ACTIVE);
    if (paViewServiceName != null) {
        serviceBuilder.addDependency(paViewServiceName, ComponentView.class, paStartService.getPaComponentViewInjector());
    } else {
        serviceBuilder.addDependency(noViewStartService, ProcessApplicationInterface.class, paStartService.getNoViewProcessApplication());
    }
    serviceBuilder.install();
}
Also used : ProcessesXmlWrapper(org.camunda.bpm.container.impl.jboss.util.ProcessesXmlWrapper) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) ProcessApplicationStartService(org.camunda.bpm.container.impl.jboss.service.ProcessApplicationStartService) ProcessArchiveXml(org.camunda.bpm.application.impl.metadata.spi.ProcessArchiveXml) ArrayList(java.util.ArrayList) ProcessApplicationDeploymentService(org.camunda.bpm.container.impl.jboss.service.ProcessApplicationDeploymentService) BpmPlatformPlugins(org.camunda.bpm.container.impl.plugin.BpmPlatformPlugins) ServiceName(org.jboss.msc.service.ServiceName) ProcessesXml(org.camunda.bpm.application.impl.metadata.spi.ProcessesXml) ProcessApplicationStopService(org.camunda.bpm.container.impl.jboss.service.ProcessApplicationStopService) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) AnnotationInstance(org.jboss.jandex.AnnotationInstance) ProcessEngine(org.camunda.bpm.engine.ProcessEngine)

Example 23 with DeploymentUnit

use of org.jboss.as.server.deployment.DeploymentUnit in project camunda-bpm-platform by camunda.

the class ProcessApplicationProcessor method deploy.

public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    // must be EE Module
    if (eeModuleDescription == null) {
        return;
    }
    // discover user-provided component
    ComponentDescription paComponent = detectExistingComponent(deploymentUnit);
    if (paComponent != null) {
        log.log(Level.INFO, "Detected user-provided @" + ProcessApplication.class.getSimpleName() + " component with name '" + paComponent.getComponentName() + "'.");
        // mark this to be a process application
        ProcessApplicationAttachments.attachProcessApplicationComponent(deploymentUnit, paComponent);
        ProcessApplicationAttachments.mark(deploymentUnit);
        ProcessApplicationAttachments.markPartOfProcessApplication(deploymentUnit);
    }
}
Also used : SessionBeanComponentDescription(org.jboss.as.ejb3.component.session.SessionBeanComponentDescription) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) WebComponentDescription(org.jboss.as.web.common.WebComponentDescription) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) ServletProcessApplication(org.camunda.bpm.application.impl.ServletProcessApplication) ProcessApplication(org.camunda.bpm.application.ProcessApplication)

Example 24 with DeploymentUnit

use of org.jboss.as.server.deployment.DeploymentUnit in project wildfly by wildfly.

the class EESecurityDependencyProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit unit = phaseContext.getDeploymentUnit();
    final DeploymentUnit top = unit.getParent() == null ? unit : unit.getParent();
    final ModuleLoader moduleLoader = Module.getBootModuleLoader();
    final ModuleSpecification moduleSpec = unit.getAttachment(Attachments.MODULE_SPECIFICATION);
    moduleSpec.addSystemDependency(new ModuleDependency(moduleLoader, ModuleIdentifier.fromString("javax.security.enterprise.api"), false, false, true, false));
    Boolean securityPresent = top.getAttachment(EESecurityAnnotationProcessor.SECURITY_PRESENT);
    if (securityPresent != null && securityPresent) {
        moduleSpec.addSystemDependency(new ModuleDependency(moduleLoader, ModuleIdentifier.fromString("org.glassfish.soteria"), false, false, true, false));
    }
}
Also used : ModuleLoader(org.jboss.modules.ModuleLoader) ModuleDependency(org.jboss.as.server.deployment.module.ModuleDependency) ModuleSpecification(org.jboss.as.server.deployment.module.ModuleSpecification) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 25 with DeploymentUnit

use of org.jboss.as.server.deployment.DeploymentUnit in project wildfly by wildfly.

the class EESecurityAnnotationProcessor method markAsEESecurity.

private void markAsEESecurity(DeploymentUnit deploymentUnit) {
    DeploymentUnit top = deploymentUnit.getParent() == null ? deploymentUnit : deploymentUnit.getParent();
    top.putAttachment(SECURITY_PRESENT, true);
}
Also used : DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Aggregations

DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)359 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)84 Module (org.jboss.modules.Module)70 ServiceName (org.jboss.msc.service.ServiceName)62 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)56 ResourceRoot (org.jboss.as.server.deployment.module.ResourceRoot)56 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)47 ModuleSpecification (org.jboss.as.server.deployment.module.ModuleSpecification)45 CapabilityServiceSupport (org.jboss.as.controller.capability.CapabilityServiceSupport)40 VirtualFile (org.jboss.vfs.VirtualFile)39 ArrayList (java.util.ArrayList)37 CompositeIndex (org.jboss.as.server.deployment.annotation.CompositeIndex)37 ModuleLoader (org.jboss.modules.ModuleLoader)35 ServiceTarget (org.jboss.msc.service.ServiceTarget)34 ModuleDependency (org.jboss.as.server.deployment.module.ModuleDependency)33 WarMetaData (org.jboss.as.web.common.WarMetaData)31 HashMap (java.util.HashMap)30 HashSet (java.util.HashSet)30 EEApplicationClasses (org.jboss.as.ee.component.EEApplicationClasses)20 DeploymentReflectionIndex (org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex)20