[jbpm-commits] JBoss JBPM SVN: r4501 - in jbpm4/branches/jbpm-4.0.0.Beta1/modules: userguide and 2 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Apr 8 10:06:45 EDT 2009


Author: heiko.braun at jboss.com
Date: 2009-04-08 10:06:45 -0400 (Wed, 08 Apr 2009)
New Revision: 4501

Added:
   jbpm4/branches/jbpm-4.0.0.Beta1/modules/userguide/src/main/docbook/en/modules/ch09-JBossIntegration.xml
   jbpm4/branches/jbpm-4.0.0.Beta1/modules/userguide/userguide.iml
Modified:
   jbpm4/branches/jbpm-4.0.0.Beta1/modules/integration/console/src/main/java/org/jbpm/integration/console/ProcessManagementImpl.java
   jbpm4/branches/jbpm-4.0.0.Beta1/modules/userguide/src/main/docbook/en/master.xml
Log:
svn merge -r4496:4500 https://svn.jboss.org/repos/jbpm/jbpm4/trunk

Modified: jbpm4/branches/jbpm-4.0.0.Beta1/modules/integration/console/src/main/java/org/jbpm/integration/console/ProcessManagementImpl.java
===================================================================
--- jbpm4/branches/jbpm-4.0.0.Beta1/modules/integration/console/src/main/java/org/jbpm/integration/console/ProcessManagementImpl.java	2009-04-08 13:30:13 UTC (rev 4500)
+++ jbpm4/branches/jbpm-4.0.0.Beta1/modules/integration/console/src/main/java/org/jbpm/integration/console/ProcessManagementImpl.java	2009-04-08 14:06:45 UTC (rev 4501)
@@ -34,6 +34,8 @@
 import org.jbpm.ProcessDefinition;
 import org.jbpm.ProcessDefinitionQuery;
 import org.jbpm.RepositoryService;
