[jbpm-commits] JBoss JBPM SVN: r6596 - in jbpm4/trunk/modules: jpdl/src/main/java/org/jbpm/jpdl/internal/activity and 4 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Sun Aug 15 20:05:50 EDT 2010


Author: rebody
Date: 2010-08-15 20:05:49 -0400 (Sun, 15 Aug 2010)
New Revision: 6596

Added:
   jbpm4/trunk/modules/migration/src/test/resources/jbpm.hibernate.cfg.xml
Modified:
   jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/AbstractMergingGatewayActivity.java
   jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JoinActivity.java
   jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JoinBinding.java
   jbpm4/trunk/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/Jpdl3ConverterReaderTest.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/DbSessionImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/DbSession.java
Log:
JBPM-2927 replace LockMode

Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/AbstractMergingGatewayActivity.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/AbstractMergingGatewayActivity.java	2010-08-15 15:14:11 UTC (rev 6595)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/AbstractMergingGatewayActivity.java	2010-08-16 00:05:49 UTC (rev 6596)
@@ -25,111 +25,109 @@
 import java.util.Collection;
 import java.util.List;
 
-import org.hibernate.LockMode;
-import org.hibernate.Session;
-
 import org.jbpm.api.Execution;
 import org.jbpm.api.activity.ActivityExecution;
 import org.jbpm.api.model.Activity;
 import org.jbpm.internal.log.Log;
 import org.jbpm.pvm.internal.env.EnvironmentImpl;
 import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.session.DbSession;
 
 /**
  * Superclass for gateway activities that wait on multiple incoming executions before merging
- * them together. 
- * 
+ * them together.
+ *
  * The {@link InclusiveGatewayActivity} and {@link ParallelGatewayActivity} are examples of such
- * gateways which have merge behaviour. 
- * 
+ * gateways which have merge behaviour.
+ *
  * @author Joram Barrez
  */
 public abstract class AbstractMergingGatewayActivity extends AbstractGatewayActivity {
-  
+
   private static final long serialVersionUID = 1L;
 
   private static final Log LOG = Log.getLog(AbstractMergingGatewayActivity.class.getName());
-  
-  protected LockMode lockMode = LockMode.UPGRADE;
-  
+
+  protected String lockModeType = "UPGRADE";
+
   public void execute(ActivityExecution execution) {
     execute((ExecutionImpl) execution);
   }
-  
+
   /**
    * Executing the actvity logic is common for all gateway types that have merge/split behaviour.
-   * 
+   *
    * For all incoming sequence flow, the gateway will handle the executions. When all sequence
    * flow have arrived at the gateway, the fork logic is executed (a gateway can have both
    * merging and splitting behaviour).
    */
-  public void execute(ExecutionImpl execution) { 
+  public void execute(ExecutionImpl execution) {
     int nrOfIncoming = execution.getActivity().getIncomingTransitions().size();
-    
+
     if (nrOfIncoming == 1) { // no join behaviour needed, save some time and do a fork immediately
-      
+
       if (LOG.isDebugEnabled()) {
         LOG.debug("Only one incoming sequence flow found. Executing fork logic.");
       }
       fork(execution);
-      
+
     } else {
-      
+
       if (LOG.isDebugEnabled()) {
         LOG.debug("Multiple incoming sequence flow found. Handling incoming execution.");
       }
       boolean allExecutionsArrived = handleIncomingExecution(execution);
-      
+
       if (LOG.isDebugEnabled()) {
         LOG.debug("All executions arrived at the gateway: " + allExecutionsArrived);
       }
-      
-      // After executing the join functionality, it could be that all executions have arrived 
+
+      // After executing the join functionality, it could be that all executions have arrived
       // at the gateway. In that case, the gateway can be left.
       if (allExecutionsArrived) {
         ExecutionImpl outgoingExecution = join(execution);
         fork(outgoingExecution);
       }
-      
+
     }
   }
-  
+
   /**
    * Joins the incoming executions.
    * Returns true if all executions have reached the gateway.
    */
   protected boolean handleIncomingExecution(ExecutionImpl execution) {
     if (Execution.STATE_ACTIVE_CONCURRENT.equals(execution.getState())) {
-     
+
       // force version increment in the parent execution
-      Session session = EnvironmentImpl.getFromCurrent(Session.class);
-      session.lock(execution.getParent(), lockMode);
+      DbSession dbSession = EnvironmentImpl.getFromCurrent(DbSession.class);
+      dbSession.lock(execution.getParent(), lockModeType);
 
       execution.setState(Execution.STATE_INACTIVE_JOIN);
-      
+
     }
-    
+
     execution.waitForSignal();
     return isComplete(execution);
   }
-  
+
   /**
    * Joins all the incoming executions currently waiting at the gateway.
-   * 
+   *
    * @return An execution that can be used to leave the gateway (one outgoing sequence flow)
    * or to create child executions on (fork behaviour when multiple outgoing sequence flow).
    */
   protected ExecutionImpl join(ExecutionImpl execution) {
     Activity activity = execution.getActivity();
     ExecutionImpl concurrentRoot = execution.getParent();
-    
+
     if (concurrentRoot == null) {
       return execution;
     }
-    
+
     List<ExecutionImpl> joinedExecutions = getJoinedExecutions(concurrentRoot, activity);
     endJoinedExecutions(joinedExecutions);
-      
+
     ExecutionImpl outgoingExecution = null;
     if (concurrentRoot.getExecutions().size() == 0) {
       outgoingExecution = concurrentRoot;
@@ -138,11 +136,11 @@
       outgoingExecution = concurrentRoot.createExecution();
       outgoingExecution.setState(Execution.STATE_ACTIVE_CONCURRENT);
     }
-      
+
     outgoingExecution.setActivity(activity);
     return outgoingExecution;
   }
-  
+
   /**
    * @return All executions currently waiting at the gateway.
    */
@@ -156,11 +154,11 @@
         joinedExecutions.add(concurrentExecution);
       }
     }
