Search in sources :

Example 11 with ProcessEngine

use of org.camunda.bpm.engine.ProcessEngine 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 12 with ProcessEngine

use of org.camunda.bpm.engine.ProcessEngine 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 13 with ProcessEngine

use of org.camunda.bpm.engine.ProcessEngine in project camunda-bpm-platform by camunda.

the class ProcessEngineStartProcessor method startProcessEngine.

protected void startProcessEngine(ProcessEngineXml processEngineXml, DeploymentPhaseContext phaseContext) {
    final ServiceTarget serviceTarget = phaseContext.getServiceTarget();
    // transform configuration
    ManagedProcessEngineMetadata configuration = transformConfiguration(processEngineXml);
    // validate the configuration
    configuration.validate();
    // create service instance
    MscManagedProcessEngineController service = new MscManagedProcessEngineController(configuration);
    // get the service name for the process engine
    ServiceName serviceName = ServiceNames.forManagedProcessEngine(processEngineXml.getName());
    // get service builder
    ServiceBuilder<ProcessEngine> serviceBuilder = serviceTarget.addService(serviceName, service);
    // make this service depend on the current phase -> makes sure it is removed with the phase service at undeployment
    serviceBuilder.addDependency(phaseContext.getPhaseServiceName());
    // add Service dependencies
    MscManagedProcessEngineController.initializeServiceBuilder(configuration, service, serviceBuilder, processEngineXml.getJobAcquisitionName());
    // make this start on demand
    serviceBuilder.setInitialMode(Mode.ACTIVE);
    // install the service
    serviceBuilder.install();
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) ServiceTarget(org.jboss.msc.service.ServiceTarget) ManagedProcessEngineMetadata(org.camunda.bpm.container.impl.jboss.config.ManagedProcessEngineMetadata) MscManagedProcessEngineController(org.camunda.bpm.container.impl.jboss.service.MscManagedProcessEngineController) ProcessEngine(org.camunda.bpm.engine.ProcessEngine)

Example 14 with ProcessEngine

use of org.camunda.bpm.engine.ProcessEngine in project camunda-bpm-platform by camunda.

the class ProcessInstanceRestServiceImpl method queryProcessInstancesCount.

@Override
public CountResultDto queryProcessInstancesCount(ProcessInstanceQueryDto queryDto) {
    ProcessEngine engine = getProcessEngine();
    queryDto.setObjectMapper(getObjectMapper());
    ProcessInstanceQuery query = queryDto.toQuery(engine);
    long count = query.count();
    CountResultDto result = new CountResultDto();
    result.setCount(count);
    return result;
}
Also used : HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) ProcessInstanceQuery(org.camunda.bpm.engine.runtime.ProcessInstanceQuery) CountResultDto(org.camunda.bpm.engine.rest.dto.CountResultDto) ProcessEngine(org.camunda.bpm.engine.ProcessEngine)

Example 15 with ProcessEngine

use of org.camunda.bpm.engine.ProcessEngine in project camunda-bpm-platform by camunda.

the class TaskRestServiceImpl method queryTasksCount.

@Override
public CountResultDto queryTasksCount(TaskQueryDto queryDto) {
    ProcessEngine engine = getProcessEngine();
    queryDto.setObjectMapper(getObjectMapper());
    TaskQuery query = queryDto.toQuery(engine);
    long count = query.count();
    CountResultDto result = new CountResultDto();
    result.setCount(count);
    return result;
}
Also used : TaskQuery(org.camunda.bpm.engine.task.TaskQuery) CountResultDto(org.camunda.bpm.engine.rest.dto.CountResultDto) ProcessEngine(org.camunda.bpm.engine.ProcessEngine)

Aggregations

ProcessEngine (org.camunda.bpm.engine.ProcessEngine)162 DescribesScenario (org.camunda.bpm.qa.upgrade.DescribesScenario)60 ScenarioSetup (org.camunda.bpm.qa.upgrade.ScenarioSetup)60 Task (org.camunda.bpm.engine.task.Task)52 Times (org.camunda.bpm.qa.upgrade.Times)52 Test (org.junit.Test)26 ExtendsScenario (org.camunda.bpm.qa.upgrade.ExtendsScenario)18 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)17 ArrayList (java.util.ArrayList)16 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)15 CountResultDto (org.camunda.bpm.engine.rest.dto.CountResultDto)14 AbstractFoxPlatformIntegrationTest (org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)14 RepositoryService (org.camunda.bpm.engine.RepositoryService)13 PooledDataSource (org.apache.ibatis.datasource.pooled.PooledDataSource)7 StandaloneInMemProcessEngineConfiguration (org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration)6 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)5 Job (org.camunda.bpm.engine.runtime.Job)5 Connection (java.sql.Connection)4 CaseService (org.camunda.bpm.engine.CaseService)4 StandaloneProcessEngineConfiguration (org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration)4