[jbpm-commits] JBoss JBPM SVN: r3465 - in projects/spec/trunk/modules: api/src/main/java/org/jboss/bpm/api/service and 8 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Fri Dec 19 17:44:25 EST 2008


Author: thomas.diesler at jboss.com
Date: 2008-12-19 17:44:25 -0500 (Fri, 19 Dec 2008)
New Revision: 3465

Added:
   projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/AbstractProcessDefinitionService.java
   projects/spec/trunk/modules/cts/src/test/java/org/jboss/bpm/test/cts/deployment/
   projects/spec/trunk/modules/cts/src/test/java/org/jboss/bpm/test/cts/deployment/DeploymentXMLTest.java
   projects/spec/trunk/modules/cts/src/test/resources/cts/deployment/
   projects/spec/trunk/modules/cts/src/test/resources/cts/deployment/simple-process-jbpm3.xml
Removed:
   projects/spec/trunk/modules/cts/src/test/resources/bpm-spec-jbpm3-beans.xml
Modified:
   projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/config/internal/MicrocontainerConfigurationProvider.java
   projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/ContextService.java
   projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/test/APITestCase.java
   projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/test/CTSTestCase.java
   projects/spec/trunk/modules/cts/pom.xml
   projects/spec/trunk/modules/cts/scripts/assembly-testsuite.xml
Log:
Add DeploymentXMLTest

Modified: projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/config/internal/MicrocontainerConfigurationProvider.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/config/internal/MicrocontainerConfigurationProvider.java	2008-12-19 19:58:19 UTC (rev 3464)
+++ projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/config/internal/MicrocontainerConfigurationProvider.java	2008-12-19 22:44:25 UTC (rev 3465)
@@ -42,8 +42,8 @@
 {
   /** The process engine bean name - BPMProcessEngine */
   public static final String DEFAULT_BEAN_NAME = "BPMProcessEngine";
-  /** The default bean config: jbpm-cfg-beans.xml */
-  public static final String DEFAULT_BEANS_CONFIG = "jbpm-cfg-beans.xml";
+  /** The default bean config: bpm-spec-beans.xml */
+  public static final String DEFAULT_BEANS_CONFIG = "bpm-spec-beans.xml";
 
   private Kernel kernel;
   private ProcessEngine engine;

Added: projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/AbstractProcessDefinitionService.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/AbstractProcessDefinitionService.java	                        (rev 0)
+++ projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/AbstractProcessDefinitionService.java	2008-12-19 22:44:25 UTC (rev 3465)
@@ -0,0 +1,108 @@
+/*
+ * 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.jboss.bpm.api.service;
+
+//$Id$
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URL;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.jboss.bpm.api.model.ProcessDefinition;
+import org.jboss.bpm.api.service.DialectHandler;
+import org.jboss.bpm.api.service.DialectHandlerService;
+import org.jboss.bpm.api.service.ProcessDefinitionService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * The ProcessDefinitionService is the entry point to create, find and otherwise manage process definitions.
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 25-Sep-2008
+ */
+public abstract class AbstractProcessDefinitionService extends AbstractService implements ProcessDefinitionService
+{
+  // Provide logging
+  final static Logger log = LoggerFactory.getLogger(AbstractProcessDefinitionService.class);
+
+  // Hide public constructor
+  protected AbstractProcessDefinitionService()
+  {
+  }
+
+  @Override
+  public final ProcessDefinition parseProcessDefinition(String pXML)
+  {
+    URI nsURI = getNamespaceURI(new ByteArrayInputStream(pXML.getBytes()));
+    DialectHandlerService dhService = getProcessEngine().getService(DialectHandlerService.class);
+    DialectHandler dialectHandler = dhService.getDialectHandler(nsURI);
+    if (dialectHandler == null)
+      throw new IllegalStateException("Cannot obtain DialectHandler for: " + nsURI);
+
+    ProcessDefinition procDef = dialectHandler.parseProcessDefinition(pXML);
+    return procDef;
+  }
+
+  @Override
+  public final ProcessDefinition parseProcessDefinition(URL pURL) throws IOException
+  {
+    URI nsURI = getNamespaceURI(pURL.openStream());
+    DialectHandlerService dhService = getProcessEngine().getService(DialectHandlerService.class);
+    DialectHandler dialectHandler = dhService.getDialectHandler(nsURI);
+    if (dialectHandler == null)
+      throw new IllegalStateException("Cannot obtain DialectHandler for: " + nsURI);
+
+    ProcessDefinition procDef = dialectHandler.parseProcessDefinition(pURL);
+    return procDef;
+  }
+
+  private URI getNamespaceURI(InputStream procXML)
+  {
+    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+    dbf.setNamespaceAware(true);
+    Document doc;
+    try
+    {
+      DocumentBuilder db = dbf.newDocumentBuilder();
+      doc = db.parse(procXML);
+    }
+    catch (Exception ex)
+    {
+      throw new IllegalStateException("Cannot parse process descriptor", ex);
+    }
+
+    Element root = doc.getDocumentElement();
+    String nsURI = root.getNamespaceURI();
+    if (nsURI == null)
+      throw new IllegalStateException("Cannot get namespace URI from root element");
+
+    return URI.create(nsURI);
+  }
+}
\ No newline at end of file

Modified: projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/ContextService.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/ContextService.java	2008-12-19 19:58:19 UTC (rev 3464)
+++ projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/ContextService.java	2008-12-19 22:44:25 UTC (rev 3465)
@@ -26,7 +26,7 @@
 //$Id$
 
 /**
- * The ContextService is the entry point to create or get an ExecutionContext.
+ * The ContextService is the entry point to create or get a Context.
  * 
  * @author thomas.diesler at jboss.com
  * @since 25-Sep-2008
@@ -34,13 +34,13 @@
 public interface ContextService
 {
   /**
-   * Create a new ExecutionContext
+   * Create a new Context
    */
-  Context createExecutionContext();
+  Context createContext();
 
   /**
-   * Get the current ExecutionContext association
-   * @param create If true, create a new ExecutionContext if there is no context associated
+   * Get the current Context association
+   * @param create If true, create a new Context if there is no context associated
    */
-  Context getExecutionContext(boolean create);
+  Context getContext(boolean create);
 }
