[jbpm-commits] JBoss JBPM SVN: r2356 - in jbpm4/trunk/modules/api/src/main/java/org/jbpm/api: client and 1 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Sep 24 10:55:07 EDT 2008


Author: thomas.diesler at jboss.com
Date: 2008-09-24 10:55:07 -0400 (Wed, 24 Sep 2008)
New Revision: 2356

Added:
   jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/client/
   jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/client/ProcessEngine.java
   jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/test/
   jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/test/ArchiveDeployer.java
   jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/test/IntegrationTestHelper.java
   jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/test/IntegrationTestSetup.java
   jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/test/JBossArchiveDeployer.java
Log:
Move package to org.jbpm.api

Added: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/client/ProcessEngine.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/client/ProcessEngine.java	                        (rev 0)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/client/ProcessEngine.java	2008-09-24 14:55:07 UTC (rev 2356)
@@ -0,0 +1,77 @@
+/*
+ * 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.api.client;
+
+// $Id$
+
+/**
+ * The process engine is an agregator of various manger objects used by the BPM engine
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 18-Jun-2008
+ */
+public class ProcessEngine
+{
+  // Flag to indicate that the Engine is shutting down
+  private boolean prepareForShutdown;
+
+  // Hide public constructor
+  protected ProcessEngine()
+  {
+  }
+
+  /**
+   * Locate the ProcessEngine instance shared by all clients.
+   * 
+   * @return The configured instance of a process engine
+   */
+  public static ProcessEngine locateProcessEngine()
+  {
+    return null;
+  }
+
+  /**
+   * Prepare the engine for shutdown. During shutdown the creation of new processes is disallowed.
+   */
+  public void prepareForShutdown()
+  {
+    //log.debug("prepareForShutdown");
+    prepareForShutdown = true;
+  }
+
+  /**
+   * True, if engine is preparing for shutdown.
+   */
+  public boolean isPrepareForShutdown()
+  {
+    return prepareForShutdown;
+  }
+
+  /**
+   * Cancel the prepare for shutdown request
+   */
+  public void cancelShutdown()
+  {
+    //log.debug("cancelShutdown");
+    prepareForShutdown = false;
+  }
+}
\ No newline at end of file


Property changes on: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/client/ProcessEngine.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/test/ArchiveDeployer.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/test/ArchiveDeployer.java	                        (rev 0)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/test/ArchiveDeployer.java	2008-09-24 14:55:07 UTC (rev 2356)
@@ -0,0 +1,41 @@
+/*
+ * 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.api.test;
+
+import java.net.URL;
+
+/**
+ * An archive deployer 
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 16-May-2006
+ */
+public interface ArchiveDeployer
+{
+   /** Deploy the given archive
+    */
+   void deploy(URL archive) throws Exception;
+
+   /** Undeploy the given archive
+    */
+   void undeploy(URL archive) throws Exception;
+}


