public void removeNodeInstance(final NodeInstance nodeInstance) { if (((NodeInstanceImpl) nodeInstance).isInversionOfControl()) { getKnowledgeRuntime().delete( getKnowledgeRuntime().getFactHandle(nodeInstance)); } this.nodeInstances.remove(nodeInstance); }
protected boolean useTimerSLATracking() { String mode = (String) getKnowledgeRuntime().getEnvironment().get("SLATimerMode"); if (mode == null) { return true; } return Boolean.parseBoolean(mode); }
public void removeEventListener(String type, EventListener listener, boolean external) { Map<String, List<EventListener>> eventListeners = external ? this.externalEventListeners : this.eventListeners; List<EventListener> listeners = eventListeners.get(type); if (listeners != null) { listeners.remove(listener); if (listeners.isEmpty()) { eventListeners.remove(type); if (external) { ((InternalProcessRuntime) getKnowledgeRuntime().getProcessRuntime()) .getSignalManager().removeEventListener(type, this); } } } else { eventListeners.remove(type); } }
public void addEventListener(String type, EventListener listener, boolean external) { Map<String, List<EventListener>> eventListeners = external ? this.externalEventListeners : this.eventListeners; List<EventListener> listeners = eventListeners.get(type); if (listeners == null) { listeners = new CopyOnWriteArrayList<EventListener>(); eventListeners.put(type, listeners); if (external) { ((InternalProcessRuntime) getKnowledgeRuntime().getProcessRuntime()) .getSignalManager().addEventListener(type, this); } } listeners.add(listener); }
protected boolean useAsync(final Node node) { if (!(node instanceof EventSubProcessNode) && (node instanceof ActionNode || node instanceof StateBasedNode || node instanceof EndNode)) { boolean asyncMode = Boolean.parseBoolean((String)node.getMetaData().get("customAsync")); if (asyncMode) { return asyncMode; } return Boolean.parseBoolean((String)getKnowledgeRuntime().getEnvironment().get("AsyncMode")); } return false; }
private void removeEventListeners() { for (String type : externalEventListeners.keySet()) { ((InternalProcessRuntime) getKnowledgeRuntime().getProcessRuntime()) .getSignalManager().removeEventListener(type, this); } }
public NodeInstance getNodeInstance(final Node node) { Node actualNode = node; // async continuation handling if (node instanceof AsyncEventNode) { actualNode = ((AsyncEventNode) node).getActualNode(); } else if (useAsync(node)) { actualNode = new AsyncEventNode(node); } NodeInstanceFactory conf = NodeInstanceFactoryRegistry.getInstance(getKnowledgeRuntime().getEnvironment()).getProcessNodeInstanceFactory(actualNode); if (conf == null) { throw new IllegalArgumentException("Illegal node type: " + node.getClass()); } NodeInstanceImpl nodeInstance = (NodeInstanceImpl) conf.getNodeInstance(actualNode, this, this); if (nodeInstance == null) { throw new IllegalArgumentException("Illegal node type: " + node.getClass()); } if (((NodeInstanceImpl) nodeInstance).isInversionOfControl()) { getKnowledgeRuntime().insert(nodeInstance); } return nodeInstance; }
public Map<String, Object> getVariables() { // for disconnected process instances, try going through the variable scope instances // (as the default variable scope cannot be retrieved as the link to the process could // be null and the associated working memory is no longer accessible) if (getKnowledgeRuntime() == null) { List<ContextInstance> variableScopeInstances = getContextInstances(VariableScope.VARIABLE_SCOPE); if (variableScopeInstances == null) { return null; } Map<String, Object> result = new HashMap<String, Object>(); for (ContextInstance contextInstance: variableScopeInstances) { Map<String, Object> variables = ((VariableScopeInstance) contextInstance).getVariables(); result.putAll(variables); } return result; } // else retrieve the variable scope VariableScopeInstance variableScopeInstance = (VariableScopeInstance) getContextInstance(VariableScope.VARIABLE_SCOPE); if (variableScopeInstance == null) { return null; } return variableScopeInstance.getVariables(); }
private void validate() { InternalRuntimeManager manager = (InternalRuntimeManager) getKnowledgeRuntime().getEnvironment().get("RuntimeManager"); if (manager != null) { // check if process instance is owned by the same manager as the one owning ksession if (hasDeploymentId() && !manager.getIdentifier().equals(getDeploymentId())) { throw new IllegalStateException("Process instance " + getId() + " is owned by another deployment " + getDeploymentId() + " != " + manager.getIdentifier()); } } }
private void handleSLAViolation() { if (slaCompliance == SLA_PENDING) { InternalKnowledgeRuntime kruntime = getKnowledgeRuntime(); InternalProcessRuntime processRuntime = (InternalProcessRuntime) kruntime.getProcessRuntime(); processRuntime.getProcessEventSupport().fireBeforeSLAViolated(this, kruntime); logger.debug("SLA violated on process instance {}", getId()); this.slaCompliance = SLA_VIOLATED; this.slaTimerId = -1; processRuntime.getProcessEventSupport().fireAfterSLAViolated(this, kruntime); } }
public Object getVariable(String name) { // for disconnected process instances, try going through the variable scope instances // (as the default variable scope cannot be retrieved as the link to the process could // be null and the associated working memory is no longer accessible) if (getKnowledgeRuntime() == null) { List<ContextInstance> variableScopeInstances = getContextInstances(VariableScope.VARIABLE_SCOPE); if (variableScopeInstances != null && variableScopeInstances.size() == 1) { for (ContextInstance contextInstance: variableScopeInstances) { Object value = ((VariableScopeInstance) contextInstance).getVariable(name); if (value != null) { return value; } } } return null; } // else retrieve the variable scope VariableScopeInstance variableScopeInstance = (VariableScopeInstance) getContextInstance(VariableScope.VARIABLE_SCOPE); if (variableScopeInstance == null) { return null; } return variableScopeInstance.getVariable(name); }
CaseData caseFile = internalGetCaseFile(((WorkflowProcessInstanceImpl)source).getKnowledgeRuntime()); if (caseFile != null) {
when(processInstance.getState()).thenReturn(1); when(processInstance.getVariables()).thenReturn(variables); when(processInstance.getKnowledgeRuntime()).thenReturn(kruntime);
public TimerInstance configureSLATimer(String slaDueDateExpression) { // setup SLA if provided slaDueDateExpression = resolveVariable(slaDueDateExpression); if (slaDueDateExpression == null || slaDueDateExpression.trim().isEmpty()) { logger.debug("Sla due date expression resolved to no value '{}'", slaDueDateExpression); return null; } logger.debug("SLA due date is set to {}", slaDueDateExpression); InternalKnowledgeRuntime kruntime = getKnowledgeRuntime(); long duration = -1; if (kruntime != null && kruntime.getEnvironment().get("jbpm.business.calendar") != null){ BusinessCalendar businessCalendar = (BusinessCalendar) kruntime.getEnvironment().get("jbpm.business.calendar"); duration = businessCalendar.calculateBusinessTimeAsDuration(slaDueDateExpression); } else { duration = DateTimeUtils.parseDuration(slaDueDateExpression); } TimerInstance timerInstance = new TimerInstance(); timerInstance.setId(-1); timerInstance.setDelay(duration); timerInstance.setPeriod(0); if (useTimerSLATracking()) { ((InternalProcessRuntime)kruntime.getProcessRuntime()).getTimerManager().registerTimer(timerInstance, this); } return timerInstance; }
InternalKnowledgeRuntime kruntime = getKnowledgeRuntime(); InternalProcessRuntime processRuntime = (InternalProcessRuntime) kruntime.getProcessRuntime(); processRuntime.getProcessEventSupport().fireBeforeProcessCompleted(this, kruntime);
public void removeNodeInstance(final NodeInstance nodeInstance) { if (((NodeInstanceImpl) nodeInstance).isInversionOfControl()) { getKnowledgeRuntime().delete( getKnowledgeRuntime().getFactHandle(nodeInstance)); } this.nodeInstances.remove(nodeInstance); }
protected boolean useTimerSLATracking() { String mode = (String) getKnowledgeRuntime().getEnvironment().get("SLATimerMode"); if (mode == null) { return true; } return Boolean.parseBoolean(mode); }
public void addEventListener(String type, EventListener listener, boolean external) { Map<String, List<EventListener>> eventListeners = external ? this.externalEventListeners : this.eventListeners; List<EventListener> listeners = eventListeners.get(type); if (listeners == null) { listeners = new CopyOnWriteArrayList<EventListener>(); eventListeners.put(type, listeners); if (external) { ((InternalProcessRuntime) getKnowledgeRuntime().getProcessRuntime()) .getSignalManager().addEventListener(type, this); } } listeners.add(listener); }
private void handleSLAViolation() { if (slaCompliance == SLA_PENDING) { InternalKnowledgeRuntime kruntime = getKnowledgeRuntime(); InternalProcessRuntime processRuntime = (InternalProcessRuntime) kruntime.getProcessRuntime(); processRuntime.getProcessEventSupport().fireBeforeSLAViolated(this, kruntime); logger.debug("SLA violated on process instance {}", getId()); this.slaCompliance = SLA_VIOLATED; this.slaTimerId = -1; processRuntime.getProcessEventSupport().fireAfterSLAViolated(this, kruntime); } }
private void validate() { InternalRuntimeManager manager = (InternalRuntimeManager) getKnowledgeRuntime().getEnvironment().get("RuntimeManager"); if (manager != null) { // check if process instance is owned by the same manager as the one owning ksession if (hasDeploymentId() && !manager.getIdentifier().equals(getDeploymentId())) { throw new IllegalStateException("Process instance " + getId() + " is owned by another deployment " + getDeploymentId() + " != " + manager.getIdentifier()); } } }