\ No newline at end of file

Modified: projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/test/APITestCase.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/test/APITestCase.java	2008-12-19 19:58:19 UTC (rev 3464)
+++ projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/test/APITestCase.java	2008-12-19 22:44:25 UTC (rev 3465)
@@ -23,6 +23,7 @@
 
 import java.io.File;
 import java.net.MalformedURLException;
+import java.net.URI;
 import java.net.URL;
 import java.util.HashMap;
 import java.util.Map;
@@ -87,14 +88,34 @@
     return ObjectNameFactory.create(Constants.ID_DOMAIN, "test", shortName);
   }
 
+  protected String getDialect()
+  {
+    String propName = "bpm.dialect";
+    String dialect = System.getProperty(propName);
+    if (dialect == null)
+      throw new IllegalStateException("Cannot obtain dialect from system property: " + propName);
+    return dialect;
+  }
+
+  /**
+   * Get the BPM descriptor dialect ID
+   */
+  protected URI getDialectURI()
+  {
+    String dialect = System.getProperty("bpm.dialect.uri");
+    return URI.create(dialect);
+  }
+  
   protected ProcessEngine getProcessEngine()
   {
-    String impl = System.getProperty("bpm.spec.impl", "jbpm3");
-    ProcessEngine engine = engineRegistry.get(impl); 
+    String dialect = getDialect();
+    ProcessEngine engine = engineRegistry.get(dialect); 
     if (engine == null)
     {
-      String cfgResource = "bpm-spec-" + impl + "-beans.xml";
-      URL cfgURL = getResourceURL(cfgResource);
+      ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
+      
+      String cfgResource = "bpm-spec-" + dialect + "-beans.xml";
+      URL cfgURL = ctxLoader.getResource(cfgResource);
       if (cfgURL == null)
         throw new IllegalStateException("Cannot obtain resource: " + cfgResource);
 
@@ -102,7 +123,7 @@
       provider.configure(cfgURL);
       
       engine = provider.getProcessEngine();
-      engineRegistry.put(impl, engine);
+      engineRegistry.put(dialect, engine);
     }
     return engine;
   }