+import org.jbpm.env.Environment;
+import org.jbpm.env.EnvironmentFactory;
 import org.jbpm.model.OpenExecution;
 
 /**
@@ -41,127 +43,214 @@
  */
 class ProcessManagementImpl extends JBPMIntegration implements ProcessManagement
 {
-  
+
   public List<ProcessDefinitionRef> getProcessDefinitions()
   {
-    List<ProcessDefinitionRef> results = new ArrayList<ProcessDefinitionRef>();
+    Environment env = ((EnvironmentFactory)processEngine).openEnvironment();
 
-    RepositoryService repositoryService = this.processEngine.getRepositoryService();
-    List<ProcessDefinition> definitions = repositoryService.createProcessDefinitionQuery()
-      .orderAsc(ProcessDefinitionQuery.PROPERTY_NAME)
-      .execute();
-    
-    // adopt ProcessDefinition to console model
-    for(ProcessDefinition processDefinition : definitions)
+    try
     {
-      results.add( ModelAdaptor.adoptDefinition(processDefinition) );
+      List<ProcessDefinitionRef> results = new ArrayList<ProcessDefinitionRef>();
+
+      RepositoryService repositoryService = this.processEngine.getRepositoryService();
+      List<ProcessDefinition> definitions = repositoryService.createProcessDefinitionQuery()
+          .orderAsc(ProcessDefinitionQuery.PROPERTY_NAME)
+          .execute();
+
+      // adopt ProcessDefinition to console model
+      for(ProcessDefinition processDefinition : definitions)
+      {
+        results.add( ModelAdaptor.adoptDefinition(processDefinition) );
+      }
+
+      return results;
     }
+    finally
+    {
+      env.close();
+    }
 
-    return results;
-
   }
 
   public ProcessDefinitionRef getProcessDefinition(String procDefId)
   {
-    RepositoryService repositoryService = this.processEngine.getRepositoryService();
-    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
-        .id(procDefId)
-        .uniqueResult();
-    return ModelAdaptor.adoptDefinition(processDefinition);
+
+    Environment env = ((EnvironmentFactory)processEngine).openEnvironment();
+
+    try
+    {
+      RepositoryService repositoryService = this.processEngine.getRepositoryService();
+      ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
+          .id(procDefId)
+          .uniqueResult();
+      return ModelAdaptor.adoptDefinition(processDefinition);
+
+    }
+    finally
+    {
+      env.close();
+    }
   }
 
   public List<ProcessDefinitionRef> removeProcessDefinition(String procDefId)
   {
-    RepositoryService repositoryService = this.processEngine.getRepositoryService();
-    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
-        .id(procDefId)
-        .uniqueResult();
-    if (processDefinition!=null) {
-      repositoryService.deleteDeploymentCascade(processDefinition.getDeploymentDbid());
+    Environment env = ((EnvironmentFactory)processEngine).openEnvironment();
+
+    try
+    {
+
+      RepositoryService repositoryService = this.processEngine.getRepositoryService();
+      ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
+          .id(procDefId)
+          .uniqueResult();
+      if (processDefinition!=null) {
+        repositoryService.deleteDeploymentCascade(processDefinition.getDeploymentDbid());
+      }
+      return getProcessDefinitions();
     }
-    return getProcessDefinitions();
+    finally
+    {
+      env.close();
+    }
   }
 
   public List<ProcessInstanceRef> getProcessInstances(String procDefId)
   {
-    ExecutionService execService = this.processEngine.getExecutionService();
-    ExecutionQuery query = execService.createExecutionQuery();
-    query.processDefinitionId(String.valueOf(procDefId));
-    
-    List<Execution> executions = query.execute();
+    Environment env = ((EnvironmentFactory)processEngine).openEnvironment();
 
-    List<ProcessInstanceRef> results = adoptTopLevelExecutions(executions);
+    try
+    {
 
-    return results;
+      ExecutionService execService = this.processEngine.getExecutionService();
+      ExecutionQuery query = execService.createExecutionQuery();
+      query.processDefinitionId(String.valueOf(procDefId));
+
+      List<Execution> executions = query.execute();
+
+      List<ProcessInstanceRef> results = adoptTopLevelExecutions(executions);
+
+      return results;
+    }
+    finally
+    {
+      env.close();
+    }
   }
 
   private List<ProcessInstanceRef> adoptTopLevelExecutions(List<Execution> executions)
   {
-    List<ProcessInstanceRef> results = new ArrayList<ProcessInstanceRef>();
-    for(Execution exec : executions)
+    Environment env = ((EnvironmentFactory)processEngine).openEnvironment();
+
+    try
     {
-      if(exec.isEnded())
+
+      List<ProcessInstanceRef> results = new ArrayList<ProcessInstanceRef>();
+      for(Execution exec : executions)
       {
-        System.out.println("*** JBPM-2055: Execution ("+exec.getId()+") is already ended. " +
-            "Should not show up in query");
-        continue;
-      }
+        if(exec.isEnded())
+        {
+          System.out.println("*** JBPM-2055: Execution ("+exec.getId()+") is already ended. " +
+              "Should not show up in query");
+          continue;
+        }
 
-      if(exec.isProcessInstance()) // parent execution
-      {
-        results.add( ModelAdaptor.adoptExecution((OpenExecution)exec) );
+        if(exec.isProcessInstance()) // parent execution
+        {
+          results.add( ModelAdaptor.adoptExecution((OpenExecution)exec) );
+        }
       }
+      return results;
     }
-    return results;
+    finally
+    {
+      env.close();
+    }
   }
 
   public ProcessInstanceRef getProcessInstance(String instanceId)
   {
-    ExecutionService execService = this.processEngine.getExecutionService();
-    ExecutionQuery query = execService.createProcessInstanceQuery();
-    query.processInstanceId(instanceId);
-    List<Execution> executions = query.execute();
+    Environment env = ((EnvironmentFactory)processEngine).openEnvironment();
 
-    if(executions.size()>1 || executions.isEmpty())
-      throw new IllegalStateException("No precise match for instanceId " + instanceId +". Num results "+executions);
+    try
+    {
 
-    return ModelAdaptor.adoptExecution( (OpenExecution)executions.get(0));
+      ExecutionService execService = this.processEngine.getExecutionService();
+      ExecutionQuery query = execService.createProcessInstanceQuery();
+      query.processInstanceId(instanceId);
+      List<Execution> executions = query.execute();
+
+      if(executions.size()>1 || executions.isEmpty())
+        throw new IllegalStateException("No precise match for instanceId " + instanceId +". Num results "+executions);
+
+      return ModelAdaptor.adoptExecution( (OpenExecution)executions.get(0));
+    }
+    finally
+    {
+      env.close();
+    }
   }
 
   public ProcessInstanceRef newInstance(String definitionId)
   {
-    ExecutionService execService = this.processEngine.getExecutionService();
-    Execution exec = execService.startProcessInstanceById(definitionId);
-    return ModelAdaptor.adoptExecution((OpenExecution)exec);
+    Environment env = ((EnvironmentFactory)processEngine).openEnvironment();
+
+    try
+    {
+      ExecutionService execService = this.processEngine.getExecutionService();
+      Execution exec = execService.startProcessInstanceById(definitionId);
+      return ModelAdaptor.adoptExecution((OpenExecution)exec);
+    }
+    finally{
+      env.close();
+    }
   }
 
   public void setProcessState(String executionId, ProcessInstanceRef.STATE nextState)
   {
-    if(ProcessInstanceRef.STATE.ENDED==nextState)
+
+    Environment env = ((EnvironmentFactory)processEngine).openEnvironment();
+
+    try
     {
-      // TODO: It's actually a delete call. Once we got the 'cancel' notion this should be changed
-      ExecutionService execService = this.processEngine.getExecutionService();
-      Execution exec = execService.findExecution(executionId);
-      if(null==exec)
-        throw new IllegalArgumentException("No such execution with id "+ executionId);
-      
-      execService.deleteProcessInstance(executionId);
+      if(ProcessInstanceRef.STATE.ENDED==nextState)
+      {
+        // TODO: It's actually a delete call. Once we got the 'cancel' notion this should be changed
+        ExecutionService execService = this.processEngine.getExecutionService();
+        Execution exec = execService.findExecution(executionId);
+        if(null==exec)
+          throw new IllegalArgumentException("No such execution with id "+ executionId);
+
+        execService.deleteProcessInstance(executionId);
+      }
+      else
+      {
+        throw new IllegalArgumentException("State " + nextState + " currently not supported");
+      }
     }
-    else
+    finally
     {
-      throw new IllegalArgumentException("State " + nextState + " currently not supported");
+      env.close();
     }
   }
 
   public void signalExecution(String executionId, String signal)
-  {        
-    ExecutionService execService = this.processEngine.getExecutionService();
+  {
+    Environment env = ((EnvironmentFactory)processEngine).openEnvironment();
 
-    if(null==signal)
-      execService.signalExecutionById(executionId);
-    else
-      execService.signalExecutionById(executionId, signal);
-            
+    try
+    {
+      ExecutionService execService = this.processEngine.getExecutionService();
+
+      if(null==signal)
+        execService.signalExecutionById(executionId);
+      else
+        execService.signalExecutionById(executionId, signal);
+    }
+    finally
+    {
+      env.close();
+    }
+
   }
 
   public void deploy(String fileName, String contentType, InputStream deployment)

Modified: jbpm4/branches/jbpm-4.0.0.Beta1/modules/userguide/src/main/docbook/en/master.xml
===================================================================
--- jbpm4/branches/jbpm-4.0.0.Beta1/modules/userguide/src/main/docbook/en/master.xml	2009-04-08 13:30:13 UTC (rev 4500)
+++ jbpm4/branches/jbpm-4.0.0.Beta1/modules/userguide/src/main/docbook/en/master.xml	2009-04-08 14:06:45 UTC (rev 4501)
@@ -9,6 +9,7 @@
   <!ENTITY ch06-Variables          SYSTEM "modules/ch06-Variables.xml">
   <!ENTITY ch07-Scripting          SYSTEM "modules/ch07-Scripting.xml">
   <!ENTITY ch08-Identity           SYSTEM "modules/ch08-Identity.xml">
+  <!ENTITY ch08-JBossIntegration   SYSTEM "modules/ch09-JBossIntegration.xml">
 ]>
 
 <book lang="en">
@@ -27,5 +28,6 @@
   &ch06-Variables;
   &ch07-Scripting;
   &ch08-Identity;
+  &ch08-JBossIntegration;
 
 </book>
\ No newline at end of file

Copied: jbpm4/branches/jbpm-4.0.0.Beta1/modules/userguide/src/main/docbook/en/modules/ch09-JBossIntegration.xml (from rev 4500, jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch09-JBossIntegration.xml)
===================================================================
--- jbpm4/branches/jbpm-4.0.0.Beta1/modules/userguide/src/main/docbook/en/modules/ch09-JBossIntegration.xml	                        (rev 0)
+++ jbpm4/branches/jbpm-4.0.0.Beta1/modules/userguide/src/main/docbook/en/modules/ch09-JBossIntegration.xml	2009-04-08 14:06:45 UTC (rev 4501)
@@ -0,0 +1,140 @@
+<chapter id="identity">
+  <title>JBoss Integration</title>
+
+  <para>
+    jBPM provides integration with JBoss 4.2.x and JBoss 5.0.0.GA.
+    As part of the <link linkend="runningtheinstaller">installation</link>, the ProcessEngine and a deployer for jBPM archives
+    will be installed as a JBoss service.
+  </para>
+
+  <para>
+    After a successful installation you should see that the ProcessEngine
+    has been started and bound to JNDI:
+  </para>
+
+  <programlisting>
+    [...]
+    14:12:09,301 INFO  [JBPMService] jBPM 4 - Integration JBoss 4
+    14:12:09,301 INFO  [JBPMService] 4.0.0.Beta1
+    14:12:09,301 INFO  [JBPMService] ProcessEngine bound to: java:/ProcessEngine
+  </programlisting>
+
+  <section>
+    <title>Packaging process archives</title>
+    <para>
+      When jBPM is deployed on a JBoss instance, process deployments are treated like
+      any other deployment artifact (i.e. *.war, *.ear) and processed by the JBPMDeployer.
+      In order to deploy a process archive simply create a *.jpdl archive (zip file) that contains
+      the process definition (*.jpdl.xml) and all required resources to execute the process (i.e. classes, property files):
+    </para>
+    <programlisting>
+      Bonanova:Desktop hbraun$ jar -tf OrderProcess.jpdl
+
+      META-INF/MANIFEST.MF
+      OrderProcess.jpdl.xml
+      org/mycompany/order/*.class
+    </programlisting>
+  </section>
+
+  <section>
+    <title>Deploying processes archives to a JBoss instance</title>
+    <para>
+      In order to deploy a process archive simply copy it to $JBOSS_HOME/server/&lt;config>/deploy:
+    </para>
+
+    <programlisting>
+      (1) cp OrderProcess.jpdl $JBOSS_HOME/server/default/deploy
+
+      (2) less $JBOSS_HOME/server/default/log
+      [...]
+      2009-04-08 14:12:21,947 INFO  [org.jbpm.integration.jboss4.JBPMDeployer]
+      Deploy file:/Users/hbraun/dev/prj/jboss/tags/JBoss_4_2_2_GA
+      /build/output/jboss-4.2.2.GA/server/default/deploy/OrderProcess.jpdl
+    </programlisting>
+
+    <para>
+      In order to remove a process simply remove the process archive from the deploy directory.
+    </para>
+  </section>
+
+  <section>
+    <title>Process deployments and versioning</title>
+    <para>
+      TBD: A prelimenary explanation cn be found <ulink url="http://relative-order.blogspot.com/2009/03/rfc-process-deployment-use-cases.html">here</ulink>
+    </para>
+  </section>
+
+  <section>
+    <title>ProcessEngine and J2EE/JEE programming models</title>
+    <para>
+      As described above the ProcessEngine will be installed as JBoss service and bound to JNDI.
+      This means that any EE component (i.e. servlet, ejb) can access it doing a JNDI lookup:
+    </para>
+
+    <programlisting>
+    private ProcessEngine processEngine;
+    [...]
+
+    try
+    {
+      InitialContext ctx = new InitialContext();
+      this.processEngine = (ProcessEngine)ctx.lookup("java:/ProcessEngine");
+    }
+    catch (Exception e)
+    {
+      throw new RuntimeException("Failed to lookup process engine");
+    }
+    </programlisting>
+
+    <para>
+      Once you obtained an instance of the ProcessEngine you can invoke on it
+      as described in <link linkend="services">chapter services</link>
+    </para>
+
+    <programlisting>
+    UserTransaction tx = (UserTransaction)ctx.lookup("UserTransaction");        (1)
+    Environment env = ((EnvironmentFactory)processEngine).openEnvironment();
+
+    try
+    {
+
+      ExecutionService execService = (ExecutionService)
+              this.processEngine.get(ExecutionService.class);
+
+      // begin transaction
+      tx.begin();
+
+      // invoke on process engine
+      executionService.signalExecutionById("ICL.82436");
+
+      // commit transaction
+      tx.commit();
+      
+    }
+    catch (Exception e)
+    {
+      if(tx!=null)
+      {
+        try
+        {
+          tx.rollback();
+        }
+        catch (SystemException e1) {}
+      }
+
+      throw new RuntimeException("...", e);
+
+    }
+    finally
+    {
+      env.close();
+    }
+    </programlisting>
+
+    <para>
+      (1) Wrapping the call in a UserTransaction is not necessary if the invocation comes a
+      CMT component, i.e. an EJB.
+    </para>
+  </section>
+
+</chapter>

Copied: jbpm4/branches/jbpm-4.0.0.Beta1/modules/userguide/userguide.iml (from rev 4500, jbpm4/trunk/modules/userguide/userguide.iml)
===================================================================
--- jbpm4/branches/jbpm-4.0.0.Beta1/modules/userguide/userguide.iml	                        (rev 0)
+++ jbpm4/branches/jbpm-4.0.0.Beta1/modules/userguide/userguide.iml	2009-04-08 14:06:45 UTC (rev 4501)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module version="4" relativePaths="true" type="JAVA_MODULE">
+  <component name="ModuleRootManager" />
+  <component name="NewModuleRootManager" inherit-compiler-output="true">
+    <exclude-output />
+    <content url="file://$MODULE_DIR$" />
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntryProperties />
+  </component>
+</module>
+




More information about the jbpm-commits mailing list