Search in sources :

Example 1 with JobHandler

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));
    }
}
Also used : TimerDeclarationImpl(org.activiti.engine.impl.jobexecutor.TimerDeclarationImpl) BoundaryEvent(org.activiti.bpmn.model.BoundaryEvent) IntermediateCatchEvent(org.activiti.bpmn.model.IntermediateCatchEvent) TimerStartEventJobHandler(org.activiti.engine.impl.jobexecutor.TimerStartEventJobHandler) TimerCatchIntermediateEventJobHandler(org.activiti.engine.impl.jobexecutor.TimerCatchIntermediateEventJobHandler) TimerExecuteNestedActivityJobHandler(org.activiti.engine.impl.jobexecutor.TimerExecuteNestedActivityJobHandler) JobHandler(org.activiti.engine.impl.jobexecutor.JobHandler) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) StartEvent(org.activiti.bpmn.model.StartEvent) ArrayList(java.util.ArrayList) List(java.util.List) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)

Example 2 with JobHandler

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);
        }
    }
}
Also used : TimerStartEventJobHandler(org.activiti.engine.impl.jobexecutor.TimerStartEventJobHandler) TimerCatchIntermediateEventJobHandler(org.activiti.engine.impl.jobexecutor.TimerCatchIntermediateEventJobHandler) JobHandler(org.activiti.engine.impl.jobexecutor.JobHandler) TimerExecuteNestedActivityJobHandler(org.activiti.engine.impl.jobexecutor.TimerExecuteNestedActivityJobHandler) ProcessEventJobHandler(org.activiti.engine.impl.jobexecutor.ProcessEventJobHandler) AsyncContinuationJobHandler(org.activiti.engine.impl.jobexecutor.AsyncContinuationJobHandler) TimerActivateProcessDefinitionHandler(org.activiti.engine.impl.jobexecutor.TimerActivateProcessDefinitionHandler) TimerCatchIntermediateEventJobHandler(org.activiti.engine.impl.jobexecutor.TimerCatchIntermediateEventJobHandler) ProcessEventJobHandler(org.activiti.engine.impl.jobexecutor.ProcessEventJobHandler) TimerSuspendProcessDefinitionHandler(org.activiti.engine.impl.jobexecutor.TimerSuspendProcessDefinitionHandler) TimerStartEventJobHandler(org.activiti.engine.impl.jobexecutor.TimerStartEventJobHandler) TimerExecuteNestedActivityJobHandler(org.activiti.engine.impl.jobexecutor.TimerExecuteNestedActivityJobHandler) AsyncContinuationJobHandler(org.activiti.engine.impl.jobexecutor.AsyncContinuationJobHandler)

Example 3 with JobHandler

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);
}
Also used : JobHandler(org.activiti.engine.impl.jobexecutor.JobHandler)

Aggregations

JobHandler (org.activiti.engine.impl.jobexecutor.JobHandler)3 TimerCatchIntermediateEventJobHandler (org.activiti.engine.impl.jobexecutor.TimerCatchIntermediateEventJobHandler)2 TimerExecuteNestedActivityJobHandler (org.activiti.engine.impl.jobexecutor.TimerExecuteNestedActivityJobHandler)2 TimerStartEventJobHandler (org.activiti.engine.impl.jobexecutor.TimerStartEventJobHandler)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 BoundaryEvent (org.activiti.bpmn.model.BoundaryEvent)1 IntermediateCatchEvent (org.activiti.bpmn.model.IntermediateCatchEvent)1 StartEvent (org.activiti.bpmn.model.StartEvent)1 AsyncContinuationJobHandler (org.activiti.engine.impl.jobexecutor.AsyncContinuationJobHandler)1 ProcessEventJobHandler (org.activiti.engine.impl.jobexecutor.ProcessEventJobHandler)1 TimerActivateProcessDefinitionHandler (org.activiti.engine.impl.jobexecutor.TimerActivateProcessDefinitionHandler)1 TimerDeclarationImpl (org.activiti.engine.impl.jobexecutor.TimerDeclarationImpl)1 TimerSuspendProcessDefinitionHandler (org.activiti.engine.impl.jobexecutor.TimerSuspendProcessDefinitionHandler)1 ProcessDefinitionEntity (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)1 ActivityImpl (org.activiti.engine.impl.pvm.process.ActivityImpl)1