use of org.camunda.bpm.container.impl.jboss.service.ProcessApplicationStopService 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();
}
Aggregations