[jbpm-commits] JBoss JBPM SVN: r6667 - in jbpm3/branches/jbpm-3.2-soa/core/src/main: resources/org/jbpm and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Sep 22 23:25:02 EDT 2010


Author: alex.guizar at jboss.com
Date: 2010-09-22 23:25:00 -0400 (Wed, 22 Sep 2010)
New Revision: 6667

Modified:
   jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/instantiation/ProcessClassLoader.java
   jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/instantiation/SharedProcessClassLoaderFactory.java
   jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml
Log:
JBPM-2908 have shared process class loader factory remember the jbpm configuration that created it

Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/instantiation/ProcessClassLoader.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/instantiation/ProcessClassLoader.java	2010-09-23 00:33:34 UTC (rev 6666)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/instantiation/ProcessClassLoader.java	2010-09-23 03:25:00 UTC (rev 6667)
@@ -76,20 +76,34 @@
   };
 
   public ProcessClassLoader(ClassLoader parent, ProcessDefinition processDefinition) {
+    this(parent, processDefinition, null);
+  }
+
+  ProcessClassLoader(ClassLoader parent, ProcessDefinition processDefinition,
+    JbpmConfiguration jbpmConfiguration) {
     super(parent);
     // check whether the given process definition is transient
     long id = processDefinition.getId();
     if (id != 0) {
       // persistent, keep id only
       processDefinitionId = id;
+      // remember jbpm configuration
+      if (jbpmConfiguration != null) {
+        this.jbpmConfiguration = jbpmConfiguration;
+      }
+      else {
+        JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
+        if (jbpmContext == null) {
+          throw new JbpmException("no active jbpm context");
+        }
+        this.jbpmConfiguration = jbpmContext.getJbpmConfiguration();
+      }
     }
     else {
       // transient, keep full object
       this.processDefinition = processDefinition;
+      this.jbpmConfiguration = null;
     }
-    // remember current jbpm configuration
-    JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
-    jbpmConfiguration = jbpmContext != null ? jbpmContext.getJbpmConfiguration() : null;
   }
 
   protected ProcessDefinition getProcessDefinition() {

Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/instantiation/SharedProcessClassLoaderFactory.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/instantiation/SharedProcessClassLoaderFactory.java	2010-09-23 00:33:34 UTC (rev 6666)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/instantiation/SharedProcessClassLoaderFactory.java	2010-09-23 03:25:00 UTC (rev 6667)
@@ -28,6 +28,7 @@
 import java.util.List;
 import java.util.Map;
 
+import org.jbpm.JbpmConfiguration;
 import org.jbpm.graph.def.ProcessDefinition;
 import org.jbpm.util.ClassLoaderUtil;
 
@@ -39,10 +40,19 @@
  */
 public class SharedProcessClassLoaderFactory implements ProcessClassLoaderFactory {
 
+  private final JbpmConfiguration jbpmConfiguration;
   private transient Map classLoaderRefs = new HashMap();
 
   private static final long serialVersionUID = 1L;
 
+  public SharedProcessClassLoaderFactory() {
+    jbpmConfiguration = null;
+  }
+
+  public SharedProcessClassLoaderFactory(JbpmConfiguration jbpmConfiguration) {
+    this.jbpmConfiguration = jbpmConfiguration;
+  }
+
   public ClassLoader getProcessClassLoader(ProcessDefinition processDefinition) {
     // determine the key to lookup a cached class loader
     // observe that the given process definition may be transient
@@ -58,7 +68,7 @@
       // the reference may not exist or may have been cleared already
       if (processClassLoader == null) {
         // (re-)create the class loader and the reference
-        processClassLoader = new ProcessClassLoader(parentClassLoader, processDefinition);
+        processClassLoader = new ProcessClassLoader(parentClassLoader, processDefinition, jbpmConfiguration);
         // cache the reference
         putProcessClassLoader(key, processClassLoader);
       }

Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml	2010-09-23 00:33:34 UTC (rev 6666)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml	2010-09-23 03:25:00 UTC (rev 6667)
@@ -47,7 +47,13 @@
   <string name="jbpm.class.loader" value="context" />
   -->
   <bean name="process.class.loader.factory"
-    class="org.jbpm.instantiation.SharedProcessClassLoaderFactory" singleton="true" />
+    class="org.jbpm.instantiation.SharedProcessClassLoaderFactory" singleton="true">
+    <constructor>
+      <parameter class="org.jbpm.JbpmConfiguration">
+        <ref bean="jbpm.configuration" />
+      </parameter>
+    </constructor>
+  </bean>
 
   <!-- make sure the block size matches the length in ByteArray.hbm.xml -->
   <int name="jbpm.byte.block.size" value="1024" />
@@ -84,7 +90,7 @@
   <!-- job execution properties -->
   <bean name="jbpm.job.executor" class="org.jbpm.job.executor.JobExecutor" singleton="true">
     <property name="jbpmConfiguration">
-      <ref bean="jbpmConfiguration" />
+      <ref bean="jbpm.configuration" />
     </property>
     <property name="name">
       <string value="JbpmJobExecutor" />



More information about the jbpm-commits mailing list