[jbpm-commits] JBoss JBPM SVN: r4197 - in jbpm4/branches/hbraun/modules: integration/jboss5/src/main/java/org/jbpm/integration/jboss5 and 1 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Mon Mar 9 13:16:37 EDT 2009


Author: heiko.braun at jboss.com
Date: 2009-03-09 13:16:37 -0400 (Mon, 09 Mar 2009)
New Revision: 4197

Added:
   jbpm4/branches/hbraun/modules/integration/spi/src/main/java/org/jbpm/integration/spi/ProcessEngineObjectFactory.java
   jbpm4/branches/hbraun/modules/integration/spi/src/main/java/org/jbpm/integration/spi/ProcessEngineReference.java
Modified:
   jbpm4/branches/hbraun/modules/enterprise/src/main/java/org/jbpm/enterprise/mgmt/ProcessManagementImpl.java
   jbpm4/branches/hbraun/modules/integration/jboss5/src/main/java/org/jbpm/integration/jboss5/JBPMServiceImpl.java
Log:
Added JNDI binding

Modified: jbpm4/branches/hbraun/modules/enterprise/src/main/java/org/jbpm/enterprise/mgmt/ProcessManagementImpl.java
===================================================================
--- jbpm4/branches/hbraun/modules/enterprise/src/main/java/org/jbpm/enterprise/mgmt/ProcessManagementImpl.java	2009-03-09 16:32:17 UTC (rev 4196)
+++ jbpm4/branches/hbraun/modules/enterprise/src/main/java/org/jbpm/enterprise/mgmt/ProcessManagementImpl.java	2009-03-09 17:16:37 UTC (rev 4197)
@@ -30,6 +30,8 @@
 import org.jbpm.model.OpenProcessDefinition;
 import org.jbpm.model.OpenExecution;
 
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
 import java.util.*;
 import java.io.InputStream;
 
@@ -42,8 +44,19 @@
 
   public ProcessManagementImpl()
   {
-    JBPMService jbpmService = JBPMServiceLocator.locateService();
-    this.processEngine = jbpmService.getProcessEngine(); 
+    //JBPMService jbpmService = JBPMServiceLocator.locateService();
+    //this.processEngine = jbpmService.getProcessEngine();
+
+      try
+      {
+        InitialContext ctx = new InitialContext();
+        this.processEngine = (ProcessEngine)ctx.lookup("java:/jbpm4");
+      }
+      catch (Exception e)
+      {
+        throw new RuntimeException("Failed to lookup process engine");
+      }
+
   }
 
   public List<ProcessDefinitionRef> getProcessDefinitions()

Modified: jbpm4/branches/hbraun/modules/integration/jboss5/src/main/java/org/jbpm/integration/jboss5/JBPMServiceImpl.java
===================================================================
--- jbpm4/branches/hbraun/modules/integration/jboss5/src/main/java/org/jbpm/integration/jboss5/JBPMServiceImpl.java	2009-03-09 16:32:17 UTC (rev 4196)
+++ jbpm4/branches/hbraun/modules/integration/jboss5/src/main/java/org/jbpm/integration/jboss5/JBPMServiceImpl.java	2009-03-09 17:16:37 UTC (rev 4197)
@@ -22,10 +22,13 @@
 package org.jbpm.integration.jboss5;
 
 import org.jbpm.integration.spi.JBPMService;
+import org.jbpm.integration.spi.ProcessEngineReference;
 import org.jbpm.ProcessEngine;
 import org.jbpm.Configuration;
 import org.jbpm.internal.log.Log;
 
+import javax.naming.InitialContext;
+
 /**
  * @author Heiko.Braun <heiko.braun at jboss.com>
  */
@@ -33,12 +36,25 @@
 {
   private static final Log log = Log.getLog(JBPMServiceImpl.class.getName());
 
+  private final static String DEFAULT_JNDI_NAME = "java:/jbpm4";
+  
   private ProcessEngine processEngine;
 
   public void start()
   {
     this.processEngine = new Configuration().buildProcessEngine();
-    log.info("JBPMService started: " + this.processEngine);
+
+    try
+    {
+      InitialContext ctx = new InitialContext();
+      ctx.bind(DEFAULT_JNDI_NAME, new ProcessEngineReference("default", this.processEngine));
+      log.info("ProcessEngine bound to: " + DEFAULT_JNDI_NAME);
+    }
+    catch (Exception e)
+    {
+      throw new RuntimeException("Failed to create JBPMService", e);
+    }
+
   }
 
   public void stop()
@@ -51,4 +67,5 @@
   {
     return this.processEngine;
   }
+
 }

Added: jbpm4/branches/hbraun/modules/integration/spi/src/main/java/org/jbpm/integration/spi/ProcessEngineObjectFactory.java
===================================================================
--- jbpm4/branches/hbraun/modules/integration/spi/src/main/java/org/jbpm/integration/spi/ProcessEngineObjectFactory.java	                        (rev 0)
+++ jbpm4/branches/hbraun/modules/integration/spi/src/main/java/org/jbpm/integration/spi/ProcessEngineObjectFactory.java	2009-03-09 17:16:37 UTC (rev 4197)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.integration.spi;
+
+import org.jbpm.ProcessEngine;
+
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.RefAddr;
+import javax.naming.Reference;
+import javax.naming.spi.ObjectFactory;
+import java.util.Hashtable;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public class ProcessEngineObjectFactory implements ObjectFactory
+{
+  public Object getObjectInstance(
+      Object obj, Name name,
+      Context nameCtx, Hashtable<?, ?> environment) throws Exception
+  {
+    if (obj instanceof Reference) {
+      Reference ref = (Reference)obj;
+      if (ref.getClassName().equals(ProcessEngine.class.getName())) {
+        RefAddr engineName = ref.get(ProcessEngineReference.ENGINE_NAME); // currently not used
+        return JBPMServiceLocator.locateService().getProcessEngine();
+      }
+    }
+
+    return null;
+  }
+}

Added: jbpm4/branches/hbraun/modules/integration/spi/src/main/java/org/jbpm/integration/spi/ProcessEngineReference.java
===================================================================
--- jbpm4/branches/hbraun/modules/integration/spi/src/main/java/org/jbpm/integration/spi/ProcessEngineReference.java	                        (rev 0)
+++ jbpm4/branches/hbraun/modules/integration/spi/src/main/java/org/jbpm/integration/spi/ProcessEngineReference.java	2009-03-09 17:16:37 UTC (rev 4197)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.integration.spi;
+
+import org.jbpm.ProcessEngine;
+
+import javax.naming.Referenceable;
+import javax.naming.Reference;
+import javax.naming.NamingException;
+import javax.naming.StringRefAddr;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public class ProcessEngineReference implements Referenceable
+{
+  private String name;
+  private transient ProcessEngine processEngine;
+  public static final String ENGINE_NAME = "process.engine.name";
+
+  public ProcessEngineReference(String name, ProcessEngine processEngine)
+  {
+    this.name = name;
+    this.processEngine = processEngine;
+  }
+
+  public Reference getReference() throws NamingException
+  {
+    return new Reference(
+        ProcessEngine.class.getName(),
+        new StringRefAddr(ProcessEngineReference.ENGINE_NAME, this.name), 
+        ProcessEngineObjectFactory.class.getName(),
+        null
+    );
+  }
+}




More information about the jbpm-commits mailing list