Property changes on: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/test/ArchiveDeployer.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/test/IntegrationTestHelper.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/test/IntegrationTestHelper.java	                        (rev 0)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/test/IntegrationTestHelper.java	2008-09-24 14:55:07 UTC (rev 2356)
@@ -0,0 +1,145 @@
+/*
+ * 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.api.test;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Hashtable;
+
+import javax.management.MBeanServerConnection;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+/**
+ * An integration test helper that deals with test deployment/undeployment, etc.
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 14-Oct-2004
+ */
+public class IntegrationTestHelper
+{
+   private static final String SYSPROP_TEST_ARCHIVE_DIRECTORY = "test.archive.directory";
+   private static final String SYSPROP_TEST_RESOURCES_DIRECTORY = "test.resources.directory";
+
+   private static MBeanServerConnection server;
+   private static String testArchiveDir;
+   private static String testResourcesDir;
+
+   /** Deploy the given archive
+    */
+   public void deploy(String archive) throws Exception
+   {
+      URL url = getArchiveFile(archive).toURI().toURL();
+      getDeployer().deploy(url);
+   }
+
+   /** Undeploy the given archive
+    */
+   public void undeploy(String archive) throws Exception
+   {
+      URL url = getArchiveFile(archive).toURI().toURL();
+      getDeployer().undeploy(url);
+   }
+
+   @SuppressWarnings("unchecked")
+   public static MBeanServerConnection getServer()
+   {
+      if (server == null)
+      {
+         Hashtable jndiEnv = null;
+         try
+         {
+            InitialContext iniCtx = new InitialContext();
+            jndiEnv = iniCtx.getEnvironment();
+            server = (MBeanServerConnection)iniCtx.lookup("jmx/invoker/RMIAdaptor");
+         }
+         catch (NamingException ex)
+         {
+            throw new RuntimeException("Cannot obtain MBeanServerConnection using jndi props: " + jndiEnv, ex);
+         }
+      }
+      return server;
+   }
+
+   private ArchiveDeployer getDeployer()
+   {
+      return new JBossArchiveDeployer(getServer());
+   }
+
+   /** Try to discover the URL for the deployment archive */
+   public URL getArchiveURL(String archive) throws MalformedURLException
+   {
+      return getArchiveFile(archive).toURI().toURL();
+   }
+
+   /** Try to discover the File for the deployment archive */
+   public File getArchiveFile(String archive)
+   {
+      File file = new File(archive);
+      if (file.exists())
+         return file;
+
+      file = new File(getTestArchiveDir() + "/" + archive);
+      if (file.exists())
+         return file;
+
+      String notSet = (getTestArchiveDir() == null ? " System property '" + SYSPROP_TEST_ARCHIVE_DIRECTORY + "' not set." : "");
+      throw new IllegalArgumentException("Cannot obtain '" + getTestArchiveDir() + "/" + archive + "'." + notSet);
+   }
+
+   /** Try to discover the URL for the test resource */
+   public URL getResourceURL(String resource) throws MalformedURLException
+   {
+      return getResourceFile(resource).toURI().toURL();
+   }
+
+   /** Try to discover the File for the test resource */
+   public File getResourceFile(String resource)
+   {
+      File file = new File(resource);
+      if (file.exists())
+         return file;
+
+      file = new File(getTestResourcesDir() + "/" + resource);
+      if (file.exists())
+         return file;
+
+      throw new IllegalArgumentException("Cannot obtain '" + getTestResourcesDir() + "/" + resource + "'");
+   }
+
+   public static String getTestArchiveDir()
+   {
+      if (testArchiveDir == null)
+         testArchiveDir = System.getProperty(SYSPROP_TEST_ARCHIVE_DIRECTORY, "target/test-libs");
+
+      return testArchiveDir;
+   }
+
+   public static String getTestResourcesDir()
+   {
+      if (testResourcesDir == null)
+         testResourcesDir = System.getProperty(SYSPROP_TEST_RESOURCES_DIRECTORY, "target/test-resource");
+
+      return testResourcesDir;
+   }
+}


