use of org.camunda.bpm.engine.impl.jobexecutor.JobHandler in project camunda-bpm-platform by camunda.
the class JobEntity method execute.
public void execute(CommandContext commandContext) {
if (executionId != null) {
ExecutionEntity execution = getExecution();
ensureNotNull("Cannot find execution with id '" + executionId + "' referenced from job '" + this + "'", "execution", execution);
}
// initialize activity id
getActivityId();
// increment sequence counter before job execution
incrementSequenceCounter();
preExecute(commandContext);
JobHandler jobHandler = getJobHandler();
JobHandlerConfiguration configuration = getJobHandlerConfiguration();
ensureNotNull("Cannot find job handler '" + jobHandlerType + "' from job '" + this + "'", "jobHandler", jobHandler);
jobHandler.execute(configuration, execution, commandContext, tenantId);
postExecute(commandContext);
}
use of org.camunda.bpm.engine.impl.jobexecutor.JobHandler in project camunda-bpm-platform by camunda.
the class ProcessEngineConfigurationImpl method initJobExecutor.
// job executor /////////////////////////////////////////////////////////////
protected void initJobExecutor() {
if (jobExecutor == null) {
jobExecutor = new DefaultJobExecutor();
}
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);
TimerStartEventSubprocessJobHandler timerStartEventSubprocess = new TimerStartEventSubprocessJobHandler();
jobHandlers.put(timerStartEventSubprocess.getType(), timerStartEventSubprocess);
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);
TimerSuspendJobDefinitionHandler suspendJobDefinitionHandler = new TimerSuspendJobDefinitionHandler();
jobHandlers.put(suspendJobDefinitionHandler.getType(), suspendJobDefinitionHandler);
TimerActivateJobDefinitionHandler activateJobDefinitionHandler = new TimerActivateJobDefinitionHandler();
jobHandlers.put(activateJobDefinitionHandler.getType(), activateJobDefinitionHandler);
BatchSeedJobHandler batchSeedJobHandler = new BatchSeedJobHandler();
jobHandlers.put(batchSeedJobHandler.getType(), batchSeedJobHandler);
BatchMonitorJobHandler batchMonitorJobHandler = new BatchMonitorJobHandler();
jobHandlers.put(batchMonitorJobHandler.getType(), batchMonitorJobHandler);
HistoryCleanupJobHandler historyCleanupJobHandler = new HistoryCleanupJobHandler();
jobHandlers.put(historyCleanupJobHandler.getType(), historyCleanupJobHandler);
for (JobHandler batchHandler : batchHandlers.values()) {
jobHandlers.put(batchHandler.getType(), batchHandler);
}
// if we have custom job handlers, register them
if (getCustomJobHandlers() != null) {
for (JobHandler customJobHandler : getCustomJobHandlers()) {
jobHandlers.put(customJobHandler.getType(), customJobHandler);
}
}
jobExecutor.setAutoActivate(jobExecutorActivate);
if (jobExecutor.getRejectedJobsHandler() == null) {
if (customRejectedJobsHandler != null) {
jobExecutor.setRejectedJobsHandler(customRejectedJobsHandler);
} else {
jobExecutor.setRejectedJobsHandler(new NotifyAcquisitionRejectedJobsHandler());
}
}
}
use of org.camunda.bpm.engine.impl.jobexecutor.JobHandler in project camunda-bpm-platform by camunda.
the class EverLivingJobEntity method init.
@Override
public void init(CommandContext commandContext) {
// clean additional data related to this job
JobHandler jobHandler = getJobHandler();
if (jobHandler != null) {
jobHandler.onDelete(getJobHandlerConfiguration(), this);
}
// cancel the retries -> will resolve job incident if present
setRetries(commandContext.getProcessEngineConfiguration().getDefaultNumberOfRetries());
// delete the job's exception byte array and exception message
String exceptionByteArrayIdToDelete = null;
if (exceptionByteArrayId != null) {
exceptionByteArrayIdToDelete = exceptionByteArrayId;
this.exceptionByteArrayId = null;
this.exceptionMessage = null;
}
// clean the lock information
setLockOwner(null);
setLockExpirationTime(null);
if (exceptionByteArrayIdToDelete != null) {
ByteArrayEntity byteArray = commandContext.getDbEntityManager().selectById(ByteArrayEntity.class, exceptionByteArrayIdToDelete);
commandContext.getDbEntityManager().delete(byteArray);
}
}
use of org.camunda.bpm.engine.impl.jobexecutor.JobHandler in project camunda-bpm-platform by camunda.
the class JobEntity method delete.
public void delete(boolean incidentResolved) {
CommandContext commandContext = Context.getCommandContext();
incrementSequenceCounter();
// clean additional data related to this job
JobHandler jobHandler = getJobHandler();
if (jobHandler != null) {
jobHandler.onDelete(getJobHandlerConfiguration(), this);
}
// fire delete event if this job is not being executed
boolean executingJob = this.equals(commandContext.getCurrentJob());
commandContext.getJobManager().deleteJob(this, !executingJob);
// Also delete the job's exception byte array
if (exceptionByteArrayId != null) {
commandContext.getByteArrayManager().deleteByteArrayById(exceptionByteArrayId);
}
// remove link to execution
ExecutionEntity execution = getExecution();
if (execution != null) {
execution.removeJob(this);
}
removeFailedJobIncident(incidentResolved);
}
Aggregations