/** * Unregister a Process. */ public void unregisterProcess(Process proc) { log.debug("unregisterProcess: " + proc); procs.remove(proc.getID()); }
public String toString() { return "RuntimeProcess[" + proc.getName() + ",status=" + proc.getProcessStatus() + "]"; } }
private JAXBProcess adaptProcess(Process proc) jaxbProc.setName(proc.getName()); for (Message msg : proc.getMessages()) for (Property prop : proc.getProperties()) for (Assignment ass : proc.getAssignments()) for (FlowObject flowObject : proc.getFlowObjects())
ObjectName procID = proc.getID(); String procName = proc.getName(); try log.debug("End execution thread [proc=" + procName + ",status=" + proc.getProcessStatus() + "]"); if (proc.getProcessStatus() == ProcessStatus.Active) procImpl.setProcessStatus(ProcessStatus.Completed);
private void startProcessPrepare(Process proc) { // Reset the process if already terminated ProcessImpl procImpl = (ProcessImpl)proc; if (isProcessTerminated(proc)) procImpl.resetProcess(); ProcessStatus procStatus = proc.getProcessStatus(); if (procStatus != ProcessStatus.Ready && procStatus != ProcessStatus.Active) throw new IllegalStateException("Cannot start process in state: " + procStatus); // Register the process if needed ProcessManager pm = ProcessManager.locateProcessManager(); if (pm.getProcessByID(proc.getID()) == null) pm.registerProcess(proc); }
private boolean isProcessTerminated(Process proc) { ProcessStatus status = proc.getProcessStatus(); return status == ProcessStatus.Cancelled || status == ProcessStatus.Completed || status == ProcessStatus.Aborted; }
DelegatingExecutionContext(FlowObject flowObject, ExecutionContext delegate) { this.flowObject = flowObject; this.delegate = delegate; proc = flowObject.getProcess(); procPrefix = proc.getName() + "."; activityPrefix = procPrefix + flowObject.getName() + "."; }
private StartEvent getNoneStartEvent(Process proc) { StartEvent start = null; for (StartEvent aux : proc.getFlowObjects(StartEvent.class)) { if (aux.getTrigger().size() == 0) { if (start != null) throw new InvalidProcessException("Process cannot have multiple start events with no trigger"); start = aux; } } return start; }
public Collection<Key> getAttachmentKeys() { Collection<Key> keys = new ArrayList<Key>(delegate.getAttachmentKeys()); // Add activity property keys if (flowObject instanceof Activity) { Activity activity = (Activity)flowObject; for (Property prop : activity.getProperties()) { Key key = new Key(null, activityPrefix + prop.getName()); keys.add(key); } } // Add process property keys for (Property prop : proc.getProperties()) { Key key = new Key(null, procPrefix + prop.getName()); keys.add(key); } return keys; }
private void startTimeAssignments(Process proc, Token token) { DelegatingToken delegatingToken = new DelegatingToken((MutableToken)token); ExecutionContext exContext = token.getExecutionContext(); for (Assignment ass : proc.getAssignments()) { if (ass.getAssignTime() == AssignTime.Start) { Expression expr = ass.getFrom(); ExpressionEvaluator exprEvaluator = new ExpressionEvaluator(expr); Object result = exprEvaluator.evaluateExpression(delegatingToken); String propName = ass.getTo().getName(); exContext.addAttachment(propName, result); } } }
Property prop = proc.getProperty(key); if (prop != null)
private void initFlow(Process proc, SequenceFlowImpl flow) { if (flow != null) { String name = flow.getTargetName(); FlowObject target = proc.getFlowObject(name); if (target == null) throw new InvalidProcessException("Cannot find target for out flow: " + name); if (target instanceof SingleInFlowSetterSupport) { SingleInFlowSetterSupport sif = (SingleInFlowSetterSupport)target; sif.setInFlow(flow); } else if (target instanceof MultipleInFlowSetterSupport) { MultipleInFlowSetterSupport mif = (MultipleInFlowSetterSupport)target; mif.addInFlow(flow); } else { throw new InvalidProcessException("Target does not support in flow: " + target); } flow.setSourceRef(this); flow.setTargetRef(target); } } }
ProcessStatus status = proc.getProcessStatus(); if (status == ProcessStatus.None) throw new IllegalStateException("Cannot wait for process in state: " + status); RuntimeException rte = new ProcessTimeoutException("Process timeout after " + timeout + "ms for: " + proc.getID()); procImpl.setRuntimeException(rte); log.error(rte); if (procManager.getProcessByID(proc.getID()) != null) procManager.unregisterProcess(proc); status = proc.getProcessStatus(); return status;
@Override public ProcessStatus waitForEnd(Process proc) { return proc.getProcessStatus(); }
for (FlowObject aux : proc.getFlowObjects())
/** * Find the set of Processes for a given name * * @param name The process name * @param status The optional process status * @return An empty set if the process cannot be found */ public Set<Process> getProcesses(String name, Process.ProcessStatus status) { Set<Process> procSet = new HashSet<Process>(); for (Process aux : procs.values()) { if (aux.getName().equals(name)) { if (status == null || aux.getProcessStatus() == status) procSet.add(aux); } } return procSet; }
public void catchSignal(Signal signal) { log.debug("catchSignal: " + signal); ProcessStatus procStatus = proc.getProcessStatus(); if (procStatus == ProcessStatus.Ready || procStatus == ProcessStatus.Active) { log.debug("Start process from signal: " + signal); ExecutionManager exManager = ExecutionManager.locateExecutionManager(); exManager.startProcess(start, null); } else { log.debug("Ignore start signal for process: " + proc); } }
private RuntimeProcess getRuntimeProcess(Process proc, boolean createNew) { RuntimeProcess rtProcess; synchronized (runtimeProcesses) { rtProcess = runtimeProcesses.get(proc.getID()); if (rtProcess == null && createNew) { rtProcess = new RuntimeProcessImpl(proc); runtimeProcesses.put(proc.getID(), rtProcess); } } return rtProcess; }
public void start(Token token) { synchronized (runnableTokens) { ProcessStatus procStatus = getProcess(token).getProcessStatus(); if (procStatus != ProcessStatus.Ready && procStatus != ProcessStatus.Active) throw new IllegalStateException("Cannot start token to process in state: " + procStatus); log.debug("Sart Token: " + token); MutableToken mutableToken = (MutableToken)token; mutableToken.setTokenStatus(TokenStatus.Started); RunnableToken rtToken = runnableTokens.get(token.getTokenID()); executor.submit(rtToken); } }
public MessageSender(FlowObject fromFlowObject, Message messageRef) { ObjectName procID = fromFlowObject.getProcess().getID(); this.fromRef = new EntityImpl(procID); this.messageRef = messageRef; if (messageRef == null) throw new IllegalArgumentException("MessageRef cannot be null"); if (fromRef == null) throw new IllegalArgumentException("FromRef cannot be null"); }