Property changes on: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/test/IntegrationTestHelper.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/test/IntegrationTestSetup.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/test/IntegrationTestSetup.java	                        (rev 0)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/test/IntegrationTestSetup.java	2008-09-24 14:55:07 UTC (rev 2356)
@@ -0,0 +1,159 @@
+/*
+ * 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.api.test;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import javax.management.MBeanServerConnection;
+import javax.naming.NamingException;
+
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * A test setup that deploys/undeploys archives
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 14-Oct-2004
+ */
+public class IntegrationTestSetup extends TestSetup
+{
+   private IntegrationTestHelper delegate = new IntegrationTestHelper();
+   private String[] archives = new String[0];
+   private ClassLoader originalClassLoader;
+
+   public IntegrationTestSetup(Class<?> testClass, String archiveList)
+   {
+      super(new TestSuite(testClass));
+      getArchiveArray(archiveList);
+   }
+
+   public IntegrationTestSetup(Test test, String archiveList)
+   {
+      super(test);
+      getArchiveArray(archiveList);
+   }
+
+   public IntegrationTestSetup(Test test)
+   {
+      super(test);
+   }
+
+   public File getArchiveFile(String archive)
+   {
+      return delegate.getArchiveFile(archive);
+   }
+
+   public URL getArchiveURL(String archive) throws MalformedURLException
+   {
+      return delegate.getArchiveFile(archive).toURI().toURL();
+   }
+
+   public File getResourceFile(String resource)
+   {
+      return delegate.getResourceFile(resource);
+   }
+
+   public URL getResourceURL(String resource) throws MalformedURLException
+   {
+      return delegate.getResourceFile(resource).toURI().toURL();
+   }
+
+   private void getArchiveArray(String archiveList)
+   {
+      if (archiveList != null)
+      {
+         StringTokenizer st = new StringTokenizer(archiveList, ", ");
+         archives = new String[st.countTokens()];
+
+         for (int i = 0; i < archives.length; i++)
+            archives[i] = st.nextToken();
+      }
+   }
+
+   protected void setUp() throws Exception
+   {
+      List<URL> clientJars = new ArrayList<URL>();
+      for (int i = 0; i < archives.length; i++)
+      {
+         String archive = archives[i];
+         try
+         {
+            delegate.deploy(archive);
+         }
+         catch (Exception ex)
+         {
+            ex.printStackTrace();
+            delegate.undeploy(archive);
+         }
+
+         if (archive.endsWith("-client.jar"))
+         {
+            URL archiveURL = getArchiveURL(archive);
+            clientJars.add(archiveURL);
+         }
+      }
+
+      ClassLoader parent = Thread.currentThread().getContextClassLoader();
+      originalClassLoader = parent;
+      
+      // add client jars to the class loader
+      if (!clientJars.isEmpty())
+      {
+         URL[] urls = new URL[clientJars.size()];
+         for (int i = 0; i < clientJars.size(); i++)
+         {
+            urls[i] = clientJars.get(i);
+         }
+         URLClassLoader cl = new URLClassLoader(urls, parent);
+         Thread.currentThread().setContextClassLoader(cl);
+      }
+   }
+
+   protected void tearDown() throws Exception
+   {
+      try
+      {
+         for (int i = 0; i < archives.length; i++)
+         {
+            String archive = archives[archives.length - i - 1];
+            delegate.undeploy(archive);
+         }
+      }
+      finally
+      {
+         Thread.currentThread().setContextClassLoader(originalClassLoader);
+      }
+   }
+
+   public MBeanServerConnection getServer() throws NamingException
+   {
+      return IntegrationTestHelper.getServer();
+   }
+}


Property changes on: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/test/IntegrationTestSetup.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/test/JBossArchiveDeployer.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/test/JBossArchiveDeployer.java	                        (rev 0)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/test/JBossArchiveDeployer.java	2008-09-24 14:55:07 UTC (rev 2356)
@@ -0,0 +1,60 @@
+/*
+ * 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.api.test;
+
+import java.net.URL;
+
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+
+/**
+ * An archive deployer that deals with test deployment/undeployment, etc.
+ * 
+ * @author Thomas.Diesler at jboss.org
+ * @since 14-Oct-2004
+ */
+public class JBossArchiveDeployer implements ArchiveDeployer
+{
+  private static final String MAIN_DEPLOYER = "jboss.system:service=MainDeployer";
+
+  private MBeanServerConnection server;
+
+  public JBossArchiveDeployer(MBeanServerConnection server)
+  {
+    this.server = server;
+  }
+
+  public void deploy(URL url) throws Exception
+  {
+    invokeMainDeployer("deploy", url);
+  }
+
+  public void undeploy(URL url) throws Exception
+  {
+    invokeMainDeployer("undeploy", url);
+  }
+
+  private void invokeMainDeployer(String methodName, URL url) throws Exception
+  {
+    server.invoke(new ObjectName(MAIN_DEPLOYER), methodName, new Object[] { url }, new String[] { "java.net.URL" });
+  }
+}


Property changes on: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/test/JBossArchiveDeployer.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF




More information about the jbpm-commits mailing list