Search in sources :

Example 1 with ProcessApplicationInterface

use of org.camunda.bpm.application.ProcessApplicationInterface in project camunda-bpm-platform by camunda.

the class ProcessApplicationDeploymentService method performDeployment.

protected void performDeployment() throws StartException {
    ManagedReference reference = null;
    try {
        // get process engine
        ProcessEngine processEngine = processEngineInjector.getValue();
        // get the process application component
        ProcessApplicationInterface processApplication = null;
        ComponentView componentView = paComponentViewInjector.getOptionalValue();
        if (componentView != null) {
            reference = componentView.createInstance();
            processApplication = (ProcessApplicationInterface) reference.getInstance();
        } else {
            processApplication = noViewProcessApplication.getValue();
        }
        // get the application name
        String processApplicationName = processApplication.getName();
        // build the deployment
        final RepositoryService repositoryService = processEngine.getRepositoryService();
        final ProcessApplicationDeploymentBuilder deploymentBuilder = repositoryService.createDeployment(processApplication.getReference());
        // enable duplicate filtering
        deploymentBuilder.enableDuplicateFiltering(PropertyHelper.getBooleanProperty(processArchive.getProperties(), ProcessArchiveXml.PROP_IS_DEPLOY_CHANGED_ONLY, false));
        // enable resuming of previous versions:
        if (PropertyHelper.getBooleanProperty(processArchive.getProperties(), ProcessArchiveXml.PROP_IS_RESUME_PREVIOUS_VERSIONS, true)) {
            enableResumingOfPreviousVersions(deploymentBuilder);
        }
        // set the name for the deployment
        String deploymentName = processArchive.getName();
        if (deploymentName == null || deploymentName.isEmpty()) {
            deploymentName = processApplicationName;
        }
        deploymentBuilder.name(deploymentName);
        // set the tenant id for the deployment
        String tenantId = processArchive.getTenantId();
        if (tenantId != null && !tenantId.isEmpty()) {
            deploymentBuilder.tenantId(tenantId);
        }
        // add deployment resources
        for (Entry<String, byte[]> resource : deploymentMap.entrySet()) {
            deploymentBuilder.addInputStream(resource.getKey(), new ByteArrayInputStream(resource.getValue()));
        }
        // let the process application component add resources to the deployment.
        processApplication.createDeployment(processArchive.getName(), deploymentBuilder);
        Collection<String> resourceNames = deploymentBuilder.getResourceNames();
        if (!resourceNames.isEmpty()) {
            logDeploymentSummary(resourceNames, deploymentName, processApplicationName);
            // perform the actual deployment
            deployment = Tccl.runUnderClassloader(new Tccl.Operation<ProcessApplicationDeployment>() {

                public ProcessApplicationDeployment run() {
                    return deploymentBuilder.deploy();
                }
            }, module.getClassLoader());
        } else {
            LOGGER.info("Not creating a deployment for process archive '" + processArchive.getName() + "': no resources provided.");
        }
    } catch (Exception e) {
        throw new StartException("Could not register process application with shared process engine ", e);
    } finally {
        if (reference != null) {
            reference.release();
        }
    }
}
Also used : ManagedReference(org.jboss.as.naming.ManagedReference) ProcessApplicationInterface(org.camunda.bpm.application.ProcessApplicationInterface) StartException(org.jboss.msc.service.StartException) ProcessApplicationDeploymentBuilder(org.camunda.bpm.engine.repository.ProcessApplicationDeploymentBuilder) ComponentView(org.jboss.as.ee.component.ComponentView) ByteArrayInputStream(java.io.ByteArrayInputStream) StartException(org.jboss.msc.service.StartException) ProcessEngine(org.camunda.bpm.engine.ProcessEngine) RepositoryService(org.camunda.bpm.engine.RepositoryService)

Example 2 with ProcessApplicationInterface

use of org.camunda.bpm.application.ProcessApplicationInterface in project camunda-bpm-platform by camunda.

the class ProcessApplicationStartService method start.

