[jbpm-commits] JBoss JBPM SVN: r6623 - in jbpm3/branches/jbpm-3.2-soa/modules: core/src/main/java/org/jbpm/jpdl and 5 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Aug 24 14:30:53 EDT 2010


Author: alex.guizar at jboss.com
Date: 2010-08-24 14:30:53 -0400 (Tue, 24 Aug 2010)
New Revision: 6623

Modified:
   jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/node/DbSubProcessResolver.java
   jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/node/ProcessState.java
   jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/node/SubProcessResolver.java
   jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/jpdl/JpdlException.java
   jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/jpdl/el/impl/JbpmExpressionEvaluator.java
   jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/jpdl/par/JpdlArchiveParser.java
   jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml
   jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/jpdl/xml/jpdl-3.2.xsd
   jbpm3/branches/jbpm-3.2-soa/modules/userguide/src/main/docbook/en-US/jpdl.xml
Log:
JBPM-2473 amend description about coexistence of version and binding attribute in sub-process element;
remove duplicate binding attribute from process-state element schema;
document SubProcessResolver interface

Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/node/DbSubProcessResolver.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/node/DbSubProcessResolver.java	2010-08-24 03:07:12 UTC (rev 6622)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/node/DbSubProcessResolver.java	2010-08-24 18:30:53 UTC (rev 6623)
@@ -2,7 +2,6 @@
 
 import org.dom4j.Element;
 import org.jbpm.JbpmContext;
-import org.jbpm.db.GraphSession;
 import org.jbpm.graph.def.ProcessDefinition;
 import org.jbpm.jpdl.JpdlException;
 
@@ -11,36 +10,33 @@
   private static final long serialVersionUID = 1L;
 
   public ProcessDefinition findSubProcess(Element subProcessElement) {
-    // if this parsing is done in the context of a process deployment,
+    // if subprocess resolution is done within an active context,
     // there is a database connection to look up the subprocess.
-    // when there is no jbpmSession, the definition will be left null...
-    // the test case can set it as appropriate.
+    // otherwise, the subprocess will be left null and
+    // it is up to client code to set the subprocess as appropriate.
     JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
     if (jbpmContext != null) {
-      GraphSession graphSession = jbpmContext.getGraphSession();
-
-      // now, we must be able to find the sub-process
+      // within an active context it is possible to find the sub-process
       String subProcessName = subProcessElement.attributeValue("name");
       if (subProcessName == null) {
-        throw new JpdlException("subprocess name is not specified: "
-          + subProcessElement.getPath());
+        throw new JpdlException("missing sub-process name");
       }
 
       // if only the name is specified,
       String subProcessVersion = subProcessElement.attributeValue("version");
       if (subProcessVersion == null) {
         // select the latest version of the subprocess definition
-        return graphSession.findLatestProcessDefinition(subProcessName);
+        return jbpmContext.getGraphSession().findLatestProcessDefinition(subProcessName);
       }
 
       // if the name and the version are specified
       try {
         // select the exact version of the subprocess definition
         int version = Integer.parseInt(subProcessVersion);
-        return graphSession.findProcessDefinition(subProcessName, version);
+        return jbpmContext.getGraphSession().findProcessDefinition(subProcessName, version);
       }
       catch (NumberFormatException e) {
-        throw new JpdlException("bad subprocess version: " + subProcessVersion);
+        throw new JpdlException("bad sub-process version value: " + subProcessVersion);
       }
     }
 

Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/node/ProcessState.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/node/ProcessState.java	2010-08-24 03:07:12 UTC (rev 6622)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/node/ProcessState.java	2010-08-24 18:30:53 UTC (rev 6623)
@@ -30,7 +30,6 @@
 import org.dom4j.Element;
 import org.dom4j.tree.DefaultElement;
 
-import org.jbpm.JbpmException;
 import org.jbpm.JbpmConfiguration.Configs;
 import org.jbpm.context.def.VariableAccess;
 import org.jbpm.context.exe.ContextInstance;
@@ -42,6 +41,7 @@
 import org.jbpm.graph.exe.ProcessInstance;
 import org.jbpm.graph.exe.Token;
 import org.jbpm.graph.log.ProcessStateLog;
+import org.jbpm.jpdl.JpdlException;
 import org.jbpm.jpdl.el.impl.JbpmExpressionEvaluator;
 import org.jbpm.jpdl.xml.JpdlXmlReader;
 import org.jbpm.util.Clock;
@@ -50,13 +50,18 @@
 
   private static final long serialVersionUID = 1L;
 
-  private static SubProcessResolver defaultSubProcessResolver = new DbSubProcessResolver();
+  private static SubProcessResolver defaultSubProcessResolver;
 
   /** @deprecated set configuration entry <code>jbpm.sub.process.resolver</code> instead */
   public static void setDefaultSubProcessResolver(SubProcessResolver subProcessResolver) {
     defaultSubProcessResolver = subProcessResolver;
   }
 
+  public static SubProcessResolver getSubProcessResolver() {
+    return defaultSubProcessResolver != null ? defaultSubProcessResolver
+      : (SubProcessResolver) Configs.getObject("jbpm.sub.process.resolver");
+  }
+
   protected ProcessDefinition subProcessDefinition;
   protected Set variableAccesses;
   protected String subProcessName;
@@ -119,8 +124,8 @@
         return subProcess;
       }
     }