Modified: projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/test/CTSTestCase.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/test/CTSTestCase.java	2008-12-19 19:58:19 UTC (rev 3464)
+++ projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/test/CTSTestCase.java	2008-12-19 22:44:25 UTC (rev 3465)
@@ -26,7 +26,6 @@
 import java.io.IOException;
 import java.io.StringWriter;
 import java.io.Writer;
-import java.net.URI;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -312,22 +311,4 @@
     dialectHandler.marshallProcessDefinition(procDef, strwr);
     return strwr.toString();
   }
-
-  /**
-   * Get the BPM descriptor dialect ID
-   */
-  protected String getDialect()
-  {
-    String dialect = System.getProperty("jbpm.dialect", "api10");
-    return dialect;
-  }
-
-  /**
-   * Get the BPM descriptor dialect ID
-   */
-  protected URI getDialectURI()
-  {
-    String dialect = System.getProperty("jbpm.dialect.uri", DialectHandler.DEFAULT_NAMESPACE_URI.toString());
-    return URI.create(dialect);
-  }
 }

Modified: projects/spec/trunk/modules/cts/pom.xml
===================================================================
--- projects/spec/trunk/modules/cts/pom.xml	2008-12-19 19:58:19 UTC (rev 3464)
+++ projects/spec/trunk/modules/cts/pom.xml	2008-12-19 22:44:25 UTC (rev 3465)
@@ -108,10 +108,30 @@
           <name>!impl</name>
         </property>
       </activation>
-      <properties>
-        <database>hsqldb</database>
-        <bpm.spec.impl>jbpm3</bpm.spec.impl>
-      </properties>
+      <build>
+        <plugins>
+          <plugin>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <configuration>
+              <skipTests>true</skipTests>
+            </configuration>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+
+    <!--
+    Name:  impl-jbpm3
+    Descr: Setup the jBPM3 Implementation
+    -->
+    <profile>
+      <id>impl-jbpm3</id>
+      <activation>
+        <property>
+          <name>impl</name>
+          <value>jbpm3</value>
+        </property>
+      </activation>
       <dependencies>
         <dependency>
           <groupId>hsqldb</groupId>
@@ -125,7 +145,37 @@
           <version>${jbpm3.version}</version>
           <scope>test</scope>
         </dependency>
+        <dependency>
+          <groupId>org.jbpm.jbpm3</groupId>
+          <artifactId>jbpm-integration-spec</artifactId>
+          <classifier>config</classifier>
+          <version>${jbpm3.version}</version>
+          <scope>test</scope>
+        </dependency>
       </dependencies>
+      <build>
+        <plugins>
+          <plugin>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <configuration>
+              <systemProperties>
+                <property>
+                  <name>bpm.dialect</name>
+                  <value>jbpm3</value>
+                </property>
+                <property>
+                  <name>bpm.dialect.uri</name>
+                  <value>urn:jbpm.org:jpdl-3.2</value>
+                </property>
+                <property>
+                  <name>log4j.output.dir</name>
+                  <value>${basedir}/target</value>
+                </property>
+              </systemProperties>
+            </configuration>
+          </plugin>
+        </plugins>
+      </build>
     </profile>
   </profiles>
 

Modified: projects/spec/trunk/modules/cts/scripts/assembly-testsuite.xml
===================================================================
--- projects/spec/trunk/modules/cts/scripts/assembly-testsuite.xml	2008-12-19 19:58:19 UTC (rev 3464)
+++ projects/spec/trunk/modules/cts/scripts/assembly-testsuite.xml	2008-12-19 22:44:25 UTC (rev 3465)
@@ -10,7 +10,7 @@
       <directory>src/test</directory>
       <outputDirectory>/</outputDirectory>
       <excludes>
