[jbpm-commits] JBoss JBPM SVN: r4276 - jbpm4/trunk/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb.
do-not-reply at jboss.org
do-not-reply at jboss.org
Wed Mar 18 06:53:23 EDT 2009
Author: heiko.braun at jboss.com
Date: 2009-03-18 06:53:23 -0400 (Wed, 18 Mar 2009)
New Revision: 4276
Modified:
jbpm4/trunk/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/CommandExecutorSLSB.java
Log:
CommandExecutorSLSB references java:/ProcessEngine
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-03-18 10:52:14 UTC (rev 4275)
+++ jbpm4/trunk/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/CommandExecutorSLSB.java 2009-03-18 10:53:23 UTC (rev 4276)
@@ -29,18 +29,22 @@
import javax.naming.InitialContext;
import javax.naming.NameNotFoundException;
import javax.naming.NamingException;
+import javax.transaction.UserTransaction;
+import javax.transaction.SystemException;
import org.jbpm.Configuration;
+import org.jbpm.ProcessEngine;
import org.jbpm.cmd.Command;
+import org.jbpm.cmd.CommandService;
import org.jbpm.env.Environment;
import org.jbpm.env.EnvironmentFactory;
import org.jbpm.internal.log.Log;
/**
* Stateless session command executor.
- *
+ *
* <h3>Configuration</h3>
- *
+ *
* <p>
* In order to provide commands an environment in which to run, the command
* executor builds an environment factory from a configuration file loaded as a
@@ -48,9 +52,9 @@
* specifies the name of the resource to access; the default is
* <code>jbpm.cfg.xml</code>.
* </p>
- *
+ *
* <h3>JNDI-bound environment factory</h3>
- *
+ *
* <p>
* To avoid parsing the configuration file multiple times, the command executor
* attempts to bind the environment factory to the name specified in the
@@ -59,7 +63,7 @@
* command executor will still work; however, each instance will build its own
* environment factory from the configuration.
* </p>
- *
+ *
* @author Jim Rigsbee
* @author Tom Baeyens
* @author Alejandro Guizar
@@ -73,7 +77,9 @@
private static final Log log = Log.getLog(CommandExecutorSLSB.class.getName());
- public <T> T execute(Command<T> command) {
+ private ProcessEngine processEngine = null;
+
+ /*public <T> T execute(Command<T> command) {
Environment environment = environmentFactory.openEnvironment();
try {
log.debug("executing command " + command);
@@ -88,6 +94,12 @@
finally {
environment.close();
}
+ } */
+
+ public <T> T execute(Command<T> command) {
+ log.info("Execute " + command);
+ CommandService cmd = processEngine.get(CommandService.class);
+ return cmd.execute(command);
}
public void setSessionContext(SessionContext sessionContext) {
@@ -99,7 +111,18 @@
* are passed in the execute method.
*/
public void ejbCreate() throws CreateException {
- String envFactoryName = "java:jbpm/EnvironmentFactory";
+
+ try
+ {
+ InitialContext ctx = new InitialContext();
+ this.processEngine = (ProcessEngine)ctx.lookup("java:/ProcessEngine");
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Failed to lookup process engine");
+ }
+
+ /*String envFactoryName = "java:jbpm/EnvironmentFactory";
try {
Context initial = new InitialContext();
@@ -119,12 +142,7 @@
environmentFactory = (EnvironmentFactory) namedObject;
}
else {
- /*
- * the bound object could be an instance of an environment factory
- * loaded in another (older?) deployment; because each deployment sets
- * up its own class loader, the existing instance could be perceived
- * as not being an environment factory
- */
+
if (namedObject == null || isInstance(EnvironmentFactory.class.getName(), namedObject)) {
log.debug("object bound to "
+ envFactoryName
@@ -153,6 +171,9 @@
log.error("could not create command executor", e);
throw new CreateException("jndi access failed");
}
+
+ */
+
}
private static boolean isInstance(String className, Object object) {
@@ -190,6 +211,7 @@
}
public void ejbRemove() {
+ processEngine = null;
environmentFactory = null;
sessionContext = null;
}
More information about the jbpm-commits
mailing list