Package org.jbpm

Examples of org.jbpm.JbpmContext


  public void processInstanceIsCreatedWhenUserSubmitsWebappForm() {
    // The code in this method could be inside a struts-action
    // or a JSF managed bean.

    // Lookup the pojo persistence context-builder that is configured above
    JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
    try {

      GraphSession graphSession = jbpmContext.getGraphSession();
     
      ProcessDefinition processDefinition =
          graphSession.findLatestProcessDefinition("hello world");
   
      // With the processDefinition that we retrieved from the database, we
      // can create an execution of the process definition just like in the
      // hello world example (which was without persistence).
      ProcessInstance processInstance =
          new ProcessInstance(processDefinition);
     
      Token token = processInstance.getRootToken();
      assertEquals("start", token.getNode().getName());
      // Let's start the process execution
      token.signal();
      // Now the process is in the state 's'.
      assertEquals("s", token.getNode().getName());
     
      // Now the processInstance is saved in the database.  So the
      // current state of the execution of the process is stored in the
      // database. 
      jbpmContext.save(processInstance);
      // The method below will get the process instance back out
      // of the database and resume execution by providing another
      // external signal.

    } finally {
      // Tear down the pojo persistence context.
      jbpmContext.close();
    }
  }
View Full Code Here


      if (userPrincipal != null) {
        actorId = userPrincipal.getName();
      }
    }

    JbpmContext jbpmContext = getJbpmConfiguration().createJbpmContext(jbpmContextName);
    try {
      if (isAuthenticationEnabled) {
        jbpmContext.setActorId(actorId);
      }
      filterChain.doFilter(servletRequest, servletResponse);
    } finally {
      jbpmContext.close();
    }
  }
View Full Code Here

  public void theProcessInstanceContinuesWhenAnAsyncMessageIsReceived() {
    // The code in this method could be the content of a message driven bean.
   
    // Lookup the pojo persistence context-builder that is configured above
    JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
    try {

      GraphSession graphSession = jbpmContext.getGraphSession();
      // First, we need to get the process instance back out of the database.
      // There are several options to know what process instance we are dealing
      // with here.  The easiest in this simple test case is just to look for
      // the full list of process instances.  That should give us only one
      // result.  So let's look up the process definition.
     
      ProcessDefinition processDefinition =
          graphSession.findLatestProcessDefinition("hello world");

      // Now, we search for all process instances of this process definition.
      List processInstances =
          graphSession.findProcessInstances(processDefinition.getId());
     
      // Because we know that in the context of this unit test, there is
      // only one execution.  In real life, the processInstanceId can be
      // extracted from the content of the message that arrived or from
      // the user making a choice.
      ProcessInstance processInstance =
          (ProcessInstance) processInstances.get(0);
     
      // Now we can continue the execution.  Note that the processInstance
      // delegates signals to the main path of execution (=the root token).
      processInstance.signal();

      // After this signal, we know the process execution should have
      // arrived in the end-state.
      assertTrue(processInstance.hasEnded());
     
      // Now we can update the state of the execution in the database
      jbpmContext.save(processInstance);

    } finally {
      // Tear down the pojo persistence context.
      jbpmContext.close();
    }
  }
View Full Code Here

    }
  }

  void deploy(File file, JbpmConfiguration jbpmConfiguration) throws IOException, FileNotFoundException {
   
    JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
    try {
      ZipInputStream zipInputStream = new ZipInputStream(new FileInputStream(file));
      ProcessDefinition processDefinition = ProcessDefinition.parseParZipInputStream(zipInputStream);
      jbpmContext.deployProcessDefinition(processDefinition);
     
    } finally {
      jbpmContext.close();
    }
  }
View Full Code Here

   * helper method to look up the authenticated actorId in the current
   * jbpm context.
   */
  public static String getAuthenticatedActorId() {
    String actorId = null;
    JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
    if (jbpmContext!=null) {
      AuthenticationService authenticationService = jbpmContext.getServices().getAuthenticationService();
      if (authenticationService!=null) {
        actorId = authenticationService.getActorId();
      }
    }
    return actorId;
View Full Code Here

 
  /**
   * helper method to check the permissions of a jbpm secured operation.
   */
  public static void checkPermission(Permission permission) {
    JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
    if (jbpmContext!=null) {
      AuthorizationService authorizationService = jbpmContext.getServices().getAuthorizationService();
      if (authorizationService!=null) {
        authorizationService.checkPermission(permission);
      }
    }
  }
View Full Code Here

  private static final long serialVersionUID = 1L;
 
  Session session = null;
 
  public DbLoggingService() {
    JbpmContext currentJbpmContext = JbpmContext.getCurrentJbpmContext();
    if (currentJbpmContext==null) {
      throw new JbpmException("instantiation of the DbLoggingService requires a current JbpmContext");
    }
    session = currentJbpmContext.getSession();
  }
View Full Code Here

    FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("processInstanceBean", processInstanceBean);
    return ("inspectInstance");
  }

  public String deleteProcessInstance() {
    JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
    GraphSession graphSession = jbpmContext.getGraphSession();
    graphSession.deleteProcessInstance(this.id);
    return ("deleteInstance");
  }
View Full Code Here

    graphSession.deleteProcessInstance(this.id);
    return ("deleteInstance");
  }

  private void initialize() {
    JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
    GraphSession graphSession = jbpmContext.getGraphSession();
    ProcessInstance processInstance = graphSession.loadProcessInstance(this.id);
    this.start = processInstance.getStart();
    this.end = processInstance.getEnd();
    this.processDefinitionId = processInstance.getProcessDefinition().getId();
    this.processDefinitionLabel = processInstance.getProcessDefinition().getName() + " (version " + processInstance.getProcessDefinition().getVersion() + ")";
View Full Code Here

  }

  public String updateVariable() {

    if (this.variableName != null) {
      JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
      GraphSession graphSession = jbpmContext.getGraphSession();
      ProcessInstance processInstance = graphSession.loadProcessInstance(this.id);
      if (this.variableValue != null) {
        processInstance.getContextInstance().setVariable(this.variableName, this.variableValue);
      } else {
        processInstance.getContextInstance().deleteVariable(this.variableName);
View Full Code Here

TOP

Related Classes of org.jbpm.JbpmContext

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.