[jbpm-commits] JBoss JBPM SVN: r5667 - in jbpm4/trunk/modules: enterprise/src/main/java/org/jbpm/enterprise/internal/ejb and 16 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Thu Sep 24 08:05:40 EDT 2009


Author: tom.baeyens at jboss.com
Date: 2009-09-24 08:05:39 -0400 (Thu, 24 Sep 2009)
New Revision: 5667

Added:
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/Policy.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/SkipInterceptor.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/SkipInterceptorBinding.java
Removed:
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/IdGeneratorBinding.java
   jbpm4/trunk/modules/pvm/src/main/resources/jbpm.tx.cmd.cfg.xml
   jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatestringid/jbpm.tx.hibernate.cfg.xml
Modified:
   jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/chxx-ExecutionModes.xml
   jbpm4/trunk/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/CommandExecutorSLSB.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/ProcessEngineImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CommandService.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/ExecuteJobCmd.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/DatabaseDbidGenerator.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/EnvironmentInterceptor.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/jta/JtaTransactionInterceptor.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/EnvironmentInterceptorBinding.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ExecutionServiceBinding.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HistoryServiceBinding.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/IdentityServiceBinding.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/JtaTransactionInterceptorBinding.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ManagementServiceBinding.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/RepositoryServiceBinding.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TaskServiceBinding.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/EnvironmentInterceptorDescriptor.java
   jbpm4/trunk/modules/pvm/src/main/resources/jbpm.default.cfg.xml
   jbpm4/trunk/modules/pvm/src/main/resources/jbpm.tx.hibernate.cfg.xml
   jbpm4/trunk/modules/pvm/src/main/resources/jbpm.tx.jta.cfg.xml
   jbpm4/trunk/modules/pvm/src/main/resources/jbpm.wire.bindings.xml
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/id/DbidGeneratorTest.java
   jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/tx/BasicTransactionTest.java
   jbpm4/trunk/modules/pvm/src/test/resources/logging.properties
   jbpm4/trunk/modules/pvm/src/test/resources/org/jbpm/test/spring/jbpm.cfg.xml
   jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatelongid/jbpm.cfg.xml
   jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatestringid/jbpm.cfg.xml
   jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/repocache/jbpm_alternative.cfg.xml
   jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/deploy/DeploymentResourceTest.java
Log:
JBPM-2526 split up the command executor into a requires and a requiresNew policy flavour

Modified: jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/chxx-ExecutionModes.xml
===================================================================
--- jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/chxx-ExecutionModes.xml	2009-09-21 16:10:41 UTC (rev 5666)
+++ jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/chxx-ExecutionModes.xml	2009-09-24 12:05:39 UTC (rev 5667)
@@ -140,7 +140,6 @@
     
     <hibernate-session-factory />
     
-    <id-generator />
     <types resource="jbpm.pvm.types.xml" />
     <job-executor auto-start="false" />
   
@@ -224,7 +223,7 @@
     </para>
     <programlisting>assertEquals("evaluate", execution.getActivityName());</programlisting>
     <para>Also very important is the generated id that can be obtained.  The default 
-    <literal>id-generator</literal> will use the process definition id and the 
+    DatabaseIdComposer will use the process definition id and the 
     given key to make a unique id for the process execution like this:</para>
     <programlisting>assertEquals("loan:1/request7836", execution.getId());</programlisting>
     <para>That id must be when providing the subsequent external triggers to the 

Modified: jbpm4/trunk/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/CommandExecutorSLSB.java
===================================================================
--- jbpm4/trunk/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/CommandExecutorSLSB.java	2009-09-21 16:10:41 UTC (rev 5666)
+++ jbpm4/trunk/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/CommandExecutorSLSB.java	2009-09-24 12:05:39 UTC (rev 5667)
@@ -22,22 +22,18 @@
 package org.jbpm.enterprise.internal.ejb;
 
 import javax.ejb.CreateException;
-import javax.ejb.EJBException;
 import javax.ejb.SessionBean;
 import javax.ejb.SessionContext;
 import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NameNotFoundException;
 import javax.naming.NamingException;
-import javax.transaction.UserTransaction;
-import javax.transaction.SystemException;
 
 import org.jbpm.api.Configuration;
 import org.jbpm.api.ProcessEngine;
 import org.jbpm.api.cmd.Command;
 import org.jbpm.internal.log.Log;
 import org.jbpm.pvm.internal.cmd.CommandService;
