Package org.jbpm.context.exe

Examples of org.jbpm.context.exe.ContextInstance


    {
        final boolean isDebugEnabled = logger.isDebugEnabled() ;
        final long tokenId = token.getId() ;
        final ProcessInstance processInstance = token.getProcessInstance() ;
        final long processInstanceId = processInstance.getId() ;
        final ContextInstance contextInstance = processInstance.getContextInstance() ;
       
        if (isDebugEnabled)
        {
            logger.debug("Locking token id " + tokenId + " from process instance " + processInstanceId) ;
        }
View Full Code Here


            }
        }
        JBpmObjectMapper mapper = new JBpmObjectMapper();
        Message message = mapper.mapFromJBpmToEsbMessage(bpmToEsbVars, globalProcessScope, executionContext);
       
        final ContextInstance contextInstance = executionContext.getContextInstance();
       
        if (isReplyToOrFaultToSet(contextInstance))
        {
            setRelatesToMessageId(contextInstance, message);
        }
       
        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

            {
                logger.debug("Signaling task " + tokenId + " from process instance " +
                    token.getProcessInstance().getId()) ;
            }
            final ProcessInstance processInstance = token.getProcessInstance() ;
            final ContextInstance contextInstance = processInstance.getContextInstance() ;
            final JbpmContext jbpmContext = executionContext.getJbpmContext() ;
            final String transitionName = (String)removeVariableLocally(jbpmContext, contextInstance, ESB_ASYNC_SIGNAL_TRANSITION_VARIABLE_NAME, token) ;
            final String actor = (String)removeVariableLocally(jbpmContext, contextInstance, ESB_ASYNC_SIGNAL_ACTOR_VARIABLE_NAME, token) ;
            final String origActor = jbpmContext.getActorId() ;
           
            final int variableCount = Integer.parseInt((String)removeVariableLocally(jbpmContext, contextInstance, ESB_ASYNC_SIGNAL_VARIABLE_COUNT, token)) ;
            for(int count = 0 ; count < variableCount ; count++)
            {
                final String name = (String)removeVariableLocally(jbpmContext, contextInstance, ESB_ASYNC_SIGNAL_VARIABLE_NAMES + count, token) ;
                final Object value = removeVariableLocally(jbpmContext, contextInstance, name, token) ;
                contextInstance.setVariable(name, value) ;
            }
           
            try
            {
                if (actor != null)
View Full Code Here

     * Wait for a notification from the test.
     */
    public void execute(final ExecutionContext executionContext)
        throws Exception
    {
        final ContextInstance contextInstance = executionContext.getContextInstance() ;
        final Token token = executionContext.getToken() ;
        final Object value = contextInstance.getVariable("theBody", token) ;
       
        getRedeliveryMBean().logMessage(String.valueOf(value)) ;
    }
View Full Code Here

        List<DeployPackageStep> unexecutedSteps = translateSteps(packageDetails);

        // Load the JBPM process into the executor
        ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(process);
        ProcessInstance processInstance = new ProcessInstance(processDefinition);
        ContextInstance context = processInstance.getContextInstance();

        // Populate the variables we'll need in the handlers
        context.setVariable(ContextVariables.CONTENT_CONTEXT, contentContext);
        context.setVariable(ContextVariables.CONTROL_ACTION_FACADE, controlFacade);
        context.setVariable(ContextVariables.PACKAGE_DETAILS_KEY, packageDetails.getKey());

        SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmssSSS");
        Date timestamp = new Date();
        String formattedTimestamp = format.format(timestamp);
        context.setVariable(ContextVariables.TIMESTAMP, formattedTimestamp);

        try {
            File downloadDir = createTempDir("jon_download");
            if (downloadDir != null) {
                context.setVariable(ContextVariables.DOWNLOAD_DIR, downloadDir.getAbsolutePath());
            }

            File patchDir = createTempDir("jon_patch");
            if (patchDir != null) {
                context.setVariable(ContextVariables.PATCH_DIR, patchDir.getAbsolutePath());
            }
        } catch (IOException e) {
            // No need to throw this error, a handler will check for these to be valid and fail the step accordingly
            log.error("Error creating temporary directories", e);
        }

        // Populate the variables describing the AS instance
        String jbossHomeDir = jbossPaths.getHomeDir();
        log.debug("jbossHomeDir: " + (jbossHomeDir == null ? " is NULL" : jbossHomeDir));
        jbossHomeDir += File.separator; // Just to make sure it ends with the separator
        context.setVariable(ContextVariables.JBOSS_HOME_DIR, jbossHomeDir);

        String jbossClientDir = jbossHomeDir + File.separator + "client" + File.separator;
        log.debug("jbossClientDir: " + jbossClientDir);
        context.setVariable(ContextVariables.JBOSS_CLIENT_DIR, jbossClientDir);

        String jbossServerDir = jbossPaths.getServerDir();
        log.debug("jbossServerDir: " + (jbossServerDir == null ? " is NULL" : jbossServerDir));
        jbossServerDir += File.separator; // Just to make sure
        context.setVariable(ContextVariables.JBOSS_SERVER_DIR, jbossServerDir);

        // The workflow will reference values inside of this object for substitution
        // Ultimately, we should parse out the workflows to use the domain object directly
        SoftwareValue softwareValue = resourcePackageDetailsToSoftwareValue(packageDetails);
        context.setVariable(ContextVariables.SOFTWARE, softwareValue);

        // Perform the workflow
        try {
            processInstance.signal();
        } catch (Exception e) {
View Full Code Here

     * Indicates if the process succeeded or failed.
     */
    private Boolean status;

    public void execute(ExecutionContext executionContext) {
        ContextInstance instance = executionContext.getContextInstance();
        if (instance != null) {
            instance.setVariable("processStatus", status);
        }
    }
View Full Code Here

      if ( removals.contains(name) ) return null;
     
      org.jbpm.taskmgmt.exe.TaskInstance taskInstance = getTaskInstance();
      if (taskInstance==null)
      {
         ContextInstance context = getContextInstance();
         return context==null ? null : context.getVariable(name);
      }
      else
      {
         return taskInstance.getVariable(name);
      }
View Full Code Here

       //      after the Seam-managed txn was committed, but
       //      this implementation requires a hit to the database!
       HashSet<String> results = new HashSet<String>();
       org.jbpm.taskmgmt.exe.TaskInstance taskInstance = getTaskInstance();
       if (taskInstance==null) {
           ContextInstance context = getContextInstance();
           if (context!=null) {
               Map variables = context.getVariables();
               if (variables != null) {
                   results.addAll(variables.keySet());
               }
           }
       } else {
View Full Code Here

   private void flushToProcessInstance(org.jbpm.graph.exe.ProcessInstance processInstance)
   {
      log.debug( "flushing to process instance: " + processInstance.getId() );
 
      ContextInstance contextInstance = processInstance.getContextInstance();
 
      for ( Map.Entry<String, Object> entry: additions.entrySet() )
      {
         contextInstance.setVariable( entry.getKey(), entry.getValue() );
      }
 
      for ( String name: removals )
      {
         contextInstance.deleteVariable(name);
      }
   }
View Full Code Here

    fireEvent(Event.EVENTTYPE_SUBPROCESS_CREATED, executionContext);

    // feed the readable variableInstances
    if ((variableAccesses != null) && (!variableAccesses.isEmpty())) {

      ContextInstance superContextInstance = executionContext.getContextInstance();
      ContextInstance subContextInstance = subProcessInstance.getContextInstance();
      subContextInstance.setTransientVariables(superContextInstance.getTransientVariables());

      // loop over all the variable accesses
      Iterator iter = variableAccesses.iterator();
      while (iter.hasNext()) {
        VariableAccess variableAccess = (VariableAccess) iter.next();
        // if this variable access is readable
        if (variableAccess.isReadable()) {
          // the variable is copied from the super process variable name
          // to the sub process mapped name
          String variableName = variableAccess.getVariableName();
          Object value = superContextInstance.getVariable(variableName, superProcessToken);
          String mappedName = variableAccess.getMappedName();
          log.debug("copying super process var '"+variableName+"' to sub process var '"+mappedName+"': "+value);
          if (value!=null) {
            subContextInstance.setVariable(mappedName, value);
          }
        }
      }
    }
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.