-    
+
     if (LOG.isDebugEnabled()) {
       LOG.debug("Found " + joinedExecutions.size() + " executions currently waiting at the gateway");
     }
-    
+
     return joinedExecutions;
   }
 
@@ -172,15 +170,15 @@
       joinedExecution.end();
     }
   }
-  
+
   /*
-   * Fork (or 'split') behaviour is dependent on the actual gateway type and cannot be 
+   * Fork (or 'split') behaviour is dependent on the actual gateway type and cannot be
    * generalized.
    */
   protected abstract void fork(ExecutionImpl execution);
-  
+
   /*
-   * Checking if all incoming sequence flow have arrived at the gateway is gateway type dependent. 
+   * Checking if all incoming sequence flow have arrived at the gateway is gateway type dependent.
    * Eg for the parallel gateway, all incoming sequence flow need to arrive at the gateway, while
    * for the inclusive gateway it depends on the remaining executions in the process instance.
    */

Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JoinActivity.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JoinActivity.java	2010-08-15 15:14:11 UTC (rev 6595)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JoinActivity.java	2010-08-16 00:05:49 UTC (rev 6596)
@@ -25,8 +25,6 @@
 import java.util.Collection;
 import java.util.List;
 
-import org.hibernate.LockMode;
-import org.hibernate.Session;
 import org.jbpm.api.Execution;
 import org.jbpm.api.JbpmException;
 import org.jbpm.api.activity.ActivityExecution;
