protected void checkLock() { if (!STATE_ACTIVE.equals(state)) { throw new PvmException(toString()+" is not active: "+state); } }
public ClientProcessInstance createSubProcessInstance(ClientProcessDefinition processDefinition, String key) { if (subProcessInstance!=null) { throw new PvmException(toString()+" already has a sub process instance: "+subProcessInstance); } subProcessInstance = (ExecutionImpl) processDefinition.createProcessInstance(key); subProcessInstance.setSuperProcessExecution(this); return subProcessInstance; }
/** @see Execution#resume() */ public void resume() { if (! isSuspended()) { throw new PvmException(toString()+" is not suspended"); } unlock(); }
/** @see Execution#suspend() */ public void suspend() { if (isSuspended()) { throw new PvmException(toString()+" is suspended"); } lock(STATE_SUSPENDED); }
/** @see Execution#take(String) */ public void take(String transitionName) { if (node==null) { throw new PvmException(toString()+" is not positioned in node"); } TransitionImpl transition = findTransition(transitionName); if (transition==null) { throw new PvmException("there is no transition "+transitionName+" in "+node); } take(transition); }
public void begin() { if (state!=STATE_CREATED) { throw new PvmException(toString()+" is already begun: "+state); } ExecutionImpl scopedExecution = initializeScopes(); this.state = STATE_ACTIVE; fire(Event.PROCESS_BEGIN, processDefinition); if (node!=null) { scopedExecution.performAtomicOperation(EXECUTE_NODE); } }
protected void destroyTimers(CompositeElementImpl scope) { log.debug("destroying timers of "+toString()); if (hasTimers && timers!=null && !timers.isEmpty()) { // get the TimerSession from the environment Environment environment = Environment.getCurrent(); if (environment==null) { throw new PvmException("non environment for initializing timers"); } TimerSession timerSession = environment.get(TimerSession.class); if (timerSession==null) { throw new PvmException("no TimerSession in environment for initializing timers"); } for (Timer timer : timers) { timerSession.cancel(timer); } timers.clear(); hasTimers = false; } }
public void perform(ExecutionImpl execution) { NodeImpl node = execution.getNode(); if (log.isTraceEnabled()) { if (execution.getName()!=null) { log.trace(execution.toString()+" executes "+node); } else { log.trace("executing "+node); } } Activity activity = node.getBehaviour(); try { execution.setPropagation(Propagation.UNSPECIFIED); activity.execute(execution); } catch (Exception e) { execution.handleException(node, null, null, e, execution.toString()+" couldn't execute "+activity+" for node "+node); } if (execution.getPropagation()==Propagation.UNSPECIFIED) { execution.proceed(); } }
public void perform(ExecutionImpl execution) { if (execution.getName()!=null) { log.debug(execution.toString()+" signals "+node); } else { log.debug("signalling "+node+", signal="+signalName); } ExternalActivity externalActivity = (ExternalActivity) node.getBehaviour(); try { execution.setPropagation(Propagation.UNSPECIFIED); externalActivity.signal(execution, signalName, parameters); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new PvmException("couldn't signal "+node+": "+e.getMessage(), e); } if (execution.getPropagation() == Propagation.UNSPECIFIED) { execution.proceed(); } }
public void perform(ExecutionImpl execution) { TransitionImpl transition = execution.getTransition(); if (execution.getName()!=null) { log.debug(execution.toString()+" takes "+transition); } else { log.debug("taking "+transition); } List<NodeImpl> leftNodes = getNodesLeft(execution.getNode(), transition.getDestination()); ExecutionImpl propagatingExecution = execution; for (NodeImpl leftNode : leftNodes) { propagatingExecution = propagatingExecution.endNode(leftNode); } propagatingExecution.setNode(null); propagatingExecution.fire(Event.TRANSITION_TAKE, transition); boolean wait = false; Condition waitCondition = transition.getWaitCondition(); if (waitCondition!=null) { wait = waitCondition.evaluate(propagatingExecution); } if (!wait) { propagatingExecution.performAtomicOperation(ExecutionImpl.PROCEED_TO_DESTINATION); } }
log.debug("creating timer on "+this.toString());