org.activiti.engine.impl.jobexecutor.JobHandler Java Examples

The following examples show how to use org.activiti.engine.impl.jobexecutor.JobHandler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AlfrescoProcessEngineConfiguration.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected void initJobExecutor() 
{
    super.initJobExecutor();

    // Wrap timer-job handler to handle authentication
    JobHandler timerJobHandler = jobHandlers.get(TimerExecuteNestedActivityJobHandler.TYPE);
    JobHandler wrappingTimerJobHandler = new AuthenticatedTimerJobHandler(timerJobHandler, unprotectedNodeService);
    jobHandlers.put(TimerExecuteNestedActivityJobHandler.TYPE, wrappingTimerJobHandler);
    
    // Wrap async-job handler to handle authentication
    JobHandler asyncJobHandler = jobHandlers.get(AsyncContinuationJobHandler.TYPE);
    JobHandler wrappingAsyncJobHandler = new AuthenticatedAsyncJobHandler(asyncJobHandler);
    jobHandlers.put(AsyncContinuationJobHandler.TYPE, wrappingAsyncJobHandler);
    
    // Wrap intermediate-timer-job handler to handle authentication
    JobHandler intermediateJobHandler = jobHandlers.get(TimerCatchIntermediateEventJobHandler.TYPE);
    JobHandler wrappingIntermediateJobHandler = new AuthenticatedAsyncJobHandler(intermediateJobHandler);
    jobHandlers.put(TimerCatchIntermediateEventJobHandler.TYPE, wrappingIntermediateJobHandler);
    
}
 
Example #2
Source File: JobEntity.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
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);
    delete();

    if (repeat != null) {
        TimerJobEntity timerRepeatJob = new TimerJobEntity(this);
        timerRepeatJob.scheduleNewTimer(commandContext);
    }
}
 
Example #3
Source File: DefaultJobManager.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected void executeJobHandler(JobEntity jobEntity) {
  ExecutionEntity execution = null;
  if (jobEntity.getExecutionId() != null) {
    execution = getExecutionEntityManager().findById(jobEntity.getExecutionId());
  }

  Map<String, JobHandler> jobHandlers = processEngineConfiguration.getJobHandlers();
  JobHandler jobHandler = jobHandlers.get(jobEntity.getJobHandlerType());
  jobHandler.execute(jobEntity, jobEntity.getJobHandlerConfiguration(), execution, getCommandContext());
}
 
Example #4
Source File: AuthenticatedAsyncJobHandler.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public AuthenticatedAsyncJobHandler(JobHandler jobHandler) 
{
    if (jobHandler == null)
    {
        throw new IllegalArgumentException("JobHandler to delegate to is required");
    }
    this.wrappedHandler = jobHandler;
}
 
Example #5
Source File: AuthenticatedTimerJobHandler.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * @param jobHandler the {@link JobHandler} to wrap.
 * @param nodeService the UNPROTECTED {@link NodeService} to use for fetching initiator username
 * when only tenant is known. We can't use initiator ScriptNode for this, because this uses the
 * protected {@link NodeService} which requires an authenticated user in that tenant (see {@link #getInitiator(ActivitiScriptNode)}).
 */
public AuthenticatedTimerJobHandler(JobHandler jobHandler, NodeService nodeService) 
{
    if (jobHandler == null)
    {
        throw new IllegalArgumentException("JobHandler to delegate to is required");
    }
    if(nodeService == null)
    {
        throw new IllegalArgumentException("NodeService is required");
    }
    this.unprotectedNodeService = nodeService;
    this.wrappedHandler = jobHandler;
}
 
Example #6
Source File: ProcessEngineConfigurationImpl.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
protected void initJobHandlers() {
    jobHandlers = new HashMap<>();
    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);
        }
    }
}
 
Example #7
Source File: TimerJobEntity.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public void execute(CommandContext commandContext) {

        // set endDate if it was set to the definition
        restoreExtraData(commandContext, jobHandlerConfiguration);

        if (this.getDuedate() != null && !isValidTime(this.getDuedate())) {
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("Timer {} fired. but the dueDate is after the endDate.  Deleting timer.", getId());
            }
            delete();
            return;
        }

        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);

        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Timer {} fired. Deleting timer.", getId());
        }
        delete();

        scheduleNextTimerIfRepeat();
    }
 
Example #8
Source File: ProcessEngineConfigurationImpl.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public Map<String, JobHandler> getJobHandlers() {
    return jobHandlers;
}
 
Example #9
Source File: ProcessEngineConfigurationImpl.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public ProcessEngineConfigurationImpl setJobHandlers(Map<String, JobHandler> jobHandlers) {
    this.jobHandlers = jobHandlers;
    return this;
}
 
Example #10
Source File: ProcessEngineConfigurationImpl.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public List<JobHandler> getCustomJobHandlers() {
    return customJobHandlers;
}
 
Example #11
Source File: ProcessEngineConfigurationImpl.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public ProcessEngineConfigurationImpl setCustomJobHandlers(List<JobHandler> customJobHandlers) {
    this.customJobHandlers = customJobHandlers;
    return this;
}