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);
}
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;
}
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);
}
}
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());
}
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());
}
Aggregations