CommandContext existingCommandContext = Context.getCommandContext(); if(existingCommandContext != null && isFromSameEngine(existingCommandContext)) { context = existingCommandContext; Context.setCommandInvocationContext(commandInvocationContext); Context.setCommandContext(context); Context.setProcessEngineConfiguration(processEngineConfiguration); Context.removeCommandInvocationContext(); Context.removeCommandContext(); Context.removeProcessEngineConfiguration();
protected boolean isAutoStoreScriptVariablesEnabled() { ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration(); if(processEngineConfiguration != null) { return processEngineConfiguration.isAutoStoreScriptVariables(); } return false; }
protected ExecutionEntity getExecutionFromContext() { if(Context.getCommandContext() != null) { BpmnExecutionContext executionContext = Context.getBpmnExecutionContext(); if(executionContext != null) { return executionContext.getExecution(); } } return null; }
protected Map<String, List<ExecutableScript>> getEnv(String language) { ProcessEngineConfigurationImpl config = Context.getProcessEngineConfiguration(); ProcessApplicationReference processApplication = Context.getCurrentProcessApplication(); Map<String, List<ExecutableScript>> result = null; if (config.isEnableFetchScriptEngineFromProcessApplication()) { if(processApplication != null) { result = getPaEnvScripts(processApplication); } } return result != null ? result : env; }
protected void processEventSync(Object payload, Object payloadLocal, String businessKey) { EventHandler eventHandler = Context.getProcessEngineConfiguration().getEventHandler(eventType); ensureNotNull("Could not find eventhandler for event of type '" + eventType + "'", "eventHandler", eventHandler); eventHandler.handleEvent(this, payload, payloadLocal, businessKey, Context.getCommandContext()); }
public JobDefinitionEntity getSeedJobDefinition() { if (seedJobDefinition == null && seedJobDefinitionId != null) { seedJobDefinition = Context.getCommandContext().getJobDefinitionManager().findById(seedJobDefinitionId); } return seedJobDefinition; }
public Void execute(CommandContext commandContext) { assertEquals(this, Context.getCommandInvocationContext().getCommand()); if (innerCommand != null) { CommandExecutor commandExecutor = Context.getProcessEngineConfiguration().getCommandExecutorTxRequired(); commandExecutor.execute(innerCommand); // should still be correct after command invocation assertEquals(this, Context.getCommandInvocationContext().getCommand()); } return null; }
/** * @deprecated since 7.2, use {@link #getBpmnExecutionContext()} */ @Deprecated public static ExecutionContext getExecutionContext() { return getBpmnExecutionContext(); }
/** * Use {@link #executeWithinProcessApplication(Callable, ProcessApplicationReference, InvocationContext)} * instead if an {@link InvocationContext} is available. */ public static <T> T executeWithinProcessApplication(Callable<T> callback, ProcessApplicationReference processApplicationReference) { return executeWithinProcessApplication(callback, processApplicationReference, null); }
protected boolean shouldPerformPaContextSwitch(DelegateExecution execution) { if(execution == null) { return false; } else { ProcessApplicationReference targetPa = ProcessApplicationContextUtil.getTargetProcessApplication((ExecutionEntity) execution); return targetPa != null && !targetPa.equals(Context.getCurrentProcessApplication()); } }
@SuppressWarnings("deprecation") public void performOperationSync(AtomicOperation executionOperation) { if (requiresUnsuspendedExecution(executionOperation)) { ensureNotSuspended(); } Context.getCommandInvocationContext().performOperation(executionOperation, this); }
@After public void cleanup() { Context.removeCommandContext(); Context.removeProcessEngineConfiguration(); }
@Before public void setup() { mockedCmdContext = mock(CommandContext.class); mockedConfiguration = mock(ProcessEngineConfigurationImpl.class); authorizationManager = spy(new AuthorizationManager()); mockedEntityManager = mock(DbEntityManager.class); when(mockedCmdContext.getSession(eq(DbEntityManager.class))).thenReturn(mockedEntityManager); when(authorizationManager.filterAuthenticatedGroupIds(eq(AUTHENTICATED_GROUPS))).thenReturn(AUTHENTICATED_GROUPS); when(mockedCmdContext.getAuthentication()).thenReturn(new Authentication(AUTHENTICATED_USER_ID, AUTHENTICATED_GROUPS)); when(mockedCmdContext.isAuthorizationCheckEnabled()).thenReturn(true); when(mockedConfiguration.isAuthorizationEnabled()).thenReturn(true); Context.setCommandContext(mockedCmdContext); Context.setProcessEngineConfiguration(mockedConfiguration); }
protected Date calculateMonitorJobDueDate() { int pollTime = Context.getCommandContext() .getProcessEngineConfiguration() .getBatchPollTime(); long dueTime = ClockUtil.getCurrentTime().getTime() + (pollTime * 1000); return new Date(dueTime); }
public Object getValue(VariableContext variableContext) { if(Context.getCommandContext() == null) { throw new ProcessEngineException("Expression can only be evaluated inside the context of the process engine"); } ELContext context = Context.getProcessEngineConfiguration() .getExpressionManager() .createElContext(variableContext); return valueExpression.getValue(context); }
public Object execute(CommandContext commandContext) { CommandExecutor commandExecutor = Context.getProcessEngineConfiguration().getCommandExecutorTxRequired(); try { commandExecutor.execute(innerCommand); fail("exception expected to pop up during execution of inner command"); } catch (IdentifiableRuntimeException e) { // happy path assertNull("the exception should not have been propagated to this command's context", Context.getCommandInvocationContext().getThrowable()); } return null; } });
protected Map<String, List<ExecutableScript>> getEnv(String language) { ProcessEngineConfigurationImpl config = Context.getProcessEngineConfiguration(); ProcessApplicationReference processApplication = Context.getCurrentProcessApplication(); Map<String, List<ExecutableScript>> result = null; if (config.isEnableFetchScriptEngineFromProcessApplication()) { if(processApplication != null) { result = getPaEnvScripts(processApplication); } } return result != null ? result : env; }
/** * @deprecated since 7.2, use {@link #getBpmnExecutionContext()} */ @Deprecated public static ExecutionContext getExecutionContext() { return getBpmnExecutionContext(); }
/** * Use {@link #executeWithinProcessApplication(Callable, ProcessApplicationReference, InvocationContext)} * instead if an {@link InvocationContext} is available. */ public static <T> T executeWithinProcessApplication(Callable<T> callback, ProcessApplicationReference processApplicationReference) { return executeWithinProcessApplication(callback, processApplicationReference, null); }
@Override public ProcessApplicationReference execute(CommandContext commandContext) { return Context.getCurrentProcessApplication(); } });