@Override
public void start(StartContext context) throws StartException {
    ManagedReference reference = null;
    try {
        // get the process application component
        ProcessApplicationInterface processApplication = null;
        ComponentView componentView = paComponentViewInjector.getOptionalValue();
        if (componentView != null) {
            reference = componentView.createInstance();
            processApplication = (ProcessApplicationInterface) reference.getInstance();
        } else {
            processApplication = noViewProcessApplication.getValue();
        }
        // create & populate the process application info object
        processApplicationInfo = new ProcessApplicationInfoImpl();
        processApplicationInfo.setName(processApplication.getName());
        processApplicationInfo.setProperties(processApplication.getProperties());
        referencedProcessEngines = new HashSet<ProcessEngine>();
        List<ProcessApplicationDeploymentInfo> deploymentInfos = new ArrayList<ProcessApplicationDeploymentInfo>();
        for (ServiceName deploymentServiceName : deploymentServiceNames) {
            ProcessApplicationDeploymentService value = getDeploymentService(context, deploymentServiceName);
            referencedProcessEngines.add(value.getProcessEngineInjector().getValue());
            ProcessApplicationDeployment deployment = value.getDeployment();
            if (deployment != null) {
                for (String deploymentId : deployment.getProcessApplicationRegistration().getDeploymentIds()) {
                    ProcessApplicationDeploymentInfoImpl deploymentInfo = new ProcessApplicationDeploymentInfoImpl();
                    deploymentInfo.setDeploymentId(deploymentId);
                    deploymentInfo.setProcessEngineName(value.getProcessEngineName());
                    deploymentInfos.add(deploymentInfo);
                }
            }
        }
        processApplicationInfo.setDeploymentInfo(deploymentInfos);
        notifyBpmPlatformPlugins(platformPluginsInjector.getValue(), processApplication);
        if (postDeployDescription != null) {
            invokePostDeploy(processApplication);
        }
        // install the ManagedProcessApplication Service as a child to this service
        // if this service stops (at undeployment) the ManagedProcessApplication service is removed as well.
        ServiceName serviceName = ServiceNames.forManagedProcessApplication(processApplicationInfo.getName());
        MscManagedProcessApplication managedProcessApplication = new MscManagedProcessApplication(processApplicationInfo, processApplication.getReference());
        context.getChildTarget().addService(serviceName, managedProcessApplication).install();
    } catch (StartException e) {
        throw e;
    } catch (Exception e) {
        throw new StartException(e);
    } finally {
        if (reference != null) {
            reference.release();
        }
    }
}
Also used : ProcessApplicationDeploymentInfoImpl(org.camunda.bpm.application.impl.ProcessApplicationDeploymentInfoImpl) ProcessApplicationDeploymentInfo(org.camunda.bpm.application.ProcessApplicationDeploymentInfo) ProcessApplicationInfoImpl(org.camunda.bpm.application.impl.ProcessApplicationInfoImpl) ArrayList(java.util.ArrayList) ManagedReference(org.jboss.as.naming.ManagedReference) ProcessApplicationInterface(org.camunda.bpm.application.ProcessApplicationInterface) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) StartException(org.jboss.msc.service.StartException) ProcessApplicationDeployment(org.camunda.bpm.engine.repository.ProcessApplicationDeployment) ComponentView(org.jboss.as.ee.component.ComponentView) ServiceName(org.jboss.msc.service.ServiceName) StartException(org.jboss.msc.service.StartException) ProcessEngine(org.camunda.bpm.engine.ProcessEngine)

Example 3 with ProcessApplicationInterface

use of org.camunda.bpm.application.ProcessApplicationInterface in project camunda-bpm-platform by camunda.

the class ProcessApplicationStartService method stop.

@Override
public void stop(StopContext context) {
    ManagedReference reference = null;
    try {
        // get the process application component
        ProcessApplicationInterface processApplication = null;
        ComponentView componentView = paComponentViewInjector.getOptionalValue();
        if (componentView != null) {
            reference = componentView.createInstance();
            processApplication = (ProcessApplicationInterface) reference.getInstance();
        } else {
            processApplication = noViewProcessApplication.getValue();
        }
        invokePreUndeploy(processApplication);
    } catch (Exception e) {
        LOGGER.log(Level.SEVERE, "Exception while stopping process application", e);
    } finally {
        if (reference != null) {
            reference.release();
        }
    }
}
Also used : ComponentView(org.jboss.as.ee.component.ComponentView) ManagedReference(org.jboss.as.naming.ManagedReference) ProcessApplicationInterface(org.camunda.bpm.application.ProcessApplicationInterface) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) StartException(org.jboss.msc.service.StartException)