-        <exclude>resources/jbpm-beans.xml</exclude>
+        <exclude>resources/*-beans.xml</exclude>
       </excludes>
     </fileSet>
   </fileSets>

Added: projects/spec/trunk/modules/cts/src/test/java/org/jboss/bpm/test/cts/deployment/DeploymentXMLTest.java
===================================================================
--- projects/spec/trunk/modules/cts/src/test/java/org/jboss/bpm/test/cts/deployment/DeploymentXMLTest.java	                        (rev 0)
+++ projects/spec/trunk/modules/cts/src/test/java/org/jboss/bpm/test/cts/deployment/DeploymentXMLTest.java	2008-12-19 22:44:25 UTC (rev 3465)
@@ -0,0 +1,73 @@
+/*
+ * 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.jboss.bpm.test.cts.deployment;
+
+// $Id$
+
+import java.net.URL;
+
+import org.jboss.bpm.api.deployment.Deployment;
+import org.jboss.bpm.api.model.ProcessDefinition;
+import org.jboss.bpm.api.model.ProcessInstance;
+import org.jboss.bpm.api.model.ProcessInstance.ProcessStatus;
+import org.jboss.bpm.api.runtime.Token;
+import org.jboss.bpm.api.service.DeploymentService;
+import org.jboss.bpm.api.test.APITestCase;
+
+/**
+ * Test simple XML deployment
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 24-Nov-2008
+ */
+public class DeploymentXMLTest extends APITestCase
+{
+  public void testSimpleXMLDeploy() throws Exception
+  {
+    URL pdURL = getResourceURL("cts/deployment/simple-process-" + getDialect() + ".xml");
+
+    DeploymentService depService = getProcessEngine().getService(DeploymentService.class);
+    Deployment dep = depService.createDeployment(pdURL);
+
+    ProcessDefinition procDef = depService.deploy(dep);
+    assertNotNull("ProcDef not null", procDef);
+    
+    ProcessInstance proc = procDef.newInstance();
+    
+    Token token = proc.startProcess();
+    assertEquals("Node name", "a", token.getNode().getName());
+    
+    token.signal();
+    assertEquals("Node name", "b", token.getNode().getName());
+    
+    token.signal();
+    assertEquals("Node name", "c", token.getNode().getName());
+    
+    token.signal();
+    assertEquals("Node name", "end", token.getNode().getName());
+    
+    assertEquals(ProcessStatus.Completed, proc.getProcessStatus());
+
+    // Undeploy the process
+    assertTrue("Undeploy successful", depService.undeploy(dep));
+  }
+}


