[jbpm-commits] JBoss JBPM SVN: r5976 - in jbpm4/trunk/modules: distro/src/main/files/install/src/cfg/hibernate/spring and 4 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Thu Dec 17 05:44:53 EST 2009


Author: tom.baeyens at jboss.com
Date: 2009-12-17 05:44:53 -0500 (Thu, 17 Dec 2009)
New Revision: 5976

Added:
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/SpringCommandCallback.java
Modified:
   jbpm4/trunk/modules/distro/src/main/files/install/build.xml
   jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/hibernate/spring/hsqldb.inmem.hibernate.cfg.xml
   jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/spring/applicationContext.xml
   jbpm4/trunk/modules/pvm/pom.xml
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/SpringTransactionFactory.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/SpringTransactionInterceptor.java
   jbpm4/trunk/modules/test-db/pom.xml
Log:
JBPM-2631 spring transactions.  finally there.  phew.

Modified: jbpm4/trunk/modules/distro/src/main/files/install/build.xml
===================================================================
--- jbpm4/trunk/modules/distro/src/main/files/install/build.xml	2009-12-17 09:17:28 UTC (rev 5975)
+++ jbpm4/trunk/modules/distro/src/main/files/install/build.xml	2009-12-17 10:44:53 UTC (rev 5976)
@@ -200,7 +200,9 @@
   </target>
 	
 	<target name="internal.copy.spring.applicationContext" if="is.spring.environment">
-		<copy todir="${cfg.dest.dir}" overwrite="true" file="${install.src.dir}/cfg/spring/applicationContext.xml" />
+		<copy todir="${cfg.dest.dir}" overwrite="true" file="${install.src.dir}/cfg/spring/applicationContext.xml">
+      <filterset filtersfile="${jdbc.properties.dir}/${database}.properties" />
+    </copy>
 	</target>
 
   <!-- ### CREATE USER WEBAPP ########################################## -->

Modified: jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/hibernate/spring/hsqldb.inmem.hibernate.cfg.xml
===================================================================
--- jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/hibernate/spring/hsqldb.inmem.hibernate.cfg.xml	2009-12-17 09:17:28 UTC (rev 5975)
+++ jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/hibernate/spring/hsqldb.inmem.hibernate.cfg.xml	2009-12-17 10:44:53 UTC (rev 5976)
@@ -9,6 +9,7 @@
 
 		<property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
     <property name="current_session_context_class">thread</property>
+    <!-- property name="hibernate.transaction.factory_class">org.jbpm.pvm.internal.tx.SpringTransactionFactory</property -->
     <!-- property name="hibernate.transaction.factory_class">org.springframework.orm.hibernate3.SpringTransactionFactory</property -->
     <property name="hibernate.format_sql">true</property>
 

Modified: jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/spring/applicationContext.xml
===================================================================
--- jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/spring/applicationContext.xml	2009-12-17 09:17:28 UTC (rev 5975)
+++ jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/spring/applicationContext.xml	2009-12-17 10:44:53 UTC (rev 5976)
@@ -26,10 +26,10 @@
   </bean>
 
   <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
-    <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
-    <property name="url" value="jdbc:hsqldb:mem:." />
-    <property name="username" value="sa" />
-    <property name="password" value="" />
+    <property name="driverClassName" value="@jdbc.driver@" />
+    <property name="url" value="@jdbc.url@" />
+    <property name="username" value="@jdbc.username@" />
+    <property name="password" value="@jdbc.password@" />
   </bean>
 
 </beans>
\ No newline at end of file