Example 4 with ProcessApplicationInterface

use of org.camunda.bpm.application.ProcessApplicationInterface in project camunda-bpm-platform by camunda.

the class StopProcessApplicationsStep method stopProcessApplication.

/**
 * <p> Stops a process application. Exceptions are logged but not re-thrown).
 *
 * @param processApplicationReference
 */
protected void stopProcessApplication(ProcessApplicationReference processApplicationReference) {
    try {
        // unless the user has overridden the stop behavior,
        // this causes the process application to remove its services
        // (triggers nested undeployment operation)
        ProcessApplicationInterface processApplication = processApplicationReference.getProcessApplication();
        processApplication.undeploy();
    } catch (Throwable t) {
        LOG.exceptionWhileStopping("Process Application", processApplicationReference.getName(), t);
    }
}
Also used : ProcessApplicationInterface(org.camunda.bpm.application.ProcessApplicationInterface)

Example 5 with ProcessApplicationInterface

use of org.camunda.bpm.application.ProcessApplicationInterface in project camunda-bpm-platform by camunda.

the class TypedValueField method getCurrentPaSerializers.

protected static VariableSerializers getCurrentPaSerializers() {
    if (Context.getCurrentProcessApplication() != null) {
        ProcessApplicationReference processApplicationReference = Context.getCurrentProcessApplication();
        try {
            ProcessApplicationInterface processApplicationInterface = processApplicationReference.getProcessApplication();
            ProcessApplicationInterface rawPa = processApplicationInterface.getRawObject();
            if (rawPa instanceof AbstractProcessApplication) {
                return ((AbstractProcessApplication) rawPa).getVariableSerializers();
            } else {
                return null;
            }
        } catch (ProcessApplicationUnavailableException e) {
            throw LOG.cannotDeterminePaDataformats(e);
        }
    } else {
        return null;
    }
}
Also used : ProcessApplicationReference(org.camunda.bpm.application.ProcessApplicationReference) ProcessApplicationUnavailableException(org.camunda.bpm.application.ProcessApplicationUnavailableException) AbstractProcessApplication(org.camunda.bpm.application.AbstractProcessApplication) ProcessApplicationInterface(org.camunda.bpm.application.ProcessApplicationInterface)

Aggregations

ProcessApplicationInterface (org.camunda.bpm.application.ProcessApplicationInterface)12 ProcessApplicationUnavailableException (org.camunda.bpm.application.ProcessApplicationUnavailableException)7 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)5 ProcessApplicationReference (org.camunda.bpm.application.ProcessApplicationReference)4 ComponentView (org.jboss.as.ee.component.ComponentView)4 ManagedReference (org.jboss.as.naming.ManagedReference)4 StartException (org.jboss.msc.service.StartException)4 AbstractProcessApplication (org.camunda.bpm.application.AbstractProcessApplication)3 ProcessEngine (org.camunda.bpm.engine.ProcessEngine)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ArrayList (java.util.ArrayList)1 ProcessApplicationDeploymentInfo (org.camunda.bpm.application.ProcessApplicationDeploymentInfo)1 ProcessApplicationDeploymentInfoImpl (org.camunda.bpm.application.impl.ProcessApplicationDeploymentInfoImpl)1 ProcessApplicationInfoImpl (org.camunda.bpm.application.impl.ProcessApplicationInfoImpl)1 BpmPlatformPlugin (org.camunda.bpm.container.impl.plugin.BpmPlatformPlugin)1 BpmPlatformPlugins (org.camunda.bpm.container.impl.plugin.BpmPlatformPlugins)1 RepositoryService (org.camunda.bpm.engine.RepositoryService)1 ExecutionListener (org.camunda.bpm.engine.delegate.ExecutionListener)1 TaskListener (org.camunda.bpm.engine.delegate.TaskListener)1 ProcessApplicationManager (org.camunda.bpm.engine.impl.application.ProcessApplicationManager)1