Property changes on: projects/spec/trunk/modules/cts/src/test/java/org/jboss/bpm/test/cts/deployment/DeploymentXMLTest.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Deleted: projects/spec/trunk/modules/cts/src/test/resources/bpm-spec-jbpm3-beans.xml
===================================================================
--- projects/spec/trunk/modules/cts/src/test/resources/bpm-spec-jbpm3-beans.xml	2008-12-19 19:58:19 UTC (rev 3464)
+++ projects/spec/trunk/modules/cts/src/test/resources/bpm-spec-jbpm3-beans.xml	2008-12-19 22:44:25 UTC (rev 3465)
@@ -1,60 +0,0 @@
-<!--
-  Note, this uses the bean-deployer-2.0 schema
-  $Id$ 
--->
-<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:jboss:bean-deployer:2.0 bean-deployer_2_0.xsd" xmlns="urn:jboss:bean-deployer:2.0">
-
- <!-- Locate the single instance of the kernel -->
- <bean name="BPMKernelLocator" class="org.jboss.bpm.api.config.internal.KernelLocator">
-  <property name="kernel"><inject bean="jboss.kernel:service=Kernel" /></property>
- </bean>
-
- <!-- The ProcessEngine -->
- <bean name="BPMProcessEngine" class="org.jbpm.integration.spec.service.ProcessEngineImpl">
-  <property name="services">
-   <set elementClass="org.jboss.bpm.api.service.Service">
-    <inject bean="BPMDeploymentService"/>
-    <inject bean="BPMDialectHandlerService"/>
-    <inject bean="BPMExecutionContextService"/>
-    <inject bean="BPMExecutionService"/>
-    <inject bean="BPMIdentityService"/>
-    <inject bean="BPMProcessBuilderService"/>
-    <inject bean="BPMProcessDefinitionService"/>
-    <inject bean="BPMProcessService"/>
-    <inject bean="BPMTaskService"/>
-   </set>
-  </property>
- </bean>
-
- <!-- The PersistenceService -->
- <bean name="BPMPersistenceService" class="org.jbpm.integration.spec.service.NoopPersistenceServiceImpl" />
-
- <!-- The ProcessService -->
- <bean name="BPMProcessService" class="org.jbpm.integration.spec.service.ProcessInstanceServiceImpl">
-  <property name="interceptors">
-   <list elementClass="java.lang.String">
-    <value>org.jbpm.integration.spec.runtime.NodeExecuteInterceptor</value>
-   </list>
-  </property>
- </bean>
-
- <!-- The DialectHandlerService -->
- <bean name="BPMDialectHandlerService" class="org.jbpm.integration.spec.service.DialectHandlerServiceImpl">
-  <property name="dialectHandlers">
-   <map keyClass="java.net.URI" valueClass="org.jboss.bpm.api.service.DialectHandler">
-    <entry><key>urn:jbpm.org:jpdl-3.2</key><value><inject bean="BPMDialectHandlerJPDL32"/></value></entry>
-   </map>
-  </property>
- </bean>
- <bean name="BPMDialectHandlerJPDL32" class="org.jbpm.integration.spec.jpdl32.DialectHandlerImpl" />
-
- <!-- Other Services -->
- <bean name="BPMDeploymentService" class="org.jbpm.integration.spec.service.DeploymentServiceImpl" />
- <bean name="BPMExecutionContextService" class="org.jbpm.integration.spec.service.ExecutionContextServiceImpl" />
- <bean name="BPMExecutionService" class="org.jbpm.integration.spec.service.ExecutionServiceImpl" />
- <bean name="BPMIdentityService" class="org.jbpm.integration.spec.service.IdentityServiceImpl" />
- <bean name="BPMProcessBuilderService" class="org.jbpm.integration.spec.service.ProcessBuilderServiceImpl" />
- <bean name="BPMProcessDefinitionService" class="org.jbpm.integration.spec.service.ProcessDefinitionServiceImpl" />
- <bean name="BPMTaskService" class="org.jbpm.integration.spec.service.TaskServiceImpl" />
-
-</deployment>

Added: projects/spec/trunk/modules/cts/src/test/resources/cts/deployment/simple-process-jbpm3.xml
===================================================================
--- projects/spec/trunk/modules/cts/src/test/resources/cts/deployment/simple-process-jbpm3.xml	                        (rev 0)
+++ projects/spec/trunk/modules/cts/src/test/resources/cts/deployment/simple-process-jbpm3.xml	2008-12-19 22:44:25 UTC (rev 3465)
@@ -0,0 +1,16 @@
+<process-definition name="simpleProcess" xmlns="urn:jbpm.org:jpdl-3.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="urn:jbpm.org:jpdl-3.2 http://jbpm.org/xsd/jpdl-3.2.xsd">
+  <start-state name='start'>
+    <transition to='a' />
+  </start-state>
+  <state name='a'>
+    <transition to='b' />
+  </state>
+  <state name='b'>
+    <transition to='c' />
+  </state>
+  <state name='c'>
+    <transition to='end' />
+  </state>
+  <end-state name='end' />
+</process-definition>


Property changes on: projects/spec/trunk/modules/cts/src/test/resources/cts/deployment/simple-process-jbpm3.xml
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF




More information about the jbpm-commits mailing list