Modified: jbpm4/trunk/modules/pvm/pom.xml
===================================================================
--- jbpm4/trunk/modules/pvm/pom.xml	2009-12-17 09:17:28 UTC (rev 5975)
+++ jbpm4/trunk/modules/pvm/pom.xml	2009-12-17 10:44:53 UTC (rev 5976)
@@ -187,6 +187,7 @@
         <configuration>
           <excludes>
             <exclude>**/*TestCase.java</exclude>
+            <exclude>org/jbpm/examples/bpmn/gateway/exclusive/ExclusiveGateway*</exclude>
           </excludes>
         </configuration>
       </plugin>

Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/SpringCommandCallback.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/SpringCommandCallback.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/SpringCommandCallback.java	2009-12-17 10:44:53 UTC (rev 5976)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.tx;
+
+import org.jbpm.api.cmd.Command;
+import org.jbpm.pvm.internal.cmd.CommandService;
+import org.jbpm.pvm.internal.env.EnvironmentImpl;
+import org.springframework.transaction.TransactionStatus;
+import org.springframework.transaction.support.TransactionCallback;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class SpringCommandCallback implements TransactionCallback {
+  
+  CommandService next;
+  Command<Object> command;
+
+  public SpringCommandCallback(CommandService next, Command command) {
+    this.next = next;
+    this.command = command;
+  }
+
+  public Object doInTransaction(TransactionStatus status) {
+    Object returnValue = next.execute(command);
+    
+    EnvironmentImpl
+        .getFromCurrent(SpringTransaction.class)
+        .flushDeserializedObjects();
+    
+    return returnValue;
+  }
+
+}


Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/SpringCommandCallback.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/SpringTransactionFactory.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/SpringTransactionFactory.java	2009-12-17 09:17:28 UTC (rev 5975)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/SpringTransactionFactory.java	2009-12-17 10:44:53 UTC (rev 5976)
@@ -67,9 +67,14 @@
 
 	public boolean isTransactionInProgress(
 			JDBCContext jdbcContext, Context transactionContext, Transaction transaction) {
+	  
+	  for (StackTraceElement stackTraceElement: new Exception().getStackTrace()) {
+	    if (stackTraceElement.getClassName().equals(SpringTransactionInterceptor.class.getName())) {
+	      return true;
+	    }
+	  }
 
-		return (transaction != null && transaction.isActive()) ||
-				TransactionSynchronizationManager.isActualTransactionActive();
+	  return (transaction != null && transaction.isActive());
 	}
 
 }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/SpringTransactionInterceptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/SpringTransactionInterceptor.java	2009-12-17 09:17:28 UTC (rev 5975)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/SpringTransactionInterceptor.java	2009-12-17 10:44:53 UTC (rev 5976)
@@ -31,6 +31,7 @@
 import org.springframework.transaction.TransactionStatus;
 import org.springframework.transaction.support.AbstractPlatformTransactionManager;
 import org.springframework.transaction.support.DefaultTransactionDefinition;
+import org.springframework.transaction.support.TransactionTemplate;
 
 /**
  * calls setRollbackOnly on the transaction in the environment in case an
@@ -43,35 +44,36 @@
   @SuppressWarnings("unused")
   private static final Log log = Log.getLog(SpringTransactionInterceptor.class.getName());
 
-  protected int springPropagationBehaviour = -1;
+  protected int springPropagationBehaviour = TransactionDefinition.PROPAGATION_REQUIRED;
   private String transactionManagerName;
 
   @SuppressWarnings("unchecked")
   public <T> T execute(Command<T> command) {
-    T returnValue = null;
+    AbstractPlatformTransactionManager platformTransactionManager = (AbstractPlatformTransactionManager) resolveTransactionManager();
+    TransactionTemplate template = new TransactionTemplate(platformTransactionManager);
+    template.setPropagationBehavior(springPropagationBehaviour);
+    return (T) template.execute(new SpringCommandCallback(next, command));
     
-    AbstractPlatformTransactionManager platformTransactionManager = (AbstractPlatformTransactionManager) resolveTransactionManager();
-    DefaultTransactionDefinition transactionDefinition = new DefaultTransactionDefinition(springPropagationBehaviour);
-    TransactionStatus transactionStatus = platformTransactionManager.getTransaction(transactionDefinition);
-    boolean completedSuccessfully = false;
-    try {
-      returnValue = next.execute(command);
-      
-      EnvironmentImpl
-          .getFromCurrent(SpringTransaction.class)
-          .flushDeserializedObjects();
-      
-      completedSuccessfully = true;
-
-    } finally {
-      if (completedSuccessfully) {
-        platformTransactionManager.commit(transactionStatus);
-      } else {
-        platformTransactionManager.rollback(transactionStatus);
-      }
-    }
-
-    return returnValue;
+//    TransactionStatus transactionStatus = platformTransactionManager.getTransaction(transactionDefinition);
+//    boolean completedSuccessfully = false;
+//    try {
+//      returnValue = next.execute(command);
+//      
+//      EnvironmentImpl
+//          .getFromCurrent(SpringTransaction.class)
+//          .flushDeserializedObjects();
+//      
+//      completedSuccessfully = true;
+//
+//    } finally {
+//      if (completedSuccessfully) {
+//        platformTransactionManager.commit(transactionStatus);
+//      } else {
+//        platformTransactionManager.rollback(transactionStatus);
+//      }
+//    }
+//
+//    return returnValue;
   }
 
   /**

Modified: jbpm4/trunk/modules/test-db/pom.xml
===================================================================
--- jbpm4/trunk/modules/test-db/pom.xml	2009-12-17 09:17:28 UTC (rev 5975)
+++ jbpm4/trunk/modules/test-db/pom.xml	2009-12-17 10:44:53 UTC (rev 5976)
@@ -169,6 +169,7 @@
                   <tasks>
                     <ant antfile="../distro/src/main/files/install/build.xml" target="create.cfg">
                       <property name="tx" value="spring.testsuite" />
+                      <property name="hibernate.connection.type" value="spring" />
                       <property name="database" value="hsqldb.inmem" />
                       <property name="mail.cfg" value="testsuite" />
                       <property name="cfg.dest.dir" value="target/test-classes" />
@@ -181,6 +182,17 @@
               </execution>
             </executions>
           </plugin>
+		      <plugin>
+		        <artifactId>maven-surefire-plugin</artifactId>
+		        <configuration>
+		          <failIfNoTests>false</failIfNoTests>
+		          <trimStackTrace>false</trimStackTrace>
+		          <redirectTestOutputToFile>true</redirectTestOutputToFile>
+		          <excludes>
+		            <exclude>org/jbpm/test/reporting/SQLStmtTest.java</exclude>
+		          </excludes>
+		        </configuration>
+		      </plugin>
         </plugins>
       </build>
     </profile>



More information about the jbpm-commits mailing list