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; } });
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); } }
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; }
@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!"); } };
private String getExecutionId() { return Context.getExecutionContext().getExecution().getId(); }
protected BusinessProcessEvent createEvent(DelegateTask task) { ExecutionContext executionContext = Context.getExecutionContext(); ProcessDefinitionEntity processDefinition = null; if (executionContext != null) { processDefinition = executionContext.getProcessDefinition(); } // map type String eventName = task.getEventName(); BusinessProcessEventType type = null; if (TaskListener.EVENTNAME_CREATE.equals(eventName)) { type = BusinessProcessEventType.CREATE_TASK; } else if (TaskListener.EVENTNAME_ASSIGNMENT.equals(eventName)) { type = BusinessProcessEventType.ASSIGN_TASK; } else if (TaskListener.EVENTNAME_COMPLETE.equals(eventName)) { type = BusinessProcessEventType.COMPLETE_TASK; } else if (TaskListener.EVENTNAME_DELETE.equals(eventName)) { type = BusinessProcessEventType.DELETE_TASK; } return new CdiBusinessProcessEvent(task, processDefinition, type, ClockUtil.getCurrentTime()); }
protected BusinessProcessEvent createEvent(DelegateExecution execution) { ProcessDefinition processDefinition = Context.getExecutionContext().getProcessDefinition(); // map type String eventName = execution.getEventName(); BusinessProcessEventType type = null; if(ExecutionListener.EVENTNAME_START.equals(eventName)) { type = BusinessProcessEventType.START_ACTIVITY; } else if(ExecutionListener.EVENTNAME_END.equals(eventName)) { type = BusinessProcessEventType.END_ACTIVITY; } else if(ExecutionListener.EVENTNAME_TAKE.equals(eventName)) { type = BusinessProcessEventType.TAKE; } return new CdiBusinessProcessEvent(execution.getCurrentActivityId(), execution.getCurrentTransitionId(), processDefinition, execution, type, ClockUtil.getCurrentTime()); }
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! " + StringUtil.getStackTrace(th)); } finally { if (executionEntity != null) { logger.fine("set variable '" + name + "' on executionEntity# " + executionEntity.getId()); } } return null; }
protected BusinessProcessEvent createEvent(DelegateTask task) { ExecutionContext executionContext = Context.getExecutionContext(); ProcessDefinitionEntity processDefinition = null; if (executionContext != null) { processDefinition = executionContext.getProcessDefinition(); } // map type String eventName = task.getEventName(); BusinessProcessEventType type = null; if (TaskListener.EVENTNAME_CREATE.equals(eventName)) { type = BusinessProcessEventType.CREATE_TASK; } else if (TaskListener.EVENTNAME_ASSIGNMENT.equals(eventName)) { type = BusinessProcessEventType.ASSIGN_TASK; } else if (TaskListener.EVENTNAME_COMPLETE.equals(eventName)) { type = BusinessProcessEventType.COMPLETE_TASK; } else if (TaskListener.EVENTNAME_DELETE.equals(eventName)) { type = BusinessProcessEventType.DELETE_TASK; } return new CdiBusinessProcessEvent(task, processDefinition, type, ClockUtil.getCurrentTime()); }
protected BusinessProcessEvent createEvent(DelegateExecution execution) { ProcessDefinition processDefinition = Context.getExecutionContext().getProcessDefinition(); // map type String eventName = execution.getEventName(); BusinessProcessEventType type = null; if(ExecutionListener.EVENTNAME_START.equals(eventName)) { type = BusinessProcessEventType.START_ACTIVITY; } else if(ExecutionListener.EVENTNAME_END.equals(eventName)) { type = BusinessProcessEventType.END_ACTIVITY; } else if(ExecutionListener.EVENTNAME_TAKE.equals(eventName)) { type = BusinessProcessEventType.TAKE; } return new CdiBusinessProcessEvent(execution.getCurrentActivityId(), execution.getCurrentTransitionId(), processDefinition, execution, type, ClockUtil.getCurrentTime()); }