[jbpm-commits] JBoss JBPM SVN: r3484 - in projects/spec/trunk/modules: api/src/main/java/org/jboss/bpm/api/service/internal and 3 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Sat Dec 20 09:32:41 EST 2008
Author: thomas.diesler at jboss.com
Date: 2008-12-20 09:32:41 -0500 (Sat, 20 Dec 2008)
New Revision: 3484
Added:
projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/internal/
projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/internal/AbstractDialectHandler.java
projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/internal/AbstractDialectHandlerService.java
projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/internal/AbstractProcessDefinitionService.java
projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/internal/AbstractService.java
Removed:
projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/AbstractDialectHandler.java
projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/AbstractDialectHandlerService.java
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/AbstractService.java
Modified:
projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/MessageBuilderService.java
projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/MessageService.java
projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/SignalBuilderService.java
projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/SignalService.java
projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/TokenService.java
projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/incubator/service/PersistenceService.java
projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/incubator/service/ProcessBuilderService.java
projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/incubator/service/ThreadingService.java
projects/spec/trunk/modules/cts/src/test/java/org/jboss/bpm/cts/feature/gateway/exclusive/ExclusiveGatewaySplitTest.java
projects/spec/trunk/modules/cts/src/test/java/org/jboss/bpm/cts/feature/service/ProcessDefinitionServiceTest.java
projects/spec/trunk/modules/cts/src/test/java/org/jboss/bpm/cts/feature/service/ProcessInstanceServiceTest.java
Log:
Enable ProcessDefinition/InstanceTest
Deleted: projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/AbstractDialectHandler.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/AbstractDialectHandler.java 2008-12-20 13:33:37 UTC (rev 3483)
+++ projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/AbstractDialectHandler.java 2008-12-20 14:32:41 UTC (rev 3484)
@@ -1,48 +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.jboss.bpm.api.service;
-
-//$Id$
-
-
-
-/**
- * The DialectHandler converts a supported dialect to the ProcessDefinition model.
- *
- * @author thomas.diesler at jboss.com
- * @since 18-Jun-2008
- */
-public abstract class AbstractDialectHandler implements DialectHandler
-{
- private ProcessEngine engine;
-
- public ProcessEngine getProcessEngine()
- {
- return engine;
- }
-
- // Do not expose through the API
- protected void setProcessEngine(ProcessEngine engine)
- {
- this.engine = engine;
- }
-}
Deleted: projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/AbstractDialectHandlerService.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/AbstractDialectHandlerService.java 2008-12-20 13:33:37 UTC (rev 3483)
+++ projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/AbstractDialectHandlerService.java 2008-12-20 14:32:41 UTC (rev 3484)
@@ -1,56 +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.jboss.bpm.api.service;
-
-//$Id$
-
-import java.net.URI;
-import java.util.Map;
-
-
-
-/**
- * A registry that maps namespaceURI to a {@link DialectHandler}
- *
- * @author thomas.diesler at jboss.com
- * @since 18-Jul-2008
- */
-public abstract class AbstractDialectHandlerService extends AbstractService implements DialectHandlerService
-{
- // Maps namespaceURI to a DialectHandler
- protected Map<URI, DialectHandler> dialectHandlers;
-
- public DialectHandler getDialectHandler(URI nsURI)
- {
- DialectHandler dialectHandler = dialectHandlers.get(nsURI);
- if (dialectHandler == null)
- throw new IllegalStateException("No dialect handler registered for: " + nsURI);
-
- if (dialectHandler instanceof AbstractDialectHandler)
- {
- AbstractDialectHandler absHandler = (AbstractDialectHandler)dialectHandler;
- absHandler.setProcessEngine(getProcessEngine());
- }
-
- return dialectHandler;
- }
-}
Deleted: 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 2008-12-20 13:33:37 UTC (rev 3483)
+++ projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/AbstractProcessDefinitionService.java 2008-12-20 14:32:41 UTC (rev 3484)
@@ -1,108 +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.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
Deleted: projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/AbstractService.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/AbstractService.java 2008-12-20 13:33:37 UTC (rev 3483)
+++ projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/AbstractService.java 2008-12-20 14:32:41 UTC (rev 3484)
@@ -1,47 +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.jboss.bpm.api.service;
-
-// $Id$
-
-
-/**
- * An abstract Service that gives access to the ProcessEngine
- *
- * @author thomas.diesler at jboss.com
- * @since 18-Jun-2008
- */
-public class AbstractService implements Service, ProcessEngineSupport
-{
- private ProcessEngine engine;
-
- public ProcessEngine getProcessEngine()
- {
- return engine;
- }
-
- // Do not expose through the API
- protected void setProcessEngine(ProcessEngine engine)
- {
- this.engine = engine;
- }
-}
Modified: projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/MessageBuilderService.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/MessageBuilderService.java 2008-12-20 13:33:37 UTC (rev 3483)
+++ projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/MessageBuilderService.java 2008-12-20 14:32:41 UTC (rev 3484)
@@ -26,6 +26,7 @@
import org.jboss.bpm.api.config.Configuration;
import org.jboss.bpm.api.model.Message;
import org.jboss.bpm.api.model.builder.MessageBuilder;
+import org.jboss.bpm.api.service.internal.AbstractService;
/**
* The MessageBuilder can be used to build a {@link Message} dynamically.
Modified: projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/MessageService.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/MessageService.java 2008-12-20 13:33:37 UTC (rev 3483)
+++ projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/MessageService.java 2008-12-20 14:32:41 UTC (rev 3484)
@@ -37,6 +37,7 @@
import org.jboss.bpm.api.model.Node;
import org.jboss.bpm.api.model.Participant;
import org.jboss.bpm.api.model.ProcessInstance;
+import org.jboss.bpm.api.service.internal.AbstractService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Modified: projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/SignalBuilderService.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/SignalBuilderService.java 2008-12-20 13:33:37 UTC (rev 3483)
+++ projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/SignalBuilderService.java 2008-12-20 14:32:41 UTC (rev 3484)
@@ -25,6 +25,7 @@
import org.jboss.bpm.api.model.Signal;
import org.jboss.bpm.api.model.builder.SignalBuilder;
+import org.jboss.bpm.api.service.internal.AbstractService;
/**
* The SignalBuilder can be used to build a {@link Signal} dynamically.
Modified: projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/SignalService.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/SignalService.java 2008-12-20 13:33:37 UTC (rev 3483)
+++ projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/SignalService.java 2008-12-20 14:32:41 UTC (rev 3484)
@@ -29,6 +29,7 @@
import org.jboss.bpm.api.model.Signal;
import org.jboss.bpm.api.model.SignalListener;
+import org.jboss.bpm.api.service.internal.AbstractService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Modified: projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/TokenService.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/TokenService.java 2008-12-20 13:33:37 UTC (rev 3483)
+++ projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/TokenService.java 2008-12-20 14:32:41 UTC (rev 3484)
@@ -28,10 +28,11 @@
import javax.management.ObjectName;
import org.jboss.bpm.api.runtime.Token;
+import org.jboss.bpm.api.service.internal.AbstractService;
/**
- * The ExecutionService manages Tokens
+ * The TokenService manages Tokens
*
* @author thomas.diesler at jboss.com
* @since 28-Nov-2008
Copied: projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/internal/AbstractDialectHandler.java (from rev 3449, projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/AbstractDialectHandler.java)
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/internal/AbstractDialectHandler.java (rev 0)
+++ projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/internal/AbstractDialectHandler.java 2008-12-20 14:32:41 UTC (rev 3484)
@@ -0,0 +1,49 @@
+/*
+ * 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.internal;
+
+//$Id$
+
+import org.jboss.bpm.api.service.DialectHandler;
+import org.jboss.bpm.api.service.ProcessEngine;
+
+/**
+ * The DialectHandler converts a supported dialect to the ProcessDefinition model.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 18-Jun-2008
+ */
+public abstract class AbstractDialectHandler implements DialectHandler
+{
+ private ProcessEngine engine;
+
+ public ProcessEngine getProcessEngine()
+ {
+ return engine;
+ }
+
+ // Do not expose through the API
+ protected void setProcessEngine(ProcessEngine engine)
+ {
+ this.engine = engine;
+ }
+}
Copied: projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/internal/AbstractDialectHandlerService.java (from rev 3449, projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/AbstractDialectHandlerService.java)
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/internal/AbstractDialectHandlerService.java (rev 0)
+++ projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/internal/AbstractDialectHandlerService.java 2008-12-20 14:32:41 UTC (rev 3484)
@@ -0,0 +1,57 @@
+/*
+ * 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.internal;
+
+//$Id$
+
+import java.net.URI;
+import java.util.Map;
+
+import org.jboss.bpm.api.service.DialectHandler;
+import org.jboss.bpm.api.service.DialectHandlerService;
+
+/**
+ * A registry that maps namespaceURI to a {@link DialectHandler}
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 18-Jul-2008
+ */
+public abstract class AbstractDialectHandlerService extends AbstractService implements DialectHandlerService
+{
+ // Maps namespaceURI to a DialectHandler
+ protected Map<URI, DialectHandler> dialectHandlers;
+
+ public DialectHandler getDialectHandler(URI nsURI)
+ {
+ DialectHandler dialectHandler = dialectHandlers.get(nsURI);
+ if (dialectHandler == null)
+ throw new IllegalStateException("No dialect handler registered for: " + nsURI);
+
+ if (dialectHandler instanceof AbstractDialectHandler)
+ {
+ AbstractDialectHandler absHandler = (AbstractDialectHandler)dialectHandler;
+ absHandler.setProcessEngine(getProcessEngine());
+ }
+
+ return dialectHandler;
+ }
+}
Copied: projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/internal/AbstractProcessDefinitionService.java (from rev 3465, 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/internal/AbstractProcessDefinitionService.java (rev 0)
+++ projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/internal/AbstractProcessDefinitionService.java 2008-12-20 14:32:41 UTC (rev 3484)
@@ -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.internal;
+
+//$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
Copied: projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/internal/AbstractService.java (from rev 3449, projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/AbstractService.java)
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/internal/AbstractService.java (rev 0)
+++ projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/api/service/internal/AbstractService.java 2008-12-20 14:32:41 UTC (rev 3484)
@@ -0,0 +1,50 @@
+/*
+ * 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.internal;
+
+//$Id$
+
+import org.jboss.bpm.api.service.ProcessEngine;
+import org.jboss.bpm.api.service.ProcessEngineSupport;
+import org.jboss.bpm.api.service.Service;
+
+/**
+ * An abstract Service that gives access to the ProcessEngine
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 18-Jun-2008
+ */
+public class AbstractService implements Service, ProcessEngineSupport
+{
+ private ProcessEngine engine;
+
+ public ProcessEngine getProcessEngine()
+ {
+ return engine;
+ }
+
+ // Do not expose through the API
+ protected void setProcessEngine(ProcessEngine engine)
+ {
+ this.engine = engine;
+ }
+}
Modified: projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/incubator/service/PersistenceService.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/incubator/service/PersistenceService.java 2008-12-20 13:33:37 UTC (rev 3483)
+++ projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/incubator/service/PersistenceService.java 2008-12-20 14:32:41 UTC (rev 3484)
@@ -29,7 +29,7 @@
import org.jboss.bpm.api.model.Node;
import org.jboss.bpm.api.model.ProcessDefinition;
import org.jboss.bpm.api.model.ProcessInstance;
-import org.jboss.bpm.api.service.AbstractService;
+import org.jboss.bpm.api.service.internal.AbstractService;
/**
* The persistence service.
Modified: projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/incubator/service/ProcessBuilderService.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/incubator/service/ProcessBuilderService.java 2008-12-20 13:33:37 UTC (rev 3483)
+++ projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/incubator/service/ProcessBuilderService.java 2008-12-20 14:32:41 UTC (rev 3484)
@@ -24,7 +24,7 @@
//$Id$
import org.jboss.bpm.api.model.ProcessInstance;
-import org.jboss.bpm.api.service.AbstractService;
+import org.jboss.bpm.api.service.internal.AbstractService;
import org.jboss.bpm.incubator.model.builder.ProcessBuilder;
/**
Modified: projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/incubator/service/ThreadingService.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/incubator/service/ThreadingService.java 2008-12-20 13:33:37 UTC (rev 3483)
+++ projects/spec/trunk/modules/api/src/main/java/org/jboss/bpm/incubator/service/ThreadingService.java 2008-12-20 14:32:41 UTC (rev 3484)
@@ -29,7 +29,7 @@
import org.jboss.bpm.api.model.ProcessInstance;
import org.jboss.bpm.api.model.ProcessInstance.ProcessStatus;
import org.jboss.bpm.api.runtime.Attachments;
-import org.jboss.bpm.api.service.AbstractService;
+import org.jboss.bpm.api.service.internal.AbstractService;
import org.jboss.bpm.incubator.model.StartEvent;
/**
Modified: projects/spec/trunk/modules/cts/src/test/java/org/jboss/bpm/cts/feature/gateway/exclusive/ExclusiveGatewaySplitTest.java
===================================================================
--- projects/spec/trunk/modules/cts/src/test/java/org/jboss/bpm/cts/feature/gateway/exclusive/ExclusiveGatewaySplitTest.java 2008-12-20 13:33:37 UTC (rev 3483)
+++ projects/spec/trunk/modules/cts/src/test/java/org/jboss/bpm/cts/feature/gateway/exclusive/ExclusiveGatewaySplitTest.java 2008-12-20 14:32:41 UTC (rev 3484)
@@ -40,7 +40,7 @@
* @author thomas.diesler at jboss.com
* @since 06-Aug-2008
*/
-public abstract class ExclusiveGatewaySplitTest extends CTSTestCase
+public abstract class ExclusiveGatewaySplitTest extends CTSTestCase
{
public void testGateA() throws Exception
{
Modified: projects/spec/trunk/modules/cts/src/test/java/org/jboss/bpm/cts/feature/service/ProcessDefinitionServiceTest.java
===================================================================
--- projects/spec/trunk/modules/cts/src/test/java/org/jboss/bpm/cts/feature/service/ProcessDefinitionServiceTest.java 2008-12-20 13:33:37 UTC (rev 3483)
+++ projects/spec/trunk/modules/cts/src/test/java/org/jboss/bpm/cts/feature/service/ProcessDefinitionServiceTest.java 2008-12-20 14:32:41 UTC (rev 3484)
@@ -24,6 +24,7 @@
// $Id$
import java.io.IOException;
+import java.net.URL;
import java.util.Set;
import javax.management.ObjectName;
@@ -41,7 +42,7 @@
* @author thomas.diesler at jboss.com
* @since 24-Sep-2008
*/
-public abstract class ProcessDefinitionServiceTest extends CTSTestCase
+public class ProcessDefinitionServiceTest extends CTSTestCase
{
public void testBasicProcess() throws Exception
{
@@ -87,6 +88,9 @@
protected ProcessDefinition getProcessDefinition() throws IOException
{
- return null;
+ URL pdURL = getResourceURL("cts/common/simple-sequence-" + getDialect() + ".xml");
+ ProcessDefinitionService pdService = getProcessEngine().getService(ProcessDefinitionService.class);
+ ProcessDefinition procDef = pdService.parseProcessDefinition(pdURL);
+ return procDef;
}
}
Modified: projects/spec/trunk/modules/cts/src/test/java/org/jboss/bpm/cts/feature/service/ProcessInstanceServiceTest.java
===================================================================
--- projects/spec/trunk/modules/cts/src/test/java/org/jboss/bpm/cts/feature/service/ProcessInstanceServiceTest.java 2008-12-20 13:33:37 UTC (rev 3483)
+++ projects/spec/trunk/modules/cts/src/test/java/org/jboss/bpm/cts/feature/service/ProcessInstanceServiceTest.java 2008-12-20 14:32:41 UTC (rev 3484)
@@ -24,6 +24,7 @@
// $Id$
import java.io.IOException;
+import java.net.URL;
import javax.management.ObjectName;
@@ -40,7 +41,7 @@
* @author thomas.diesler at jboss.com
* @since 08-Jul-2008
*/
-public abstract class ProcessInstanceServiceTest extends CTSTestCase
+public class ProcessInstanceServiceTest extends CTSTestCase
{
public void testRegisterProcess() throws Exception
{
@@ -93,6 +94,9 @@
protected ProcessDefinition getProcessDefinition() throws IOException
{
- return null;
+ URL pdURL = getResourceURL("cts/common/simple-sequence-" + getDialect() + ".xml");
+ ProcessDefinitionService pdService = getProcessEngine().getService(ProcessDefinitionService.class);
+ ProcessDefinition procDef = pdService.parseProcessDefinition(pdURL);
+ return procDef;
}
}
More information about the jbpm-commits
mailing list