Package org.jbpm.context.exe

Examples of org.jbpm.context.exe.ContextInstance


  String msg;

  public void execute(ExecutionContext executionContext) throws Exception {
    TaskMgmtDefinition taskMgmtDefinition = executionContext.getProcessDefinition().getTaskMgmtDefinition();
    TaskMgmtInstance taskMgmtInstance = executionContext.getTaskMgmtInstance();
    ContextInstance contextInstance = executionContext.getContextInstance();
   
    Swimlane shipperSwimlane = taskMgmtDefinition.getSwimlane("shipper");
    SwimlaneInstance shipperSwimlaneInstance = taskMgmtInstance.getInitializedSwimlaneInstance(executionContext, shipperSwimlane);

    String actorId = shipperSwimlaneInstance.getActorId();
   
    String displayMsg = replace(msg, "${"+swimlaneName+"}", actorId);
    displayMsg = replace(displayMsg, "${item}", (String)contextInstance.getVariable("item"));
    displayMsg = replace(displayMsg, "${address}", (String)contextInstance.getVariable("address"));
   
    log.info("###############################################");
    log.info("### "+displayMsg);
    log.info("###############################################");
   
View Full Code Here


    );
    jbpmContext.deployProcessDefinition(superDefinition);
    newTransaction();
   
    ProcessInstance superInstance = jbpmContext.newProcessInstanceForUpdate("super");
    ContextInstance superContext = superInstance.getContextInstance();
    superContext.setVariable("a", "value a");
    superContext.setVariable("b", "value b");
    superInstance.signal();
   
    commitAndCloseSession();
    try {
      SchedulerThread schedulerThread = new SchedulerThread(jbpmConfiguration);
      schedulerThread.executeTimers();
    } finally {
      beginSessionTransaction();
    }

    superInstance = jbpmContext.loadProcessInstance(superInstance.getId());
    assertEquals("async", superInstance.getRootToken().getNode().getName());
   
    commitAndCloseSession();
    try {
      CommandExecutorThread commandExecutorThread = new CommandExecutorThread(jbpmConfiguration);
      commandExecutorThread.executeCommand();
    } finally {
      beginSessionTransaction();
    }

    List taskInstances = taskMgmtSession.findTaskInstances("victim");
    assertEquals(1, taskInstances.size());
    TaskInstance taskInstance = (TaskInstance) taskInstances.get(0);
    taskInstance.setVariable("a", "value a updated");
    taskInstance.setVariable("b", "value b updated");
    taskInstance.end();
   
    jbpmContext.save(taskInstance);
    long taskInstanceId = taskInstance.getId();
    long tokenId = taskInstance.getToken().getId();
    newTransaction();
   
    taskInstance = jbpmContext.loadTaskInstance(taskInstanceId);
    assertEquals("value a updated", taskInstance.getVariable("a"));
    assertEquals("value b updated", taskInstance.getVariable("b"));
   
    Token token = jbpmContext.loadToken(tokenId);
    ContextInstance subContextInstance = token.getProcessInstance().getContextInstance();
    assertEquals("value a", subContextInstance.getVariable("a"));
    assertEquals("value b updated", subContextInstance.getVariable("b"));
  }
View Full Code Here

                && (executionContext.getTaskInstance().hasVariableLocally(name))
              ) {
      value = executionContext.getTaskInstance().getVariable(name);

    } else {
      ContextInstance contextInstance = executionContext.getContextInstance();
      Token token = executionContext.getToken();
      value = contextInstance.getVariable(name, token);
    }

    return value;
  }
