use of org.activiti.engine.impl.jobexecutor.JobHandler in project Activiti by Activiti.
the class TimerEventDefinitionParseHandler method executeParse.
protected void executeParse(BpmnParse bpmnParse, TimerEventDefinition timerEventDefinition) {
ActivityImpl timerActivity = bpmnParse.getCurrentActivity();
if (bpmnParse.getCurrentFlowElement() instanceof StartEvent) {
ProcessDefinitionEntity processDefinition = bpmnParse.getCurrentProcessDefinition();
timerActivity.setProperty("type", "startTimerEvent");
TimerDeclarationImpl timerDeclaration = createTimer(bpmnParse, timerEventDefinition, timerActivity, TimerStartEventJobHandler.TYPE);
String jobHandlerConfiguration = timerDeclaration.getJobHandlerConfiguration();
Map<String, JobHandler> jobHandlers = Context.getProcessEngineConfiguration().getJobHandlers();
JobHandler jobHandler = jobHandlers.get(TimerStartEventJobHandler.TYPE);
jobHandlerConfiguration = ((TimerEventHandler) jobHandler).setProcessDefinitionKeyToConfiguration(jobHandlerConfiguration, processDefinition.getKey());
jobHandlerConfiguration = ((TimerEventHandler) jobHandler).setActivityIdToConfiguration(jobHandlerConfiguration, timerActivity.getId());
timerDeclaration.setJobHandlerConfiguration(jobHandlerConfiguration);
List<TimerDeclarationImpl> timerDeclarations = (List<TimerDeclarationImpl>) processDefinition.getProperty(PROPERTYNAME_START_TIMER);
if (timerDeclarations == null) {
timerDeclarations = new ArrayList<TimerDeclarationImpl>();
processDefinition.setProperty(PROPERTYNAME_START_TIMER, timerDeclarations);
}
timerDeclarations.add(timerDeclaration);
} else if (bpmnParse.getCurrentFlowElement() instanceof IntermediateCatchEvent) {
timerActivity.setProperty("type", "intermediateTimer");
TimerDeclarationImpl timerDeclaration = createTimer(bpmnParse, timerEventDefinition, timerActivity, TimerCatchIntermediateEventJobHandler.TYPE);
if (getPrecedingEventBasedGateway(bpmnParse, (IntermediateCatchEvent) bpmnParse.getCurrentFlowElement()) != null) {
addTimerDeclaration(timerActivity.getParent(), timerDeclaration);
} else {
addTimerDeclaration(timerActivity, timerDeclaration);
timerActivity.setScope(true);
}
} else if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent) {
timerActivity.setProperty("type", "boundaryTimer");
TimerDeclarationImpl timerDeclaration = createTimer(bpmnParse, timerEventDefinition, timerActivity, TimerExecuteNestedActivityJobHandler.TYPE);
// ACT-1427
BoundaryEvent boundaryEvent = (BoundaryEvent) bpmnParse.getCurrentFlowElement();
boolean interrupting = boundaryEvent.isCancelActivity();
if (interrupting) {
timerDeclaration.setInterruptingTimer(true);
}
addTimerDeclaration(timerActivity.getParent(), timerDeclaration);
if (timerActivity.getParent() instanceof ActivityImpl) {
((ActivityImpl) timerActivity.getParent()).setScope(true);
}
timerActivity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createBoundaryEventActivityBehavior((BoundaryEvent) bpmnParse.getCurrentFlowElement(), interrupting, timerActivity));
}
}
use of org.activiti.engine.impl.jobexecutor.JobHandler in project Activiti by Activiti.
the class ProcessEngineConfigurationImpl method initJobHandlers.
protected void initJobHandlers() {
jobHandlers = new HashMap<String, JobHandler>();
TimerExecuteNestedActivityJobHandler timerExecuteNestedActivityJobHandler = new TimerExecuteNestedActivityJobHandler();
jobHandlers.put(timerExecuteNestedActivityJobHandler.getType(), timerExecuteNestedActivityJobHandler);
TimerCatchIntermediateEventJobHandler timerCatchIntermediateEvent = new TimerCatchIntermediateEventJobHandler();
jobHandlers.put(timerCatchIntermediateEvent.getType(), timerCatchIntermediateEvent);
TimerStartEventJobHandler timerStartEvent = new TimerStartEventJobHandler();
jobHandlers.put(timerStartEvent.getType(), timerStartEvent);
AsyncContinuationJobHandler asyncContinuationJobHandler = new AsyncContinuationJobHandler();
jobHandlers.put(asyncContinuationJobHandler.getType(), asyncContinuationJobHandler);
ProcessEventJobHandler processEventJobHandler = new ProcessEventJobHandler();
jobHandlers.put(processEventJobHandler.getType(), processEventJobHandler);
TimerSuspendProcessDefinitionHandler suspendProcessDefinitionHandler = new TimerSuspendProcessDefinitionHandler();
jobHandlers.put(suspendProcessDefinitionHandler.getType(), suspendProcessDefinitionHandler);
TimerActivateProcessDefinitionHandler activateProcessDefinitionHandler = new TimerActivateProcessDefinitionHandler();
jobHandlers.put(activateProcessDefinitionHandler.getType(), activateProcessDefinitionHandler);
// if we have custom job handlers, register them
if (getCustomJobHandlers() != null) {
for (JobHandler customJobHandler : getCustomJobHandlers()) {
jobHandlers.put(customJobHandler.getType(), customJobHandler);
}
}
}
use of org.activiti.engine.impl.jobexecutor.JobHandler in project Activiti by Activiti.
the class JobEntity method execute.
public void execute(CommandContext commandContext) {
ExecutionEntity execution = null;
if (executionId != null) {
execution = commandContext.getExecutionEntityManager().findExecutionById(executionId);
}
Map<String, JobHandler> jobHandlers = Context.getProcessEngineConfiguration().getJobHandlers();
JobHandler jobHandler = jobHandlers.get(jobHandlerType);
jobHandler.execute(this, jobHandlerConfiguration, execution, commandContext);
}
Aggregations