-    catch (JbpmException e) {
-      jpdlReader.addError("failed to resolve subprocess", e);
+    catch (JpdlException e) {
+      jpdlReader.addError(e.getMessage());
     }
 
     // check whether this is a recursive process invocation
@@ -134,11 +139,6 @@
     return null;
   }
 
-  private SubProcessResolver getSubProcessResolver() {
-    return Configs.hasObject("jbpm.sub.process.resolver") ? (SubProcessResolver) Configs
-      .getObject("jbpm.sub.process.resolver") : defaultSubProcessResolver;
-  }
-
   public void execute(ExecutionContext executionContext) {
     Token superProcessToken = executionContext.getToken();
 
@@ -227,20 +227,18 @@
     // remove the subprocess reference
     superProcessToken.setSubProcessInstance(null);
 
-    // We replaced the normal log generation of super.leave()
-    // by creating the log here
-    // and overriding the addNodeLog method with an empty version
-    superProcessToken.addLog(new ProcessStateLog(this, superProcessToken.getNodeEnter(), Clock
-      .getCurrentTime(), subProcessInstance));
+    // override the normal log generation in super.leave() by creating the log here
+    // and replacing addNodeLog() with an empty version
+    superProcessToken.addLog(new ProcessStateLog(this, superProcessToken.getNodeEnter(),
+      Clock.getCurrentTime(), subProcessInstance));
 
     // call the subProcessEndAction
     super.leave(executionContext, getDefaultLeavingTransition());
   }
 