View Full Code Here

    assertEquals("super", superProcessDefinition.getName());
  }
 
  public void testProcessInstanceModuleInstances() {
    ProcessInstance processInstance = new ProcessInstance();
    processInstance.addInstance(new ContextInstance());
    processInstance.addInstance(new TaskMgmtInstance());
  
    processInstance = saveAndReload(processInstance);

    assertNotNull(processInstance.getInstances());
View Full Code Here

  }
 
  public static class EnterNodeS implements ActionHandler {
    private static final long serialVersionUID = 1L;
    public void execute(ExecutionContext executionContext) throws Exception {
      ContextInstance contextInstance = executionContext.getContextInstance();
      Integer invocationCount = (Integer) contextInstance.getVariable("invocationCount");
      if (invocationCount==null) {
        contextInstance.setVariable("invocationCount", new Integer(1));
      } else {
        contextInstance.setVariable("invocationCount", new Integer(invocationCount.intValue()+1));
      }
    }
View Full Code Here

     * @param message
     */
    private void setAllOnEsbMessage(final boolean gblPrcScope, final ExecutionContext executionContext, Message message)
    {
        Token token = executionContext.getToken();
        ContextInstance ctxInstance = token.getProcessInstance().getContextInstance();
        log.debug("The user has not mapped anything (jbpmToEsbVars is null) " +
                  "so add all the variables using their jBPM name");
        Map map = (gblPrcScope) ? ctxInstance.getVariables() : ctxInstance.getVariables(token);
        if (null != map) {
            for (Iterator iter = map.entrySet().iterator(); iter.hasNext();){
                Map.Entry jBPMVariable = (Map.Entry) iter.next();
                message.getBody().add(jBPMVariable.getKey().toString(), jBPMVariable.getValue());
            }
View Full Code Here

        }
        if (mapping.getEsb()==null || "".equals(mapping.getEsb())) {
            mapping.setEsb(mapping.getBpm());
        }
        Token token = executionContext.getToken();
        ContextInstance ctxInstance = token.getProcessInstance().getContextInstance();
        //Each mapping can override the global setting
        boolean isPrcScope = (null == mapping.getIsProcessScope()) ? gblPrcScope : mapping.getIsProcessScope();
        //By default assume the object is part of the jBPM variableMap
        Object object = getObjectFromJBpmVariableMap(isPrcScope, mapping.getBpm(), ctxInstance, token);
        //if that fails then try to get it from the ExecutionContext
View Full Code Here

    {
        AssertArgument.isNotNull(executionContext, "executionContext");
        AssertArgument.isNotNull(esbMessage, "esbMessage");

        final Token token = executionContext.getToken();
        final ContextInstance ctxInstance = token.getProcessInstance().getContextInstance();
        final Map jbpmMap = (gblPrcScope) ? ctxInstance.getVariables() : ctxInstance.getVariables(token);

        if (jbpmMap == null)
        {
            return esbMessage;
        }
View Full Code Here

           
            if (token.isLocked()) {
                throw new CallbackException("Token id " + tokenId + " from process instance " + processInstanceId + " is already locked, another thread is active") ;
            }
           
            final ContextInstance contextInstance = instance.getContextInstance() ;
            final long currentProcessNodeVersion = Long.parseLong(String.valueOf(contextInstance.getVariableLocally(counterName, token)));
            if (isDebugEnabled) logger.debug("ProcessNodeVersion=" + currentProcessNodeVersion);
            if (processNodeVersion!=currentProcessNodeVersion) {
                throw new CallbackException("The current processNodeVersion (id=" + currentProcessNodeVersion + ") is not the expected version (version=" + processNodeVersion + ").");
            }
           
View Full Code Here

//          Set the replyTo to the JBpmCallback Service
            EPR faultTo = createFaultTo(esbToBpmVarsXml, globalProcessScope, executionContext);
            message.getHeader().getCall().setFaultTo(faultTo);
        }
       
        final ContextInstance contextInstance = executionContext.getContextInstance() ;
       
        if (isReplyToOrFaultToSet(contextInstance))
        {
            setRelatesToMessageId(contextInstance, message);
        }
       
        //Sending the message on its way
        if (logger.isDebugEnabled()) logger.debug("Created ESB message=" + message);
       
        if (replyToOriginator != null) {
            final EPR epr ;
            final Object replyToEPR = contextInstance.getVariable(Constants.REPLY_TO);
            final Object faultToEPR = contextInstance.getVariable(Constants.FAULT_TO);

            if (Constants.EPR_FAULT.equals(replyToOriginator) && (faultToEPR != null)) {
                epr = EPRHelper.fromXMLString(faultToEPR.toString()) ;
            } else if (replyToEPR != null) {
                epr = EPRHelper.fromXMLString(replyToEPR.toString()) ;
View Full Code Here

TOP

Related Classes of org.jbpm.context.exe.ContextInstance

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.