-import org.jbpm.pvm.internal.env.EnvironmentImpl;
 import org.jbpm.pvm.internal.env.EnvironmentFactory;
 
 /**
@@ -70,14 +66,12 @@
  */
 public class CommandExecutorSLSB implements SessionBean {
 
-  private SessionContext sessionContext;
-  private EnvironmentFactory environmentFactory;
-
   private static final long serialVersionUID = 1L;
 
   private static final Log log = Log.getLog(CommandExecutorSLSB.class.getName());
 
-  private ProcessEngine processEngine = null;
+  protected ProcessEngine processEngine = null;
+  protected SessionContext sessionContext;
 
   /*public <T> T execute(Command<T> command) {
     EnvironmentImpl environment = environmentFactory.openEnvironment();
@@ -98,7 +92,7 @@
 
   public <T> T execute(Command<T> command) {
     log.info("Execute " + command);
-    CommandService cmd = processEngine.get(CommandService.class);
+    CommandService cmd = (CommandService) processEngine.get(CommandService.NAME_TX_REQUIRED_COMMAND_SERVICE);
     return cmd.execute(command);
   }
 
@@ -212,7 +206,6 @@
 
   public void ejbRemove() {
     processEngine = null;
-    environmentFactory = null;
     sessionContext = null;
   }
 

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/ProcessEngineImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/ProcessEngineImpl.java	2009-09-21 16:10:41 UTC (rev 5666)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/ProcessEngineImpl.java	2009-09-24 12:05:39 UTC (rev 5667)
@@ -132,7 +132,7 @@
       }
     }
     processEngineWireContext.create();
-    userCommandService = (CommandService) processEngineWireContext.get("user.command.service");
+    userCommandService = (CommandService) processEngineWireContext.get(CommandService.NAME_TX_REQUIRED_COMMAND_SERVICE);
     return this;
   }
 
@@ -324,15 +324,6 @@
   }
 
   public <T> T execute(Command<T> command) {
-    EnvironmentImpl environment = openEnvironment();
-    try {
-      return userCommandService.execute(command);
-    } catch (RuntimeException e) {
-      throw e;
-    } catch (Exception e) {
-      throw new JbpmException(e.getMessage(), e);
-    } finally {
-      environment.close();
-    }
+    return userCommandService.execute(command);
   }
 }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CommandService.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CommandService.java	2009-09-21 16:10:41 UTC (rev 5666)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CommandService.java	2009-09-24 12:05:39 UTC (rev 5667)
@@ -15,6 +15,9 @@
  * command.
  */
 public interface CommandService {
+  
+  String NAME_TX_REQUIRED_COMMAND_SERVICE = "txRequiredCommandService";
+  String NAME_NEW_TX_REQUIRED_COMMAND_SERVICE = "newTxRequiredCommandService";
 
   /**
    * @throws JbpmException if command throws an exception.

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/ExecuteJobCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/ExecuteJobCmd.java	2009-09-21 16:10:41 UTC (rev 5666)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/ExecuteJobCmd.java	2009-09-24 12:05:39 UTC (rev 5667)
@@ -108,7 +108,7 @@
     Transaction transaction = environment.get(Transaction.class);
     // transaction.setRollbackOnly();
 
-    CommandService commandService = (CommandService) environment.get(CommandService.class);
+    CommandService commandService = (CommandService) environment.get(CommandService.NAME_NEW_TX_REQUIRED_COMMAND_SERVICE);
     JobExceptionHandler jobExceptionHandler = new JobExceptionHandler(job.getDbid(), exception, commandService);
     transaction.registerSynchronization(jobExceptionHandler);
   }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/DatabaseDbidGenerator.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/DatabaseDbidGenerator.java	2009-09-21 16:10:41 UTC (rev 5666)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/DatabaseDbidGenerator.java	2009-09-24 12:05:39 UTC (rev 5667)
@@ -52,6 +52,8 @@
     if (lastId<nextId) {
       // acquire a next block of ids
 
+      log.debug("last id "+lastId+" was consumed.  acquiring new block...");
+
       // reset the id block
       lastId = -2;
       nextId = -1;

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/EnvironmentInterceptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/EnvironmentInterceptor.java	2009-09-21 16:10:41 UTC (rev 5666)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/EnvironmentInterceptor.java	2009-09-24 12:05:39 UTC (rev 5667)
@@ -22,11 +22,8 @@
 package org.jbpm.pvm.internal.svc;
 
 import org.jbpm.api.cmd.Command;
-import org.jbpm.pvm.internal.env.Context;
+import org.jbpm.pvm.internal.env.EnvironmentFactory;
 import org.jbpm.pvm.internal.env.EnvironmentImpl;
-import org.jbpm.pvm.internal.env.EnvironmentFactory;
-import org.jbpm.pvm.internal.wire.WireContext;
-import org.jbpm.pvm.internal.wire.descriptor.ProvidedObjectDescriptor;
 
 
 /** sets up an environment around the execution of the command.
@@ -34,15 +31,25 @@
  * @author Tom Baeyens
  */
 public class EnvironmentInterceptor extends Interceptor {
-
+  
   protected EnvironmentFactory environmentFactory;
+  protected Policy policy = Policy.REQUIRES;
 
   public <T> T execute(Command<T> command) {
-    EnvironmentImpl environment;
-    
-    environment = environmentFactory.openEnvironment();
+    if ( isEnvironmentCreationNecessary() ) {
+      return executeInNewEnvironment(command);
+    } else {
+      return executeInExistingEnvironment(command);
+    }
+  }
+
+  protected <T> T executeInExistingEnvironment(Command<T> command) {
+    return next.execute(command);
+  }
+
+  protected <T> T executeInNewEnvironment(Command<T> command) {
+    EnvironmentImpl environment = environmentFactory.openEnvironment();
     try {
-      // injectEnvironmentObjects(environment);
       return next.execute(command);
       
     } finally {
@@ -50,9 +57,9 @@
     }
   }
 
-  protected void injectEnvironmentObjects(EnvironmentImpl environment) {
-    WireContext transactionContext = (WireContext) environment.getContext(Context.CONTEXTNAME_TRANSACTION);
-    transactionContext.getWireDefinition().addDescriptor(new ProvidedObjectDescriptor());
+  protected boolean isEnvironmentCreationNecessary() {
+    return policy==Policy.REQUIRES_NEW 
+           || (EnvironmentImpl.getCurrent()==null);
   }
 
   public EnvironmentFactory getEnvironmentFactory() {
@@ -61,4 +68,10 @@
   public void setEnvironmentFactory(EnvironmentFactory environmentFactory) {
     this.environmentFactory = environmentFactory;
   }
+  public Policy getPolicy() {
+    return policy;
+  }
+  public void setPolicy(Policy policy) {
+    this.policy = policy;
+  }
 }

Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/Policy.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/Policy.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/Policy.java	2009-09-24 12:05:39 UTC (rev 5667)
@@ -0,0 +1,27 @@
+/*
+ * 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.svc;
+
+public enum Policy {
+  REQUIRES,
+  REQUIRES_NEW
+}
\ No newline at end of file


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

Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/SkipInterceptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/SkipInterceptor.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/SkipInterceptor.java	2009-09-24 12:05:39 UTC (rev 5667)
@@ -0,0 +1,46 @@
+/*
+ * 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.svc;
+
+import org.jbpm.api.cmd.Command;
+import org.jbpm.pvm.internal.env.EnvironmentImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class SkipInterceptor extends Interceptor {
+  
+  static DefaultCommandService defaultCommandService = new DefaultCommandService();
+
+  public <T> T execute(Command<T> command) {
+    EnvironmentImpl environment = EnvironmentImpl.getCurrent();
+    // if there is an environment active
+    if (environment!=null) {
+      // skip the rest of the interceptor stack and just execute the command
+      return defaultCommandService.execute(command);
+    }
+
+    return next.execute(command);
+  }
+
+}


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

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/jta/JtaTransactionInterceptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/jta/JtaTransactionInterceptor.java	2009-09-21 16:10:41 UTC (rev 5666)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/jta/JtaTransactionInterceptor.java	2009-09-24 12:05:39 UTC (rev 5667)
@@ -22,7 +22,6 @@
 package org.jbpm.pvm.internal.tx.jta;
 
 import javax.transaction.Status;
-import javax.transaction.SystemException;
 import javax.transaction.Transaction;
 import javax.transaction.UserTransaction;
 
@@ -31,6 +30,7 @@
 import org.jbpm.internal.log.Log;
 import org.jbpm.pvm.internal.env.EnvironmentImpl;
 import org.jbpm.pvm.internal.svc.Interceptor;
+import org.jbpm.pvm.internal.svc.Policy;
 
 
 /**
@@ -39,6 +39,8 @@
 public class JtaTransactionInterceptor extends Interceptor {
   
   private static Log log = Log.getLog(JtaTransactionInterceptor.class.getName());
+  
+  protected Policy policy = Policy.REQUIRES;
 
   public <T> T execute(Command<T> command) {
     JtaTransaction jtaTransaction = EnvironmentImpl.getFromCurrent(JtaTransaction.class);
@@ -47,7 +49,9 @@
 
     int status = JtaTransaction.getUserTransactionStatus(userTransaction);
     
-    if (status == Status.STATUS_ACTIVE) {
+    if ( (status == Status.STATUS_ACTIVE)
+         && (! (policy==Policy.REQUIRES_NEW))
+       ) {
       return executeInExistingTx(command);
     }
     
@@ -67,7 +71,10 @@
 
   protected <T> T executeInNewTx(Command<T> command, JtaTransaction jtaTransaction, int status) {
     Transaction suspendedTransaction = null;
-    if ((status == Status.STATUS_COMMITTED) || (status == Status.STATUS_ROLLEDBACK)) {
+    if ( (status == Status.STATUS_ACTIVE)
+         || (status == Status.STATUS_COMMITTED) 
+         || (status == Status.STATUS_ROLLEDBACK)
+       ) {
       suspendedTransaction = jtaTransaction.suspend();
     }
     
@@ -93,5 +100,8 @@
     
     return (T) returnValue;
   }
-  
+
+  public void setPolicy(Policy policy) {
+    this.policy = policy;
+  }
 }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/EnvironmentInterceptorBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/EnvironmentInterceptorBinding.java	2009-09-21 16:10:41 UTC (rev 5666)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/EnvironmentInterceptorBinding.java	2009-09-24 12:05:39 UTC (rev 5667)
@@ -23,6 +23,7 @@
 
 import org.jbpm.pvm.internal.cfg.ProcessEngineImpl;
 import org.jbpm.pvm.internal.env.EnvironmentFactory;
+import org.jbpm.pvm.internal.svc.Policy;
 import org.jbpm.pvm.internal.wire.descriptor.EnvironmentInterceptorDescriptor;
 import org.jbpm.pvm.internal.xml.Parse;
 import org.jbpm.pvm.internal.xml.Parser;
@@ -38,8 +39,18 @@
   }
 
   public Object parse(Element element, Parse parse, Parser parser) {
+    EnvironmentInterceptorDescriptor environmentInterceptorDescriptor = new EnvironmentInterceptorDescriptor();
+
     EnvironmentFactory environmentFactory = (EnvironmentFactory) parse.findObject(ProcessEngineImpl.class);
-    return new EnvironmentInterceptorDescriptor(environmentFactory);
+    environmentInterceptorDescriptor.setEnvironmentFactory(environmentFactory);
+    
+    if ( element.hasAttribute("policy")
+         && ("requiresNew".equals(element.getAttribute("policy")))
+       ) {
+      environmentInterceptorDescriptor.setPolicy(Policy.REQUIRES_NEW);
+    }
+    
+    return environmentInterceptorDescriptor;
   }
 
 }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ExecutionServiceBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ExecutionServiceBinding.java	2009-09-21 16:10:41 UTC (rev 5666)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ExecutionServiceBinding.java	2009-09-24 12:05:39 UTC (rev 5667)
@@ -23,8 +23,8 @@
 
 import org.jbpm.pvm.internal.cmd.CommandService;
 import org.jbpm.pvm.internal.svc.ExecutionServiceImpl;
-import org.jbpm.pvm.internal.wire.descriptor.ContextTypeRefDescriptor;
 import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ReferenceDescriptor;
 import org.jbpm.pvm.internal.xml.Parse;
 import org.jbpm.pvm.internal.xml.Parser;
 import org.w3c.dom.Element;
@@ -41,7 +41,7 @@
 
   public Object parse(Element element, Parse parse, Parser parser) {
     ObjectDescriptor descriptor = new ObjectDescriptor(ExecutionServiceImpl.class);
-    descriptor.addInjection("commandService", new ContextTypeRefDescriptor(CommandService.class));
+    descriptor.addInjection("commandService", new ReferenceDescriptor(CommandService.NAME_TX_REQUIRED_COMMAND_SERVICE));
     return descriptor;
   }
 }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HistoryServiceBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HistoryServiceBinding.java	2009-09-21 16:10:41 UTC (rev 5666)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HistoryServiceBinding.java	2009-09-24 12:05:39 UTC (rev 5667)
@@ -23,8 +23,8 @@
 
 import org.jbpm.pvm.internal.cmd.CommandService;
 import org.jbpm.pvm.internal.svc.HistoryServiceImpl;
-import org.jbpm.pvm.internal.wire.descriptor.ContextTypeRefDescriptor;
 import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ReferenceDescriptor;
 import org.jbpm.pvm.internal.xml.Parse;
 import org.jbpm.pvm.internal.xml.Parser;
 import org.w3c.dom.Element;
@@ -41,7 +41,7 @@
 
   public Object parse(Element element, Parse parse, Parser parser) {
     ObjectDescriptor descriptor = new ObjectDescriptor(HistoryServiceImpl.class);
-    descriptor.addInjection("commandService", new ContextTypeRefDescriptor(CommandService.class));
+    descriptor.addInjection("commandService", new ReferenceDescriptor(CommandService.NAME_TX_REQUIRED_COMMAND_SERVICE));
     return descriptor;
   }
 }

Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/IdGeneratorBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/IdGeneratorBinding.java	2009-09-21 16:10:41 UTC (rev 5666)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/IdGeneratorBinding.java	2009-09-24 12:05:39 UTC (rev 5667)
@@ -1,44 +0,0 @@
-/*
- * 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.wire.binding;
-
-import org.jbpm.pvm.internal.id.DatabaseIdComposer;
-import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
-import org.jbpm.pvm.internal.xml.Parse;
-import org.jbpm.pvm.internal.xml.Parser;
-import org.w3c.dom.Element;
-
-
-/**
- * @author Tom Baeyens
- */
-public class IdGeneratorBinding extends WireDescriptorBinding {
-
-  public IdGeneratorBinding() {
-    super("id-generator");
-  }
-
-  public Object parse(Element element, Parse parse, Parser parser) {
-    return new ObjectDescriptor(DatabaseIdComposer.class);
-  }
-
-}

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/IdentityServiceBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/IdentityServiceBinding.java	2009-09-21 16:10:41 UTC (rev 5666)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/IdentityServiceBinding.java	2009-09-24 12:05:39 UTC (rev 5667)
@@ -23,8 +23,8 @@
 
 import org.jbpm.pvm.internal.cmd.CommandService;
 import org.jbpm.pvm.internal.svc.IdentityServiceImpl;
-import org.jbpm.pvm.internal.wire.descriptor.ContextTypeRefDescriptor;
 import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ReferenceDescriptor;
 import org.jbpm.pvm.internal.xml.Parse;
 import org.jbpm.pvm.internal.xml.Parser;
 import org.w3c.dom.Element;
@@ -41,7 +41,7 @@
 
   public Object parse(Element element, Parse parse, Parser parser) {
     ObjectDescriptor descriptor = new ObjectDescriptor(IdentityServiceImpl.class);
-    descriptor.addInjection("commandService", new ContextTypeRefDescriptor(CommandService.class));
+    descriptor.addInjection("commandService", new ReferenceDescriptor(CommandService.NAME_TX_REQUIRED_COMMAND_SERVICE));
     return descriptor;
   }
 

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/JtaTransactionInterceptorBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/JtaTransactionInterceptorBinding.java	2009-09-21 16:10:41 UTC (rev 5666)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/JtaTransactionInterceptorBinding.java	2009-09-24 12:05:39 UTC (rev 5667)
@@ -21,8 +21,9 @@
  */
 package org.jbpm.pvm.internal.wire.binding;
 
+import org.jbpm.pvm.internal.svc.Policy;
 import org.jbpm.pvm.internal.tx.jta.JtaTransactionInterceptor;
-import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ProvidedObjectDescriptor;
 import org.jbpm.pvm.internal.xml.Parse;
 import org.jbpm.pvm.internal.xml.Parser;
 import org.w3c.dom.Element;
@@ -32,6 +33,7 @@
  * {@link JtaTransactionInterceptor} object.
  * 
  * @author Alejandro Guizar
+ * @author Tom Baeyens
  */
 public class JtaTransactionInterceptorBinding extends WireInterceptorBinding {
 
@@ -40,7 +42,15 @@
   }
 
   public Object parse(Element element, Parse parse, Parser parser) {
-    return new ObjectDescriptor(JtaTransactionInterceptor.class);
+    JtaTransactionInterceptor jtaTransactionInterceptor = new JtaTransactionInterceptor();
+    
+    if ( element.hasAttribute("policy")
+         && ("requiresNew".equals(element.getAttribute("policy")))
+       ) {
+      jtaTransactionInterceptor.setPolicy(Policy.REQUIRES_NEW);
+    }
+    
+    return new ProvidedObjectDescriptor(jtaTransactionInterceptor);
   }
 
 }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ManagementServiceBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ManagementServiceBinding.java	2009-09-21 16:10:41 UTC (rev 5666)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ManagementServiceBinding.java	2009-09-24 12:05:39 UTC (rev 5667)
@@ -25,6 +25,7 @@
 import org.jbpm.pvm.internal.svc.ManagementServiceImpl;
 import org.jbpm.pvm.internal.wire.descriptor.ContextTypeRefDescriptor;
 import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ReferenceDescriptor;
 import org.jbpm.pvm.internal.xml.Parse;
 import org.jbpm.pvm.internal.xml.Parser;
 import org.w3c.dom.Element;
@@ -41,7 +42,7 @@
 
   public Object parse(Element element, Parse parse, Parser parser) {
     ObjectDescriptor descriptor = new ObjectDescriptor(ManagementServiceImpl.class);
-    descriptor.addInjection("commandService", new ContextTypeRefDescriptor(CommandService.class));
+    descriptor.addInjection("commandService", new ReferenceDescriptor(CommandService.NAME_TX_REQUIRED_COMMAND_SERVICE));
     return descriptor;
   }
 }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/RepositoryServiceBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/RepositoryServiceBinding.java	2009-09-21 16:10:41 UTC (rev 5666)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/RepositoryServiceBinding.java	2009-09-24 12:05:39 UTC (rev 5667)
@@ -21,8 +21,10 @@
  */
 package org.jbpm.pvm.internal.wire.binding;
 
+import org.jbpm.pvm.internal.cmd.CommandService;
 import org.jbpm.pvm.internal.repository.RepositoryServiceImpl;
 import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ReferenceDescriptor;
 import org.jbpm.pvm.internal.xml.Parse;
 import org.jbpm.pvm.internal.xml.Parser;
 import org.w3c.dom.Element;
@@ -38,8 +40,8 @@
   }
 
   public Object parse(Element element, Parse parse, Parser parser) {
-    ObjectDescriptor objectDescriptor = new ObjectDescriptor(RepositoryServiceImpl.class);
-    objectDescriptor.setAutoWireEnabled(true);
-    return objectDescriptor;
+    ObjectDescriptor descriptor = new ObjectDescriptor(RepositoryServiceImpl.class);
+    descriptor.addInjection("commandService", new ReferenceDescriptor(CommandService.NAME_TX_REQUIRED_COMMAND_SERVICE));
+    return descriptor;
   }
 }

Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/SkipInterceptorBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/SkipInterceptorBinding.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/SkipInterceptorBinding.java	2009-09-24 12:05:39 UTC (rev 5667)
@@ -0,0 +1,44 @@
+/*
+ * 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.wire.binding;
+
+import org.jbpm.pvm.internal.svc.SkipInterceptor;
+import org.jbpm.pvm.internal.wire.descriptor.ProvidedObjectDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class SkipInterceptorBinding extends WireInterceptorBinding {
+
+  public SkipInterceptorBinding() {
+    super("skip-interceptor");
+  }
+
+  public Object parse(Element element, Parse parse, Parser parser) {
+    return new ProvidedObjectDescriptor(new SkipInterceptor());
+  }
+
+}


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

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TaskServiceBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TaskServiceBinding.java	2009-09-21 16:10:41 UTC (rev 5666)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TaskServiceBinding.java	2009-09-24 12:05:39 UTC (rev 5667)
@@ -23,8 +23,8 @@
 
 import org.jbpm.pvm.internal.cmd.CommandService;
 import org.jbpm.pvm.internal.svc.TaskServiceImpl;
-import org.jbpm.pvm.internal.wire.descriptor.ContextTypeRefDescriptor;
 import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ReferenceDescriptor;
 import org.jbpm.pvm.internal.xml.Parse;
 import org.jbpm.pvm.internal.xml.Parser;
 import org.w3c.dom.Element;
@@ -40,7 +40,7 @@
 
   public Object parse(Element element, Parse parse, Parser parser) {
     ObjectDescriptor descriptor = new ObjectDescriptor(TaskServiceImpl.class);
-    descriptor.addInjection("commandService", new ContextTypeRefDescriptor(CommandService.class));
+    descriptor.addInjection("commandService", new ReferenceDescriptor(CommandService.NAME_TX_REQUIRED_COMMAND_SERVICE));
     return descriptor;
   }
 

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/EnvironmentInterceptorDescriptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/EnvironmentInterceptorDescriptor.java	2009-09-21 16:10:41 UTC (rev 5666)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/EnvironmentInterceptorDescriptor.java	2009-09-24 12:05:39 UTC (rev 5667)
@@ -23,6 +23,7 @@
 
 import org.jbpm.pvm.internal.env.EnvironmentFactory;
 import org.jbpm.pvm.internal.svc.EnvironmentInterceptor;
+import org.jbpm.pvm.internal.svc.Policy;
 import org.jbpm.pvm.internal.wire.WireContext;
 
 /**
@@ -32,15 +33,23 @@
 
   private static final long serialVersionUID = 1L;
   
-  EnvironmentFactory environmentFactory;
+  protected EnvironmentFactory environmentFactory;
+  protected Policy policy;
   
-  public EnvironmentInterceptorDescriptor(EnvironmentFactory environmentFactory) {
-    this.environmentFactory = environmentFactory;
-  }
-
   public Object construct(WireContext wireContext) {
     EnvironmentInterceptor environmentInterceptor = new EnvironmentInterceptor();
     environmentInterceptor.setEnvironmentFactory(environmentFactory);
+    if (policy!=null) {
+      environmentInterceptor.setPolicy(policy);
+    }
     return environmentInterceptor;
   }
+
+  public void setEnvironmentFactory(EnvironmentFactory environmentFactory) {
+    this.environmentFactory = environmentFactory;
+  }
+  
+  public void setPolicy(Policy policy) {
+    this.policy = policy;
+  }
 }

Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.default.cfg.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.default.cfg.xml	2009-09-21 16:10:41 UTC (rev 5666)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.default.cfg.xml	2009-09-24 12:05:39 UTC (rev 5667)
@@ -19,7 +19,7 @@
     <hibernate-session-factory />
     
     <object class="org.jbpm.pvm.internal.id.DatabaseDbidGenerator" init="eager">
-      <field name="commandService"><ref type="org.jbpm.pvm.internal.cmd.CommandService" /></field>
+      <field name="commandService"><ref object="newTxRequiredCommandService" /></field>
       <invoke method="initialize" />
     </object>
 
@@ -30,7 +30,6 @@
       <script-language name="juel" factory="org.jbpm.pvm.internal.script.JuelScriptEngineFactory" />
     </script-manager>
     
-    <id-generator />
     <types resource="jbpm.variable.types.xml" />
 
     <address-resolver />

Deleted: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.tx.cmd.cfg.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.tx.cmd.cfg.xml	2009-09-21 16:10:41 UTC (rev 5666)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.tx.cmd.cfg.xml	2009-09-24 12:05:39 UTC (rev 5667)
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<jbpm-configuration>
-
-  <process-engine-context>
-    <command-service name="user.command.service">
-      <retry-interceptor />
-      <environment-interceptor />
-      <standard-transaction-interceptor />
-    </command-service>
-    <command-service />
-  </process-engine-context>
-
-  <transaction-context>
-    <transaction />
-    <hibernate-session />
-  </transaction-context>
-
-</jbpm-configuration>

Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.tx.hibernate.cfg.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.tx.hibernate.cfg.xml	2009-09-21 16:10:41 UTC (rev 5666)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.tx.hibernate.cfg.xml	2009-09-24 12:05:39 UTC (rev 5667)
@@ -3,11 +3,20 @@
 <jbpm-configuration>
 
   <process-engine-context>
-    <command-service>
+
+    <command-service name="txRequiredCommandService">
+      <skip-interceptor />
       <retry-interceptor />
       <environment-interceptor />
       <standard-transaction-interceptor />
     </command-service>
+
+    <command-service name="newTxRequiredCommandService">
+      <retry-interceptor />
+      <environment-interceptor policy="requiresNew" />
+      <standard-transaction-interceptor />
+    </command-service>
+
   </process-engine-context>
 
   <transaction-context>

Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.tx.jta.cfg.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.tx.jta.cfg.xml	2009-09-21 16:10:41 UTC (rev 5666)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.tx.jta.cfg.xml	2009-09-24 12:05:39 UTC (rev 5667)
@@ -3,11 +3,22 @@
 <jbpm-configuration>
 
   <process-engine-context>
-    <command-service>
+    <command-service name="txRequiredCommandService">
+      <skip-interceptor />
       <environment-interceptor />
       <retry-interceptor type="jta" />
       <jta-transaction-interceptor />
     </command-service>
+
+    <command-service name="newTxRequiredCommandService">
+      <environment-interceptor policy="requiresNew" />
+      <retry-interceptor type="jta" />
+      <jta-transaction-interceptor policy="requiresNew" />
+    </command-service>
+
+    <command-service>
+      <environment-interceptor />
+    </command-service>
   </process-engine-context>
 
   <transaction-context>

Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.wire.bindings.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.wire.bindings.xml	2009-09-21 16:10:41 UTC (rev 5666)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.wire.bindings.xml	2009-09-24 12:05:39 UTC (rev 5667)
@@ -37,7 +37,7 @@
   <binding class="org.jbpm.pvm.internal.wire.binding.JobTestHelperBinding" />
   <binding class="org.jbpm.pvm.internal.wire.binding.ScriptManagerBinding" />
   <binding class="org.jbpm.pvm.internal.wire.binding.BusinessCalendarBinding" />
-  <binding class="org.jbpm.pvm.internal.wire.binding.IdGeneratorBinding" />
+  <binding class="org.jbpm.pvm.internal.wire.binding.IdComposerBinding" />
   <binding class="org.jbpm.pvm.internal.wire.binding.MailTemplateBinding" />
   <binding class="org.jbpm.pvm.internal.wire.binding.AddressResolverBinding"/>
   <!-- hibernate bindings -->
@@ -72,6 +72,7 @@
   <binding class="org.jbpm.pvm.internal.wire.binding.DeployerManagerBinding" />
 
   <!-- interceptors -->
+  <binding class="org.jbpm.pvm.internal.wire.binding.SkipInterceptorBinding" />
   <binding class="org.jbpm.pvm.internal.wire.binding.EnvironmentInterceptorBinding" />
   <binding class="org.jbpm.pvm.internal.wire.binding.AuthorizationInterceptorBinding" />
   <binding class="org.jbpm.pvm.internal.wire.binding.RetryInterceptorBinding" />

Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/id/DbidGeneratorTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/id/DbidGeneratorTest.java	2009-09-21 16:10:41 UTC (rev 5666)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/id/DbidGeneratorTest.java	2009-09-24 12:05:39 UTC (rev 5667)
@@ -39,11 +39,10 @@
   
   private static Log log = Log.getLog(DbidGeneratorTest.class.getName());
   
-  public void testIdGenerator() {
+  public void testDbidGenerator() {
     ProcessEngine processEngine = new Configuration().buildProcessEngine();
     
-    CommandService commandService = processEngine.get(CommandService.class);
-    commandService.execute(new Command<Void>() {
+    processEngine.execute(new Command<Void>() {
       private static final long serialVersionUID = 1L;
       public Void execute(Environment environment) throws Exception {
         Session session = environment.get(Session.class);
@@ -56,12 +55,66 @@
     });
     
     DbidGenerator dbidGenerator = processEngine.get(DbidGenerator.class);
-    
     for (int i=1; i<10020; i++) {
       assertEquals(i, dbidGenerator.getNextId());
       if ((i%1000) == 0) {
         log.debug("just got dbid "+i+"...");
       }
     }
+
+    try {
+      processEngine.execute(new Command<Void>() {
+        private static final long serialVersionUID = 1L;
+        public Void execute(Environment environment) throws Exception {
+          DbidGenerator dbidGenerator = environment.get(DbidGenerator.class);
+          for (int i=10020; i<20020; i++) {
+            assertEquals(i, dbidGenerator.getNextId());
+            if ((i%1000) == 0) {
+              log.debug("just got dbid "+i+"...");
+            }
+          }
+          // the following 'user' exception will cause the user transaction to 
+          // roll back, but the dbid-transaction should have been committed
+          throw new RuntimeException("user exception");
+        }
+      });
+    } catch (RuntimeException e) {
+      assertEquals("user exception", e.getMessage());
+    }
+
+    for (int i=20020; i<30020; i++) {
+      assertEquals(i, dbidGenerator.getNextId());
+      if ((i%1000) == 0) {
+        log.debug("just got dbid "+i+"...");
+      }
+    }
+
+    CommandService serviceCommandService = (CommandService) processEngine.get(CommandService.NAME_TX_REQUIRED_COMMAND_SERVICE);
+    try {
+      serviceCommandService.execute(new Command<Void>() {
+        private static final long serialVersionUID = 1L;
+        public Void execute(Environment environment) throws Exception {
+          DbidGenerator dbidGenerator = environment.get(DbidGenerator.class);
+          for (int i=30020; i<40020; i++) {
+            assertEquals(i, dbidGenerator.getNextId());
+            if ((i%1000) == 0) {
+              log.debug("just got dbid "+i+"...");
+            }
+          }
+          // the following 'user' exception will cause the user transaction to 
+          // roll back, but the dbid-transaction should have been committed
+          throw new RuntimeException("user exception");
+        }
+      });
+    } catch (RuntimeException e) {
+      assertEquals("user exception", e.getMessage());
+    }
+
+    for (int i=40020; i<50020; i++) {
+      assertEquals(i, dbidGenerator.getNextId());
+      if ((i%1000) == 0) {
+        log.debug("just got dbid "+i+"...");
+      }
+    }
   }
 }

Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/tx/BasicTransactionTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/tx/BasicTransactionTest.java	2009-09-21 16:10:41 UTC (rev 5666)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/tx/BasicTransactionTest.java	2009-09-24 12:05:39 UTC (rev 5667)
@@ -45,7 +45,7 @@
   
   public void setUp() throws Exception {
     super.setUp();
-    commandService = processEngine.get(CommandService.class);
+    commandService = (CommandService) processEngine.get(CommandService.NAME_TX_REQUIRED_COMMAND_SERVICE);
   }
 
   public void testCommit() {

Modified: jbpm4/trunk/modules/pvm/src/test/resources/logging.properties
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/resources/logging.properties	2009-09-21 16:10:41 UTC (rev 5666)
+++ jbpm4/trunk/modules/pvm/src/test/resources/logging.properties	2009-09-24 12:05:39 UTC (rev 5667)
@@ -1,11 +1,11 @@
 handlers= java.util.logging.ConsoleHandler
 redirect.commons.logging = enabled
 
-java.util.logging.ConsoleHandler.level = FINE
+java.util.logging.ConsoleHandler.level = FINEST
 java.util.logging.ConsoleHandler.formatter = org.jbpm.internal.log.LogFormatter
 
-org.jbpm.level=FINE
-# org.jbpm.pvm.internal.tx.level=FINE
+org.jbpm.level=FINEST
+# org.jbpm.pvm.internal.tx.level=FINEST
 # org.jbpm.pvm.internal.wire.level=FINE
 # org.jbpm.pvm.internal.util.level=FINE
 

Modified: jbpm4/trunk/modules/pvm/src/test/resources/org/jbpm/test/spring/jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/resources/org/jbpm/test/spring/jbpm.cfg.xml	2009-09-21 16:10:41 UTC (rev 5666)
+++ jbpm4/trunk/modules/pvm/src/test/resources/org/jbpm/test/spring/jbpm.cfg.xml	2009-09-24 12:05:39 UTC (rev 5667)
@@ -21,7 +21,13 @@
       <cfg resource="jbpm.hibernate.cfg.xml" />     
     </hibernate-configuration>
 
-    
+    <object class="org.jbpm.pvm.internal.id.DatabaseDbidGenerator" init="eager">
+      <field name="commandService"><ref object="newTxRequiredCommandService" /></field>
+      <invoke method="initialize" />
+    </object>
+
+    <object class="org.jbpm.pvm.internal.id.DatabaseIdComposer" init="eager" />
+
     <script-manager default-expression-language="juel"
                     default-script-language="juel">
         <script-language name="juel" factory="org.jbpm.pvm.internal.script.JuelScriptEngineFactory" />
@@ -31,7 +37,6 @@
 
     <job-executor auto-start="false" />
 
-    <id-generator />
     <types resource="jbpm.variable.types.xml" />
 
     <business-calendar>

Modified: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatelongid/jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatelongid/jbpm.cfg.xml	2009-09-21 16:10:41 UTC (rev 5666)
+++ jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatelongid/jbpm.cfg.xml	2009-09-24 12:05:39 UTC (rev 5667)
@@ -3,7 +3,7 @@
 <jbpm-configuration>
 
   <import resource="jbpm.businesscalendar.cfg.xml" />
-  <import resource="jbpm.tx.cmd.cfg.xml" />
+  <import resource="jbpm.tx.hibernate.cfg.xml" />
   <import resource="jbpm.jpdl.cfg.xml" />
   <import resource="jbpm.identity.cfg.xml" />
 
@@ -24,16 +24,17 @@
     <hibernate-session-factory />
 
     <object class="org.jbpm.pvm.internal.id.DatabaseDbidGenerator" init="eager">
-      <field name="commandService"><ref type="org.jbpm.pvm.internal.cmd.CommandService" /></field>
+      <field name="commandService"><ref object="newTxRequiredCommandService" /></field>
       <invoke method="initialize" />
     </object>
 
+    <object class="org.jbpm.pvm.internal.id.DatabaseIdComposer" init="eager" />
+
     <script-manager default-expression-language="juel"
                     default-script-language="juel">
       <script-language name="juel" factory="org.jbpm.pvm.internal.script.JuelScriptEngineFactory" />
     </script-manager>
     
-    <id-generator />
     <types resource="jbpm.variable.types.xml" />
 
     <address-resolver />

Modified: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatestringid/jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatestringid/jbpm.cfg.xml	2009-09-21 16:10:41 UTC (rev 5666)
+++ jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatestringid/jbpm.cfg.xml	2009-09-24 12:05:39 UTC (rev 5667)
@@ -3,7 +3,7 @@
 <jbpm-configuration>
 
   <import resource="jbpm.businesscalendar.cfg.xml" />
-  <import resource="org/jbpm/test/hibernatestringid/jbpm.tx.hibernate.cfg.xml" />
+  <import resource="jbpm.tx.hibernate.cfg.xml" />
   <import resource="jbpm.jpdl.cfg.xml" />
   <import resource="jbpm.identity.cfg.xml" />
 
@@ -24,16 +24,17 @@
     <hibernate-session-factory />
 
     <object class="org.jbpm.pvm.internal.id.DatabaseDbidGenerator" init="eager">
-      <field name="commandService"><ref type="org.jbpm.pvm.internal.cmd.CommandService" /></field>
+      <field name="commandService"><ref object="newTxRequiredCommandService" /></field>
       <invoke method="initialize" />
     </object>
 
+    <object class="org.jbpm.pvm.internal.id.DatabaseIdComposer" init="eager" />
+
     <script-manager default-expression-language="juel"
                     default-script-language="juel">
       <script-language name="juel" factory="org.jbpm.pvm.internal.script.JuelScriptEngineFactory" />
     </script-manager>
     
-    <id-generator />
     <types resource="jbpm.variable.types.xml" />
 
     <address-resolver />

Deleted: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatestringid/jbpm.tx.hibernate.cfg.xml
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatestringid/jbpm.tx.hibernate.cfg.xml	2009-09-21 16:10:41 UTC (rev 5666)
+++ jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatestringid/jbpm.tx.hibernate.cfg.xml	2009-09-24 12:05:39 UTC (rev 5667)
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<jbpm-configuration>
-
-  <process-engine-context>
-    <command-service>
-      <retry-interceptor />
-      <environment-interceptor />
-    </command-service>
-  </process-engine-context>
-
-  <transaction-context>
-    <hibernate-session current="true" />
-  </transaction-context>
-
-</jbpm-configuration>

Modified: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/repocache/jbpm_alternative.cfg.xml
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/repocache/jbpm_alternative.cfg.xml	2009-09-21 16:10:41 UTC (rev 5666)
+++ jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/repocache/jbpm_alternative.cfg.xml	2009-09-24 12:05:39 UTC (rev 5667)
@@ -23,13 +23,19 @@
 
     <hibernate-session-factory />
 
+    <object class="org.jbpm.pvm.internal.id.DatabaseDbidGenerator" init="eager">
+      <field name="commandService"><ref object="newTxRequiredCommandService" /></field>
+      <invoke method="initialize" />
+    </object>
+
+    <object class="org.jbpm.pvm.internal.id.DatabaseIdComposer" init="eager" />
+
     <script-manager default-expression-language="juel"
       default-script-language="juel">
       <script-language name="juel"
         factory="org.jbpm.pvm.internal.script.JuelScriptEngineFactory" />
     </script-manager>
 
-    <id-generator />
     <types resource="jbpm.variable.types.xml" />
 
     <address-resolver />

Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/deploy/DeploymentResourceTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/deploy/DeploymentResourceTest.java	2009-09-21 16:10:41 UTC (rev 5666)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/deploy/DeploymentResourceTest.java	2009-09-24 12:05:39 UTC (rev 5667)
@@ -26,6 +26,7 @@
 
 import java.io.FileInputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.util.zip.ZipInputStream;
 
 import org.jbpm.api.NewDeployment;
@@ -43,14 +44,13 @@
 
   
   public void testZippedResourceDeployment() {
-    FileInputStream fip = null;
+    InputStream inputStream = null;
     try {
+      inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("org/jbpm/test/deploy/process.zip");
+      ZipInputStream zipInputStream = new ZipInputStream(inputStream);
       
-      fip = new FileInputStream("src/test/resources/org/jbpm/test/deploy/process.zip");
-      ZipInputStream zis = new ZipInputStream(fip);
-      
       NewDeployment newDeployment = repositoryService.createDeployment();
-      newDeployment.addResourcesFromZipInputStream(zis);
+      newDeployment.addResourcesFromZipInputStream(zipInputStream);
       String deployId = newDeployment.deploy();
       
       ProcessDefinition procDef = repositoryService.createProcessDefinitionQuery()
@@ -60,12 +60,10 @@
       assertEquals("ImageTest", procDef.getName());
       repositoryService.deleteDeploymentCascade(deployId);
       
-    } catch (IOException e) {
-      fail(e.getMessage());
     } finally {
-      if (fip != null) {
+      if (inputStream != null) {
         try {
-          fip.close();
+          inputStream.close();
         } catch (IOException e) {
           fail(e.getMessage());
         }



More information about the jbpm-commits mailing list