-  // We replaced the normal log generation of super.leave()
-  // by creating the log above in the leave method
-  // and overriding the addNodeLog method with an empty version
   protected void addNodeLog(Token token) {
+    // override the normal log generation in super.leave() by creating the log in this.leave()
+    // and replacing this method with an empty version
   }
 
   public ProcessDefinition getSubProcessDefinition() {

Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/node/SubProcessResolver.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/node/SubProcessResolver.java	2010-08-24 03:07:12 UTC (rev 6622)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/node/SubProcessResolver.java	2010-08-24 18:30:53 UTC (rev 6623)
@@ -5,8 +5,16 @@
 import org.dom4j.Element;
 import org.jbpm.graph.def.ProcessDefinition;
 
+/**
+ * An agent capable of resolving sub-process definitions given the information items in the
+ * <code>sub-process</code> element taken from a process definition document.
+ */
 public interface SubProcessResolver extends Serializable {
 
+  /**
+   * Resolves a sub-process definition given the information items in the
+   * <code>sub-process</code> element.
+   */
   ProcessDefinition findSubProcess(Element subProcessElement);
 
 }

Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/jpdl/JpdlException.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/jpdl/JpdlException.java	2010-08-24 03:07:12 UTC (rev 6622)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/jpdl/JpdlException.java	2010-08-24 18:30:53 UTC (rev 6623)
@@ -24,16 +24,17 @@
 import java.util.Collections;
 import java.util.List;
 
+import org.jbpm.JbpmException;
 import org.jbpm.jpdl.xml.Problem;
 
-public class JpdlException extends RuntimeException {
+public class JpdlException extends JbpmException {
 
   private static final long serialVersionUID = 1L;
 
   protected List problems;
 
   public JpdlException(List problems) {
-    super(problems.toString());
+    super(problems.size() + " problems found");
     this.problems = problems;
   }
 

Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/jpdl/el/impl/JbpmExpressionEvaluator.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/jpdl/el/impl/JbpmExpressionEvaluator.java	2010-08-24 03:07:12 UTC (rev 6622)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/jpdl/el/impl/JbpmExpressionEvaluator.java	2010-08-24 18:30:53 UTC (rev 6623)
@@ -12,11 +12,6 @@
 
   private static ExpressionEvaluator expressionEvaluator;
 
-  private static ExpressionEvaluator getExpressionEvaluator() {
-    return expressionEvaluator != null ? expressionEvaluator
-      : (ExpressionEvaluator) Configs.getObject("jbpm.expression.evaluator");
-  }
-
   /**
    * @deprecated set configuration entry <code>jbpm.expression.evaluator</code> instead
    */
@@ -24,6 +19,11 @@
     JbpmExpressionEvaluator.expressionEvaluator = expressionEvaluator;
   }
 
+  public static ExpressionEvaluator getExpressionEvaluator() {
+    return expressionEvaluator != null ? expressionEvaluator
+      : (ExpressionEvaluator) Configs.getObject("jbpm.expression.evaluator");
+  }
+
   private static VariableResolver variableResolver;
 
   /**
@@ -33,6 +33,16 @@
     JbpmExpressionEvaluator.variableResolver = variableResolver;
   }
 
+  public static VariableResolver getVariableResolver() {
+    return variableResolver != null ? variableResolver
+      : (VariableResolver) Configs.getObject("jbpm.variable.resolver");
+  }
+
+  /** @deprecated call {@link #getVariableResolver()} instead */
+  public static VariableResolver getUsedVariableResolver() {
+    return getVariableResolver();
+  }
+
   private static FunctionMapper functionMapper;
 
   /**
@@ -42,6 +52,17 @@
     JbpmExpressionEvaluator.functionMapper = functionMapper;
   }
 
+  public static FunctionMapper getFunctionMapper() {
+    return functionMapper != null ? functionMapper
+      : Configs.hasObject("jbpm.function.mapper") ? (FunctionMapper) Configs.getObject("jbpm.function.mapper")
+        : null;
+  }
+
+  /** @deprecated call {@link #getFunctionMapper()} instead */
+  public static FunctionMapper getUsedFunctionMapper() {
+    return getFunctionMapper();
+  }
+
   public static Object evaluate(String expression, ExecutionContext executionContext) {
     return evaluate(expression, executionContext, Object.class);
   }
@@ -75,25 +96,4 @@
   private static String translateExpressionToDollars(String expression) {
     return hashPattern.matcher(expression).replaceAll("\\${$1}");
   }
-
-  /** @deprecated call {@link #getVariableResolver()} instead */
-  public static VariableResolver getUsedVariableResolver() {
-    return getVariableResolver();
-  }
-
-  public static VariableResolver getVariableResolver() {
-    return variableResolver != null ? variableResolver
-      : (VariableResolver) Configs.getObject("jbpm.variable.resolver");
-  }
-
-  /** @deprecated call {@link #getFunctionMapper()} instead */
-  public static FunctionMapper getUsedFunctionMapper() {
-    return getFunctionMapper();
-  }
-
-  public static FunctionMapper getFunctionMapper() {
-    return functionMapper != null ? functionMapper
-      : Configs.hasObject("jbpm.function.mapper") ? (FunctionMapper) Configs.getObject("jbpm.function.mapper")
-        : null;
-  }
 }

Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/jpdl/par/JpdlArchiveParser.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/jpdl/par/JpdlArchiveParser.java	2010-08-24 03:07:12 UTC (rev 6622)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/jpdl/par/JpdlArchiveParser.java	2010-08-24 18:30:53 UTC (rev 6623)
@@ -22,8 +22,6 @@
 package org.jbpm.jpdl.par;
 
 import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
 
 import org.jbpm.graph.def.ProcessDefinition;
 import org.jbpm.jpdl.JpdlException;
@@ -34,30 +32,17 @@
 
   private static final long serialVersionUID = 1L;
 
-  public ProcessDefinition readFromArchive(ProcessArchive processArchive, ProcessDefinition processDefinition) throws JpdlException{
-    try {
-      // getting the value
-      byte[] processBytes = processArchive.getEntry("processdefinition.xml");
-      
-      if (processBytes==null) {
-        throw new JpdlException("no processdefinition.xml inside process archive");
-      }
-      
-      // creating the JpdlXmlReader
-      InputStream processInputStream  = new ByteArrayInputStream(processBytes);
-      InputSource processInputSource = new InputSource(processInputStream); 
-      JpdlXmlReader jpdlXmlReader = new JpdlXmlReader(processInputSource, processArchive);
-      
-      processDefinition = jpdlXmlReader.readProcessDefinition();
-
-      // close all the streams
-      jpdlXmlReader.close();
-      processInputStream.close();
-      
-    } catch (IOException e) {
-      throw new JpdlException("io problem while reading processdefinition.xml: "+e.getMessage(), e);
+  public ProcessDefinition readFromArchive(ProcessArchive processArchive,
+    ProcessDefinition processDefinition) throws JpdlException {
+    // getting the value
+    byte[] processBytes = processArchive.getEntry("processdefinition.xml");
+    if (processBytes == null) {
+      throw new JpdlException("no processdefinition.xml inside process archive");
     }
-    
-    return processDefinition;
+
+    ByteArrayInputStream processStream = new ByteArrayInputStream(processBytes);
+    JpdlXmlReader jpdlXmlReader = new JpdlXmlReader(new InputSource(processStream),
+      processArchive);
+    return jpdlXmlReader.readProcessDefinition();
   }
 }

Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml	2010-08-24 03:07:12 UTC (rev 6622)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml	2010-08-24 18:30:53 UTC (rev 6623)
@@ -45,12 +45,15 @@
   <!-- alternate delegation class loader
   <string name="jbpm.class.loader" value="context" />
   -->
-  <bean name="process.class.loader.factory" class="org.jbpm.instantiation.SharedProcessClassLoaderFactory"
-    singleton="true" />
+  <bean name="process.class.loader.factory"
+    class="org.jbpm.instantiation.SharedProcessClassLoaderFactory" singleton="true" />
 
   <!-- make sure the block size matches the length in ByteArray.hbm.xml -->
   <int name="jbpm.byte.block.size" value="1024" />
 
+  <bean name="jbpm.sub.process.resolver" class="org.jbpm.graph.node.DbSubProcessResolver"
+    singleton="true" />
+
   <bean name="jbpm.expression.evaluator" class="org.jbpm.jpdl.el.impl.ExpressionEvaluatorImpl"
     singleton="true" />
   <bean name="jbpm.variable.resolver" class="org.jbpm.jpdl.el.impl.JbpmVariableResolver"

Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/jpdl/xml/jpdl-3.2.xsd
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/jpdl/xml/jpdl-3.2.xsd	2010-08-24 03:07:12 UTC (rev 6622)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/jpdl/xml/jpdl-3.2.xsd	2010-08-24 18:30:53 UTC (rev 6623)
@@ -118,7 +118,7 @@
           <xs:complexType>
             <xs:attribute name="name" type="xs:string" use="required" />
             <xs:attribute name="version" type="xs:integer" />
-            <xs:attribute name="binding" type="xs:string" />
+            <xs:attribute name="binding" type="bindingType" />
           </xs:complexType>
         </xs:element>
         <xs:element ref="variable" />
@@ -126,7 +126,6 @@
       </xs:choice>
       <xs:attribute name="name" type="xs:string" use="required" />
       <xs:attribute name="async" type="asyncType" default="false" />
-      <xs:attribute name="binding" type="bindingType" />
     </xs:complexType>
   </xs:element>
 

Modified: jbpm3/branches/jbpm-3.2-soa/modules/userguide/src/main/docbook/en-US/jpdl.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/userguide/src/main/docbook/en-US/jpdl.xml	2010-08-24 03:07:12 UTC (rev 6622)
+++ jbpm3/branches/jbpm-3.2-soa/modules/userguide/src/main/docbook/en-US/jpdl.xml	2010-08-24 18:30:53 UTC (rev 6623)
@@ -1052,14 +1052,6 @@
             </row>
           </thead>
           <tbody>
-          <row>
-              <entry>binding</entry>
-              <entry>attribute</entry>
-              <entry>optional</entry>
-              <entry>This defines the moment at which a sub-process is
-              resolved. The options are: <code>{late|*}</code>. It defaults
-              to resolving the <property>deploytime</property></entry>
-            </row>
             <row>
               <entry>sub-process</entry>
               <entry>element</entry>
@@ -2080,37 +2072,37 @@
               <entry><property>name</property></entry>
               <entry>attribute</entry>
               <entry>required</entry>
-                  <entry>
-                  This is the name of the
-                  <classname>sub-process</classname>. It can be an EL
-                  expression but it must resolve to a
-                  <classname>String</classname>. 
+              <entry>
+                Name of the sub-process to call.
+                Can be an EL expression which must evaluate to <classname>String</classname>. 
               </entry>
             </row>
             <row>
               <entry><property>version</property></entry>
               <entry>attribute</entry>
               <entry>optional</entry>
-                 <entry>
-                 This  is the version of the <classname>sub-process</classname>. If
-                 <property>version</property> is not specified, jBPM will use the latest known version of the
-                 given process whilst it deploys the parent process-state. 
-                </entry>
+              <entry>
+                Version of the sub-process to call.
+                If <property>version</property> is not specified,
+                the <classname>process-state</classname> takes
+                the latest version of the given process.
+              </entry>
             </row>
             <row>
-                <entry><property>binding</property></entry>
+              <entry><property>binding</property></entry>
               <entry>attribute</entry>
               <entry>optional</entry>
-                <entry>
-                Controls when the version of the <classname>sub-process</classname> is determined.
-                The default behaviour is to determine the version when deploying the parent
-                <classname>process-state</classname>. If <property>binding</property> is defined as
-                <code>late</code> (<code>binding="late"</code>) then it is determined
-                when the <classname>sub-process</classname> is invoked. If
-                <property>binding</property> is set to "late" and <property>version</property> is
-                specified, then the value of version will be ignored and the latest version will be
-                used.
-            </entry>
+              <entry>
+                Defines the moment when the sub-process is resolved.
+                The options are: <code>{early|late}</code>. The default is
+                to resolve <code>early</code>, that is, at deployment time.
+                If <property>binding</property> is defined as <code>late</code>,
+                the <classname>process-state</classname> resolves the latest
+                version of the given process at each execution.
+                Late binding is senseless in combination with a fixed version;
+                therefore, the <property>version</property> attribute is ignored
+                if <code>binding="late"</code>.
+              </entry>
           </row>
           </tbody>
         </tgroup>



More information about the jbpm-commits mailing list