protected ExecutionContext getExecutionContext() { try { return Context.getExecutionContext(); } catch (EmptyStackException e) { // hack for bug in activiti return null; } }
public Object invoke(MethodInvocation methodInvocation) throws Throwable { String methodName = methodInvocation.getMethod().getName() ; logger.info("method invocation for " + methodName+ "."); if(methodName.equals("toString")) return "SharedProcessInstance"; ProcessInstance processInstance = Context.getExecutionContext().getProcessInstance(); Method method = methodInvocation.getMethod(); Object[] args = methodInvocation.getArguments(); Object result = method.invoke(processInstance, args); return result; } });
public Object resolveContextualObject(String key) { if ("executionId".equalsIgnoreCase(key)) return Context.getExecutionContext().getExecution().getId(); if ("processInstance".equalsIgnoreCase(key)) return Context.getExecutionContext().getProcessInstance(); if ("processInstanceId".equalsIgnoreCase(key)) return Context.getExecutionContext().getProcessInstance().getId(); return null; }
protected BusinessProcessEvent createEvent(DelegateExecution execution) { ProcessDefinition processDefinition = Context.getExecutionContext().getProcessDefinition(); return new CdiBusinessProcessEvent(activityId, transitionName, processDefinition, execution, type, new Date()); }
private void persistVariable(String variableName, Object scopedObject) { ProcessInstance processInstance = Context.getExecutionContext().getProcessInstance(); ExecutionEntity executionEntity = (ExecutionEntity) processInstance; Assert.isTrue(scopedObject instanceof Serializable, "the scopedObject is not " + Serializable.class.getName() + "!"); executionEntity.setVariable(variableName, scopedObject); } }
protected BusinessProcessEvent createEvent(DelegateExecution execution) { ProcessDefinition processDefinition = Context.getExecutionContext().getProcessDefinition(); return new CdiBusinessProcessEvent(activityId, transitionName, processDefinition, execution, type, new Date()); }
@Override public java.lang.Object get(java.lang.Object o) { Assert.isInstanceOf(String.class, o, "the 'key' must be a String"); String varName = (String) o; ProcessInstance processInstance = Context.getExecutionContext().getProcessInstance(); ExecutionEntity executionEntity = (ExecutionEntity) processInstance; if (executionEntity.getVariableNames().contains(varName)) { return executionEntity.getVariable(varName); } throw new RuntimeException("no processVariable by the name of '" + varName + "' is available!"); } };
protected ExecutionEntity getExecutionFromContext() { if(Context.getCommandContext() != null) { ExecutionContext executionContext = Context.getExecutionContext(); if(executionContext != null) { return executionContext.getExecution(); } } return null; }
protected ExecutionEntity getExecutionFromContext() { if(Context.getCommandContext() != null) { ExecutionContext executionContext = Context.getExecutionContext(); if(executionContext != null) { return executionContext.getExecution(); } } return null; }
private String getExecutionId() { return Context.getExecutionContext().getExecution().getId(); }
public void exception(Throwable exception) { if (this.exception == null) { this.exception = exception; } else { if (Context.isExecutionContextActive()) { LogMDC.putMDCExecution(Context.getExecutionContext().getExecution()); } LOGGER.error("masked exception in command context. for root cause, see below as it will be rethrown later.", exception); LogMDC.clear(); } }
public Object get(String name, ObjectFactory<?> objectFactory) { ExecutionEntity executionEntity = null; try { logger.fine("returning scoped object having beanName '" + name + "' for conversation ID '" + this.getConversationId() + "'. "); ProcessInstance processInstance = Context.getExecutionContext().getProcessInstance(); executionEntity = (ExecutionEntity) processInstance; Object scopedObject = executionEntity.getVariable(name); if (scopedObject == null) { scopedObject = objectFactory.getObject(); if (scopedObject instanceof ScopedObject) { ScopedObject sc = (ScopedObject) scopedObject; scopedObject = sc.getTargetObject(); logger.fine("de-referencing " + ScopedObject.class.getName() + "#targetObject before persisting variable"); } persistVariable(name, scopedObject); } return createDirtyCheckingProxy(name, scopedObject); } catch (Throwable th) { logger.warning("couldn't return value from process scope! " + ExceptionUtils.getFullStackTrace(th)); } finally { if (executionEntity != null) { logger.fine("set variable '" + name + "' on executionEntity# " + executionEntity.getId()); } } return null; }
@Override public void onEvent(FlowableEvent event) { if (isValidEvent(event) && event instanceof FlowableEngineEvent) { FlowableEngineEvent engineEvent = (FlowableEngineEvent) event; ExecutionEntity execution = null; if (Context.isExecutionContextActive()) { execution = Context.getExecutionContext().getExecution(); } else if (engineEvent.getExecutionId() != null) { // Get the execution based on the event's execution ID instead execution = Context.getCommandContext().getExecutionEntityManager().findExecutionById(engineEvent.getExecutionId()); } if (execution == null) { throw new ActivitiException("No execution context active and event is not related to an execution. No compensation event can be thrown."); } try { ErrorPropagation.propagateError(errorCode, execution); } catch (Exception e) { throw new ActivitiException("Error while propagating error-event", e); } } }
protected static void populateEventWithCurrentContext(ActivitiEventImpl event) { boolean extractedFromContext = false; if (Context.isExecutionContextActive()) { ExecutionContext executionContext = Context.getExecutionContext(); if (executionContext != null) { extractedFromContext = true;