@@ -36,6 +34,7 @@
 import org.jbpm.pvm.internal.env.EnvironmentImpl;
 import org.jbpm.pvm.internal.model.ActivityImpl;
 import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.session.DbSession;
 
 /**
  * @author Tom Baeyens
@@ -43,8 +42,8 @@
 public class JoinActivity extends JpdlActivity {
 
   private static final long serialVersionUID = 1L;
-  
-  private LockMode lockMode = LockMode.UPGRADE;
+
+  private String lockMode = "UPGRADE";
   private Expression multiplicity;
 
   public void execute(ActivityExecution execution) {
@@ -53,7 +52,7 @@
 
   public void execute(ExecutionImpl execution) {
     ActivityImpl activity = execution.getActivity();
-    
+
     // if this is a single, non concurrent root
     if (Execution.STATE_ACTIVE_ROOT.equals(execution.getState())) {
       // just pass through
@@ -62,19 +61,19 @@
         throw new JbpmException("join must have an outgoing transition");
       }
       execution.take(transition);
-      
+
     } else if (Execution.STATE_ACTIVE_CONCURRENT.equals(execution.getState())) {
-      
+
       // force version increment in the parent execution
-      Session session = EnvironmentImpl.getFromCurrent(Session.class);
-      session.lock(execution.getParent(), lockMode);
+      DbSession dbSession = EnvironmentImpl.getFromCurrent(DbSession.class);
+      dbSession.lock(execution.getParent(), lockMode);
 
       execution.setState(Execution.STATE_INACTIVE_JOIN);
       execution.waitForSignal();
 
       ExecutionImpl concurrentRoot = execution.getParent();
       List<ExecutionImpl> joinedExecutions = getJoinedExecutions(concurrentRoot, activity);
-      
+
       if (isComplete(execution, joinedExecutions)) {
         endExecutions(joinedExecutions);
         // if multiplicity was used
@@ -105,7 +104,7 @@
         }
         outgoingExecution.take(transition);
       }
-      
+
     } else {
       throw new JbpmException("invalid execution state");
     }
@@ -155,9 +154,9 @@
     return -1;
   }
 
-  public void setLockMode(LockMode lockMode) {
+  public void setLockMode(String lockMode) {
     this.lockMode = lockMode;
-  }  
+  }
   public void setMultiplicity(Expression multiplicity) {
     this.multiplicity = multiplicity;
   }

Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JoinBinding.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JoinBinding.java	2010-08-15 15:14:11 UTC (rev 6595)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JoinBinding.java	2010-08-16 00:05:49 UTC (rev 6596)
@@ -21,9 +21,10 @@
  */
 package org.jbpm.jpdl.internal.activity;
 
-import org.hibernate.LockMode;
 import org.jbpm.jpdl.internal.xml.JpdlParser;
 import org.jbpm.pvm.internal.el.Expression;
+import org.jbpm.pvm.internal.env.EnvironmentImpl;
+import org.jbpm.pvm.internal.session.DbSession;
 import org.jbpm.pvm.internal.xml.Parse;
 import org.w3c.dom.Element;
 
