org.activiti.engine.impl.jobexecutor.TimerExecuteNestedActivityJobHandler Java Examples
The following examples show how to use
org.activiti.engine.impl.jobexecutor.TimerExecuteNestedActivityJobHandler.
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 |
@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: ActivitiDelegateTest.java From herd with Apache License 2.0 | 6 votes |
/** * This method tests the scenario when an workflow related error is throws while workflow is executing an Async type task like Timer. This error is logged * as WARN. */ @Test(expected = ActivitiException.class) public void testActivitiUnReportableError() throws Exception { BpmnModel bpmnModel = getBpmnModelForXmlResource(ACTIVITI_XML_HERD_TIMER_WITH_CLASSPATH); ServiceTask serviceTask = (ServiceTask) bpmnModel.getProcesses().get(0).getFlowElement("servicetask1"); serviceTask.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION); serviceTask.setImplementation("${BeanNotAvailable}"); jobDefinitionServiceTestHelper.createJobDefinitionForActivitiXml(getActivitiXmlFromBpmnModel(bpmnModel)); Job job = jobService.createAndStartJob(jobServiceTestHelper.createJobCreateRequest(TEST_ACTIVITI_NAMESPACE_CD, TEST_ACTIVITI_JOB_NAME, null)); org.activiti.engine.runtime.Job timer = activitiManagementService.createJobQuery().processInstanceId(job.getId()).timers().singleResult(); if (timer != null) { executeWithoutLogging(TimerExecuteNestedActivityJobHandler.class, () -> { activitiManagementService.executeJob(timer.getId()); }); } }
Example #3
Source File: ProcessEngineConfigurationImpl.java From flowable-engine with Apache License 2.0 | 5 votes |
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 #4
Source File: ActivitiDelegateTest.java From herd with Apache License 2.0 | 5 votes |
/** * This method tests the scenario when an error that is not workflow related is throws while workflow is executing an Async type task like Timer. This error * is logged as ERROR. */ @Test(expected = ActivitiException.class) public void testActivitiReportableError() throws Exception { BpmnModel bpmnModel = getBpmnModelForXmlResource(ACTIVITI_XML_HERD_TIMER_WITH_CLASSPATH); ServiceTask serviceTask = (ServiceTask) bpmnModel.getProcesses().get(0).getFlowElement("servicetask1"); FieldExtension exceptionField = new FieldExtension(); exceptionField.setFieldName("exceptionToThrow"); exceptionField.setExpression("${exceptionToThrow}"); serviceTask.getFieldExtensions().add(exceptionField); jobDefinitionServiceTestHelper.createJobDefinitionForActivitiXml(getActivitiXmlFromBpmnModel(bpmnModel)); List<Parameter> parameters = new ArrayList<>(); Parameter parameter = new Parameter("exceptionToThrow", MockJavaDelegate.EXCEPTION_BPMN_ERROR); parameters.add(parameter); Job job = jobService.createAndStartJob(jobServiceTestHelper.createJobCreateRequest(TEST_ACTIVITI_NAMESPACE_CD, TEST_ACTIVITI_JOB_NAME, parameters)); org.activiti.engine.runtime.Job timer = activitiManagementService.createJobQuery().processInstanceId(job.getId()).timers().singleResult(); if (timer != null) { executeWithoutLogging(Arrays.asList(ActivitiRuntimeHelper.class, TimerExecuteNestedActivityJobHandler.class), () -> { activitiManagementService.executeJob(timer.getId()); }); } }
Example #5
Source File: TimerJobEntity.java From flowable-engine with Apache License 2.0 | 4 votes |
protected void restoreExtraData(CommandContext commandContext, String jobHandlerConfiguration) { String embededActivityId = jobHandlerConfiguration; if (jobHandlerType.equalsIgnoreCase(TimerExecuteNestedActivityJobHandler.TYPE) || jobHandlerType.equalsIgnoreCase(TimerCatchIntermediateEventJobHandler.TYPE) || jobHandlerType.equalsIgnoreCase(TimerStartEventJobHandler.TYPE)) { embededActivityId = TimerEventHandler.getActivityIdFromConfiguration(jobHandlerConfiguration); String endDateExpressionString = TimerEventHandler.getEndDateFromConfiguration(jobHandlerConfiguration); if (endDateExpressionString != null) { Expression endDateExpression = Context.getProcessEngineConfiguration().getExpressionManager().createExpression(endDateExpressionString); String endDateString = null; BusinessCalendar businessCalendar = Context.getProcessEngineConfiguration().getBusinessCalendarManager() .getBusinessCalendar(getBusinessCalendarName(TimerEventHandler.geCalendarNameFromConfiguration(jobHandlerConfiguration))); VariableScope executionEntity = null; if (executionId != null) { executionEntity = commandContext.getExecutionEntityManager().findExecutionById(executionId); } if (executionEntity == null) { executionEntity = NoExecutionVariableScope.getSharedInstance(); } if (endDateExpression != null) { Object endDateValue = endDateExpression.getValue(executionEntity); if (endDateValue instanceof String) { endDateString = (String) endDateValue; } else if (endDateValue instanceof Date) { endDate = (Date) endDateValue; } else { throw new ActivitiException("Timer '" + ((ExecutionEntity) executionEntity).getActivityId() + "' was not configured with a valid duration/time, either hand in a java.util.Date or a String in format 'yyyy-MM-dd'T'hh:mm:ss'"); } if (endDate == null) { endDate = businessCalendar.resolveEndDate(endDateString); } } } } if (processDefinitionId != null) { ProcessDefinition def = Context.getProcessEngineConfiguration().getRepositoryService().getProcessDefinition(processDefinitionId); maxIterations = checkStartEventDefinitions(def, embededActivityId); if (maxIterations <= 1) { maxIterations = checkBoundaryEventsDefinitions(def, embededActivityId); } } else { maxIterations = 1; } }
Example #6
Source File: TimerEventDefinitionParseHandler.java From flowable-engine with Apache License 2.0 | 4 votes |
protected TimerDeclarationImpl createTimer(BpmnParse bpmnParse, TimerEventDefinition timerEventDefinition, ScopeImpl timerActivity, String jobHandlerType) { TimerDeclarationType type = null; Expression expression = null; Expression endDate = null; Expression calendarName = null; ExpressionManager expressionManager = bpmnParse.getExpressionManager(); if (StringUtils.isNotEmpty(timerEventDefinition.getTimeDate())) { // TimeDate type = TimerDeclarationType.DATE; expression = expressionManager.createExpression(timerEventDefinition.getTimeDate()); } else if (StringUtils.isNotEmpty(timerEventDefinition.getTimeCycle())) { // TimeCycle type = TimerDeclarationType.CYCLE; expression = expressionManager.createExpression(timerEventDefinition.getTimeCycle()); // support for endDate if (StringUtils.isNotEmpty(timerEventDefinition.getEndDate())) { endDate = expressionManager.createExpression(timerEventDefinition.getEndDate()); } } else if (StringUtils.isNotEmpty(timerEventDefinition.getTimeDuration())) { // TimeDuration type = TimerDeclarationType.DURATION; expression = expressionManager.createExpression(timerEventDefinition.getTimeDuration()); } if (StringUtils.isNotEmpty(timerEventDefinition.getCalendarName())) { calendarName = expressionManager.createExpression(timerEventDefinition.getCalendarName()); } // neither date, cycle or duration configured! if (expression == null) { LOGGER.warn("Timer needs configuration (either timeDate, timeCycle or timeDuration is needed) ({})", timerActivity.getId()); } String jobHandlerConfiguration = timerActivity.getId(); if (jobHandlerType.equalsIgnoreCase(TimerExecuteNestedActivityJobHandler.TYPE) || jobHandlerType.equalsIgnoreCase(TimerCatchIntermediateEventJobHandler.TYPE) || jobHandlerType.equalsIgnoreCase(TimerStartEventJobHandler.TYPE)) { jobHandlerConfiguration = TimerStartEventJobHandler.createConfiguration(timerActivity.getId(), endDate, calendarName); } // Parse the timer declaration // TODO move the timer declaration into the bpmn activity or next to the // TimerSession TimerDeclarationImpl timerDeclaration = new TimerDeclarationImpl(expression, type, jobHandlerType, endDate, calendarName); timerDeclaration.setJobHandlerConfiguration(jobHandlerConfiguration); timerDeclaration.setExclusive(true); return timerDeclaration; }