Search in sources :

Example 1 with CommandContext

use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.

the class JsonSerializationTest method testVariableValueCaching.

@Deployment(resources = ONE_TASK_PROCESS)
public void testVariableValueCaching() {
    final ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
    processEngineConfiguration.getCommandExecutorTxRequired().execute(new Command<Void>() {

        @Override
        public Void execute(CommandContext commandContext) {
            JsonSerializable bean = new JsonSerializable("a String", 42, true);
            runtimeService.setVariable(instance.getId(), "simpleBean", bean);
            Object returnedBean = runtimeService.getVariable(instance.getId(), "simpleBean");
            assertSame(bean, returnedBean);
            return null;
        }
    });
    VariableInstance variableInstance = runtimeService.createVariableInstanceQuery().singleResult();
    Object returnedBean = variableInstance.getValue();
    Object theSameReturnedBean = variableInstance.getValue();
    assertSame(returnedBean, theSameReturnedBean);
}
Also used : CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 2 with CommandContext

use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.

the class ProcessApplicationManager method getDeployedCaseDefinitionArtifacts.

protected List<CaseDefinition> getDeployedCaseDefinitionArtifacts(DeploymentEntity deployment) {
    CommandContext commandContext = Context.getCommandContext();
    // in case deployment was created by this command
    List<CaseDefinition> entities = deployment.getDeployedCaseDefinitions();
    if (entities == null) {
        String deploymentId = deployment.getId();
        CaseDefinitionManager caseDefinitionManager = commandContext.getCaseDefinitionManager();
        return caseDefinitionManager.findCaseDefinitionByDeploymentId(deploymentId);
    }
    return entities;
}
Also used : CaseDefinitionManager(org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionManager) CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition)

Example 3 with CommandContext

use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.

the class ProcessApplicationManager method logRegistration.

// logger ////////////////////////////////////////////////////////////////////////////
protected void logRegistration(Set<String> deploymentIds, ProcessApplicationReference reference) {
    if (!LOG.isInfoEnabled()) {
        // building the log message is expensive (db queries) so we avoid it if we can
        return;
    }
    try {
        StringBuilder builder = new StringBuilder();
        builder.append("ProcessApplication '");
        builder.append(reference.getName());
        builder.append("' registered for DB deployments ");
        builder.append(deploymentIds);
        builder.append(". ");
        List<ProcessDefinition> processDefinitions = new ArrayList<ProcessDefinition>();
        List<CaseDefinition> caseDefinitions = new ArrayList<CaseDefinition>();
        CommandContext commandContext = Context.getCommandContext();
        ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
        boolean cmmnEnabled = processEngineConfiguration.isCmmnEnabled();
        for (String deploymentId : deploymentIds) {
            DeploymentEntity deployment = commandContext.getDbEntityManager().selectById(DeploymentEntity.class, deploymentId);
            if (deployment != null) {
                processDefinitions.addAll(getDeployedProcessDefinitionArtifacts(deployment));
                if (cmmnEnabled) {
                    caseDefinitions.addAll(getDeployedCaseDefinitionArtifacts(deployment));
                }
            }
        }
        logProcessDefinitionRegistrations(builder, processDefinitions);
        if (cmmnEnabled) {
            logCaseDefinitionRegistrations(builder, caseDefinitions);
        }
        LOG.registrationSummary(builder.toString());
    } catch (Throwable e) {
        LOG.exceptionWhileLoggingRegistrationSummary(e);
    }
}
Also used : DeploymentEntity(org.camunda.bpm.engine.impl.persistence.entity.DeploymentEntity) CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition) ArrayList(java.util.ArrayList) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)

Example 4 with CommandContext

use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.

the class ModificationBatchJobHandler method postProcessJob.

@Override
protected void postProcessJob(ModificationBatchConfiguration configuration, JobEntity job) {
    CommandContext commandContext = Context.getCommandContext();
    ProcessDefinitionEntity processDefinitionEntity = commandContext.getProcessEngineConfiguration().getDeploymentCache().findDeployedProcessDefinitionById(configuration.getProcessDefinitionId());
    job.setDeploymentId(processDefinitionEntity.getDeploymentId());
}
Also used : CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) ProcessDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)

Example 5 with CommandContext

use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.

the class RestartProcessInstancesJobHandler method postProcessJob.

@Override
protected void postProcessJob(RestartProcessInstancesBatchConfiguration configuration, JobEntity job) {
    CommandContext commandContext = Context.getCommandContext();
    ProcessDefinitionEntity processDefinitionEntity = commandContext.getProcessEngineConfiguration().getDeploymentCache().findDeployedProcessDefinitionById(configuration.getProcessDefinitionId());
    job.setDeploymentId(processDefinitionEntity.getDeploymentId());
}
Also used : CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) ProcessDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)

Aggregations

CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)120 CommandExecutor (org.camunda.bpm.engine.impl.interceptor.CommandExecutor)31 List (java.util.List)17 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)17 JobEntity (org.camunda.bpm.engine.impl.persistence.entity.JobEntity)11 Deployment (org.camunda.bpm.engine.test.Deployment)11 ArrayList (java.util.ArrayList)10 ProcessDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)10 Date (java.util.Date)9 HistoricIncident (org.camunda.bpm.engine.history.HistoricIncident)8 DeploymentCache (org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache)8 JobManager (org.camunda.bpm.engine.impl.persistence.entity.JobManager)8 Command (org.camunda.bpm.engine.impl.interceptor.Command)6 HistoricIncidentEntity (org.camunda.bpm.engine.impl.persistence.entity.HistoricIncidentEntity)6 After (org.junit.After)6 ProcessApplicationReference (org.camunda.bpm.application.ProcessApplicationReference)5 RepositoryService (org.camunda.bpm.engine.RepositoryService)5 ProcessEngineImpl (org.camunda.bpm.engine.impl.ProcessEngineImpl)5 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)5 HistoricDecisionInstance (org.camunda.bpm.engine.history.HistoricDecisionInstance)4