@@ -32,9 +33,9 @@
  * @author Tom Baeyens
  */
 public class JoinBinding extends JpdlBinding {
-  
+
   private static final String MULTIPLICITY = "multiplicity";
-  
+
   private static final String LOCKMODE = "lockmode";
 
   public JoinBinding() {
@@ -43,7 +44,7 @@
 
   public Object parseJpdl(Element element, Parse parse, JpdlParser parser) {
     JoinActivity joinActivity = new JoinActivity();
-                            
+
     if (element.hasAttribute(MULTIPLICITY)) {
       String multiplicityText = element.getAttribute(MULTIPLICITY);
       Expression expression = Expression.create(multiplicityText, Expression.LANGUAGE_UEL_VALUE);
@@ -51,12 +52,12 @@
     }
 
     if (element.hasAttribute(LOCKMODE)) {
+      DbSession dbSession = EnvironmentImpl.getFromCurrent(DbSession.class);
       String lockModeText = element.getAttribute(LOCKMODE);
-      LockMode lockMode = LockMode.parse(lockModeText.toUpperCase());
-      if (lockMode==null) {
+      if (!dbSession.isValidLockModeType(lockModeText)) {
         parse.addProblem(lockModeText + " is not a valid lock mode", element);
       } else {
-        joinActivity.setLockMode(lockMode);
+        joinActivity.setLockMode(lockModeText);
       }
     }
 

Modified: jbpm4/trunk/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/Jpdl3ConverterReaderTest.java
===================================================================
--- jbpm4/trunk/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/Jpdl3ConverterReaderTest.java	2010-08-15 15:14:11 UTC (rev 6595)
+++ jbpm4/trunk/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/Jpdl3ConverterReaderTest.java	2010-08-16 00:05:49 UTC (rev 6596)
@@ -40,169 +40,176 @@
  *
  */
 public class Jpdl3ConverterReaderTest {
-	@Test
-	public void testSimpleProcesss() throws Exception {
-		testConvert("simple.xml");
-	}
+    @Test
+    public void testSimpleProcesss() throws Exception {
+        testConvert("simple.xml");
+    }
 
-	@Test
-	public void testBusinessTrip() throws Exception {
-		setUpEnviroment();
-		testConvert("businesstrip.xml");
-	}
+    @Test
+    public void testBusinessTrip() throws Exception {
+        setUpEnviroment();
+        testConvert("businesstrip.xml");
+    }
 
-	@Test
-	public void testAssignment() throws Exception {
-		testConvert("assignment.xml");
-	}
+    @Test
+    public void testAssignment() throws Exception {
+        testConvert("assignment.xml");
+    }
 
-	@Test
-	public void testEvent() throws Exception {
-		setUpEnviroment();
-		testConvert("process-event.xml");
-	}
+    @Test
+    public void testEvent() throws Exception {
+        setUpEnviroment();
+        testConvert("process-event.xml");
+    }
 
-	@Test
-	public void testDescision() throws Exception {
-		testConvert("testDecision.xml");
-	}
+    @Test
+    public void testDescision() throws Exception {
+        testConvert("testDecision.xml");
+    }
 
-	@Test
-	public void testProcessState() throws Exception {
-		Document convertedDoc = convert("process-state.xml");
-		Element ele = convertedDoc.getRootElement();
-		String subProcessKey = ele.element("sub-process").attributeValue("sub-process-key");
-		Assert.assertEquals("interview", subProcessKey);
-		validate(convertedDoc);
-		
-	}
+    @Test
+    public void testProcessState() throws Exception {
+        Document convertedDoc = convert("process-state.xml");
+        Element ele = convertedDoc.getRootElement();
+        String subProcessKey = ele.element("sub-process").attributeValue("sub-process-key");
+        Assert.assertEquals("interview", subProcessKey);
+        validate(convertedDoc);
 
-	@Test
-	public void testScript() throws Exception {
-		setUpEnviroment();
-		Document doc = convert("script.xml");
-		Element stateEle = doc.getRootElement().element("state");
-		Assert.assertEquals("async", stateEle.attributeValue("continue"));
-		validate(doc);
-	}
+    }
 
-	@Test
-	// Unsupported exception handler conversion test
-	public void testExceptionHandler() throws Exception {
-		InputStream inputStream = getClass().getClassLoader()
-				.getResourceAsStream("exception-handler.xml");
-		// Convert to process file to jpdl4
-		InputSource ins = new InputSource(inputStream);
-		Jpdl3Converter converter = new Jpdl3Converter(ins);
-		Document doc = converter.readAndConvert();
-		Assert.assertEquals(converter.problems.size(), 2);
-		Assert.assertTrue(converter.problems.get(0).toString().indexOf("[WARNING] Unsupported exception handler conversion for element") > -1);
-		Assert.assertTrue(converter.problems.get(1).toString().indexOf("[WARNING] Unsupported exception handler conversion for element") > -1);
-	}
+    @Test
+    public void testScript() throws Exception {
+        setUpEnviroment();
+        Document doc = convert("script.xml");
+        Element stateEle = doc.getRootElement().element("state");
+        Assert.assertEquals("async", stateEle.attributeValue("continue"));
+        validate(doc);
+    }
 
-	@Test
-	public void testSuperStateAndMailNode() throws Exception {
-		InputStream inputStream = getClass().getClassLoader()
-				.getResourceAsStream("superstate-mail.xml");
-		// Convert to process file to jpdl4
-		InputSource ins = new InputSource(inputStream);
-		Jpdl3Converter converter = new Jpdl3Converter(ins);		
-		Document doc = converter.readAndConvert();
-		validate(doc);		
-	}
-	
-	@Test
-	public void testTransitionResolved() {
-		InputStream inputStream = getClass().getClassLoader()
-				.getResourceAsStream("test-transition-resolve.xml");
-		// Convert to process file to jpdl4
-		InputSource ins = new InputSource(inputStream);
-		Jpdl3Converter converter = new Jpdl3Converter(ins);
-		Document doc = converter.readAndConvert();
-		Assert.assertEquals(converter.problems.size(), 2);
-		for (org.jbpm.jpdl.internal.convert.problem.Problem pb : converter.problems) {
-			System.out.println(pb);
-		}
-		Assert.assertTrue(converter.problems.get(0).toString().startsWith(
-		"[WARNING] transition to='first2'"));
+    @Test
+    // Unsupported exception handler conversion test
+    public void testExceptionHandler() throws Exception {
+        InputStream inputStream = getClass().getClassLoader()
+                .getResourceAsStream("exception-handler.xml");
+        // Convert to process file to jpdl4
+        InputSource ins = new InputSource(inputStream);
+        Jpdl3Converter converter = new Jpdl3Converter(ins);
+        Document doc = converter.readAndConvert();
+        Assert.assertEquals(converter.problems.size(), 2);
+        Assert.assertTrue(converter.problems.get(0).toString().indexOf("[WARNING] Unsupported exception handler conversion for element") > -1);
+        Assert.assertTrue(converter.problems.get(1).toString().indexOf("[WARNING] Unsupported exception handler conversion for element") > -1);
+    }
+
+    @Test
+    public void testSuperStateAndMailNode() throws Exception {
+        InputStream inputStream = getClass().getClassLoader()
+                .getResourceAsStream("superstate-mail.xml");
+        // Convert to process file to jpdl4
+        InputSource ins = new InputSource(inputStream);
+        Jpdl3Converter converter = new Jpdl3Converter(ins);
+        Document doc = converter.readAndConvert();
+        validate(doc);
+    }
+
+    @Test
+    public void testTransitionResolved() {
+        InputStream inputStream = getClass().getClassLoader()
+                .getResourceAsStream("test-transition-resolve.xml");
+        // Convert to process file to jpdl4
+        InputSource ins = new InputSource(inputStream);
+        Jpdl3Converter converter = new Jpdl3Converter(ins);
+        Document doc = converter.readAndConvert();
+        Assert.assertEquals(converter.problems.size(), 2);
+        for (org.jbpm.jpdl.internal.convert.problem.Problem pb : converter.problems) {
+            System.out.println(pb);
+        }
+        Assert.assertTrue(converter.problems.get(0).toString().startsWith(
+        "[WARNING] transition to='first2'"));
         Assert.assertTrue(converter.problems.get(1).toString().startsWith(
-		"[WARNING] transition to='end2'"));
-		
-	}
+        "[WARNING] transition to='end2'"));
 
-	@Test
-	public void testTimer() throws Exception {
-		String xml = convert("timer.xml").asXML();
-		List<Problem> problems = new JpdlParser().createParse().setString(xml)
-				.execute().getProblems();
-		Assert.assertEquals(2, problems.size());
-		Assert.assertTrue(problems.get(0).getMsg().startsWith(
-				"unrecognized event listener"));
-		Assert.assertTrue(problems.get(1).getMsg().startsWith(
-				"unrecognized event listener"));
-	}
-	
-	@Test
-	public void testMailNode() throws Exception {
-		setUpEnviroment();
-		String xml = convert("mail-node.xml").asXML();
-		List<Problem> problems = new JpdlParser().createParse().setString(xml)
-				.execute().getProblems();
+    }
+
+    @Test
+    public void testTimer() throws Exception {
+        String xml = convert("timer.xml").asXML();
+        List<Problem> problems = new JpdlParser().createParse().setString(xml)
+                .execute().getProblems();
+        Assert.assertEquals(2, problems.size());
+        Assert.assertTrue(problems.get(0).getMsg().startsWith(
+                "unrecognized event listener"));
+        Assert.assertTrue(problems.get(1).getMsg().startsWith(
+                "unrecognized event listener"));
+    }
+
+    @Test
+    public void testMailNode() throws Exception {
+        setUpEnviroment();
+        String xml = convert("mail-node.xml").asXML();
+        List<Problem> problems = new JpdlParser().createParse().setString(xml)
+                .execute().getProblems();
         Assert.assertEquals(0, problems.size());
-		
-	}
-	
-	
-	
-	private void testConvert(String resourcefile) throws Exception {
-		Document doc = convert(resourcefile);
-		validate(doc);	
-	}
-	
-	
-	private Document convert(String resouceFile) throws Exception {
-		InputStream inputStream = getClass().getClassLoader().getResourceAsStream(resouceFile);
-		// Convert to process file to jpdl4
-		InputSource ins = new InputSource(inputStream);
-		Jpdl3Converter converter = new Jpdl3Converter(ins);
-		Document doc = converter.readAndConvert();
-		//System.out.println(doc.asXML());
-		return doc;
-	}
-	
-	private void validate(Document convertedDoc) throws Exception {
-	  System.out.println(convertedDoc.asXML());
-		List<Problem> problems = new JpdlParser().createParse().setString(convertedDoc.asXML()).execute().getProblems();
-		Assert.assertEquals(problems.toString(), 0, problems.size());
-	}
-	
-	private void setUpEnviroment() throws Exception {
-		EnvironmentFactory environmentFactory = ProcessEngineImpl
-				.parseXmlString("<jbpm-configuration>"
-						+ "  <process-engine-context>"
-						+ "    <script-manager default-expression-language='juel'"
-						+ "                    default-script-language='juel'>"
-						+ "      <script-language name='juel' factory='com.sun.script.juel.JuelScriptEngineFactory' />"
-						+ "    </script-manager>"
-						
-						+ "    <mail-template name='my-template'> "
-						+ "       <to addresses='${addressee}' />"
-						+ "           <subject>rectify ${newspaper}</subject>"
-						+ "           <text>${newspaper} ${date} ${details}</text>"
-						+ "    </mail-template>"
-						+ "    <mail-template name='task-notification'> "
-						+ "       <to addresses='${addressee}' />"
-						+ "           <subject>rectify ${newspaper}</subject>"
-						+ "           <text>${newspaper} ${date} ${details}</text>"
-						+ "    </mail-template>"
-						+ "     <mail-template name='task-reminder'> "
+
+    }
+
+
+
+    private void testConvert(String resourcefile) throws Exception {
+        Document doc = convert(resourcefile);
+        validate(doc);
+    }
+
+
+    private Document convert(String resouceFile) throws Exception {
+        InputStream inputStream = getClass().getClassLoader().getResourceAsStream(resouceFile);
+        // Convert to process file to jpdl4
+        InputSource ins = new InputSource(inputStream);
+        Jpdl3Converter converter = new Jpdl3Converter(ins);
+        Document doc = converter.readAndConvert();
+        //System.out.println(doc.asXML());
+        return doc;
+    }
+
+    private void validate(Document convertedDoc) throws Exception {
+      System.out.println(convertedDoc.asXML());
+      List<Problem> problems = new JpdlParser().createParse().setString(convertedDoc.asXML()).execute().getProblems();
+      Assert.assertEquals(problems.toString(), 0, problems.size());
+    }
+
+    private void setUpEnviroment() throws Exception {
+        EnvironmentFactory environmentFactory = ProcessEngineImpl
+          .parseXmlString("<jbpm-configuration>"
+                        + "  <process-engine-context>"
+                        + "    <script-manager default-expression-language='juel'"
+                        + "                    default-script-language='juel'>"
+                        + "      <script-language name='juel' factory='com.sun.script.juel.JuelScriptEngineFactory' />"
+                        + "    </script-manager>"
+                        + "    <mail-template name='my-template'> "
                         + "       <to addresses='${addressee}' />"
+                        + "           <subject>rectify ${newspaper}</subject>"
+                        + "           <text>${newspaper} ${date} ${details}</text>"
+                        + "    </mail-template>"
+                        + "    <mail-template name='task-notification'> "
+                        + "       <to addresses='${addressee}' />"
+                        + "           <subject>rectify ${newspaper}</subject>"
+                        + "           <text>${newspaper} ${date} ${details}</text>"
+                        + "    </mail-template>"
+                        + "     <mail-template name='task-reminder'> "
+                        + "       <to addresses='${addressee}' />"
                         + "           <subject>Task reminder</subject>"
                         + "           <text>Task reminder</text>"
                         + "    </mail-template>"
-                        
-						+ "  </process-engine-context> </jbpm-configuration>");
+                        + "    <hibernate-configuration>"
+                        + "      <cfg resource='jbpm.hibernate.cfg.xml' />"
+                        + "    </hibernate-configuration>"
+                        + "    <hibernate-session-factory />"
+                        + "  </process-engine-context>"
+                        + "  <transaction-context>"
+                        + "    <db-session/>"
+                        + "    <hibernate-session />"
+                        + "  </transaction-context>"
+                        + "</jbpm-configuration>");
 
-		environmentFactory.openEnvironment();
-	}
+        environmentFactory.openEnvironment();
+    }
 }

Added: jbpm4/trunk/modules/migration/src/test/resources/jbpm.hibernate.cfg.xml
===================================================================
--- jbpm4/trunk/modules/migration/src/test/resources/jbpm.hibernate.cfg.xml	                        (rev 0)
+++ jbpm4/trunk/modules/migration/src/test/resources/jbpm.hibernate.cfg.xml	2010-08-16 00:05:49 UTC (rev 6596)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!DOCTYPE hibernate-configuration PUBLIC
+          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
+          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
+
+<hibernate-configuration>
+  <session-factory>
+  
+     <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
+     <property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
+     <property name="hibernate.connection.url">jdbc:hsqldb:mem:.</property>
+     <property name="hibernate.connection.username">sa</property>
+     <property name="hibernate.connection.password"></property>
+     <property name="hibernate.hbm2ddl.auto">create-drop</property>
+     <property name="hibernate.format_sql">true</property>
+     
+     <mapping resource="jbpm.repository.hbm.xml" />
+     <mapping resource="jbpm.execution.hbm.xml" />
+     <mapping resource="jbpm.history.hbm.xml" />
+     <mapping resource="jbpm.task.hbm.xml" />
+     <mapping resource="jbpm.identity.hbm.xml" />
+     
+  </session-factory>
+</hibernate-configuration>

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/DbSessionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/DbSessionImpl.java	2010-08-15 15:14:11 UTC (rev 6595)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/DbSessionImpl.java	2010-08-16 00:05:49 UTC (rev 6596)
@@ -125,6 +125,16 @@
     return historyHibernateMetadata != null;
   }
 
+  // lock mode
+  public boolean isValidLockModeType(String lockModeType) {
+    LockMode lockMode = LockMode.parse(lockModeType.toUpperCase());
+    return lockMode != null;
+  }
+
+  public void lock(Object entity, String lockModeType) {
+    session.lock(entity, LockMode.parse(lockModeType.toUpperCase()));
+  }
+
   // process execution queries ////////////////////////////////////////////////
 
   public ClientExecution findExecutionById(String executionId) {

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/DbSession.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/DbSession.java	2010-08-15 15:14:11 UTC (rev 6595)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/DbSession.java	2010-08-16 00:05:49 UTC (rev 6596)
@@ -45,11 +45,15 @@
 
   void save(Object entity);
   void update(Object entity);
-  
+
   <T> T get(Class<T> entityClass, Object primaryKey);
   void delete(Object entity);
   void flush();
 
+  // lock mode
+  boolean isValidLockModeType(String lockModeType);
+  void lock(Object entity, String lockModeType);
+
   // process execution queries ////////////////////////////////////////////////
 
   /** create a process instance query */
@@ -65,28 +69,28 @@
 
   List<HistoryComment> findCommentsByTaskId(String taskId);
 
-  /** the execution uniquely identified by the given executionKey. 
-   * this method doesn't 'see' suspended executions. */ 
+  /** the execution uniquely identified by the given executionKey.
+   * this method doesn't 'see' suspended executions. */
   ClientExecution findExecutionById(String executionId);
 
-  /** the process instance uniquely identified by the given executionKey. */ 
+  /** the process instance uniquely identified by the given executionKey. */
   ClientExecution findProcessInstanceById(String processInstanceId);
-  
+
   List<String> findProcessInstanceIds(String processDefinitionId);
-  
-  /** deletes the history information for all process instances for 
+
+  /** deletes the history information for all process instances for
    * the given process definition */
   void deleteProcessDefinitionHistory(String processDefinitionId);
 
   /** delete the process instance and optionally deletes the history. */
   void deleteProcessInstance(String processInstanceId, boolean deleteHistory);
-  
+
   void cascadeExecutionSuspend(ExecutionImpl execution);
 
   void cascadeExecutionResume(ExecutionImpl execution);
-  
+
   // task methods /////////////////////////////////////////////////////////////
-  
+
   TaskImpl createTask();
 
   TaskImpl findTaskByExecution(Execution execution);
@@ -101,7 +105,7 @@
 
   /** the first job to finish among non-owned jobs or null if none */
   public JobImpl findFirstDueJob();
-  
+
   /** returns a list of start process timers for the given process definition */
   public List<StartProcessTimer> findStartProcessTimers(String processDefinitionId);
 }



More information about the jbpm-commits mailing list