jbpm-tempranillo Mailing List for jBPM (Page 2)
open-source, flexible Business Process Management (BPM) in Java
Brought to you by:
krisverlaenen
You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(11) |
Sep
(4) |
Oct
(91) |
Nov
(68) |
Dec
(36) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(60) |
Feb
(30) |
Mar
(257) |
Apr
(175) |
May
(126) |
Jun
(303) |
Jul
(99) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2010 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <do-...@jb...> - 2008-07-04 10:10:06
|
Author: tho...@jb... Date: 2008-07-04 06:10:04 -0400 (Fri, 04 Jul 2008) New Revision: 1508 Modified: jbpm3/trunk/.classpath jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ExecutionImpl.java jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/runtime/ActivityWrapper.java Log: [JBPM-1253] Add support for Basic Activity Modified: jbpm3/trunk/.classpath =================================================================== --- jbpm3/trunk/.classpath 2008-07-04 10:04:28 UTC (rev 1507) +++ jbpm3/trunk/.classpath 2008-07-04 10:10:04 UTC (rev 1508) @@ -1,8 +1,35 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="src" path="modules/jpdl/core/src/main/java"/> - <classpathentry kind="src" path="modules/jpdl/core/src/test/java"/> + <classpathentry kind="src" output="modules/jpdl/core/target/classes" path="modules/jpdl/core/src/main/java"/> + <classpathentry kind="src" output="modules/jpdl/core/target/test-classes" path="modules/jpdl/core/src/test/java"/> + <classpathentry excluding="**" kind="src" output="modules/jpdl/core/target/classes" path="modules/jpdl/core/src/main/resources"/> + <classpathentry excluding="**" kind="src" output="modules/jpdl/core/target/test-classes" path="modules/jpdl/core/src/test/resources"/> + <classpathentry excluding="**" kind="src" output="modules/jpdl/db/target/classes" path="modules/jpdl/db/src/main/resources"/> + <classpathentry kind="src" output="modules/jpdl/examples/target/test-classes" path="modules/jpdl/examples/src/test/java"/> + <classpathentry excluding="**" kind="src" output="modules/jpdl/examples/target/test-classes" path="modules/jpdl/examples/src/test/resources"/> + <classpathentry kind="src" output="modules/jpdl/identity/target/classes" path="modules/jpdl/identity/src/main/java"/> + <classpathentry kind="src" output="modules/jpdl/identity/target/test-classes" path="modules/jpdl/identity/src/test/java"/> + <classpathentry excluding="**" kind="src" output="modules/jpdl/identity/target/classes" path="modules/jpdl/identity/src/main/resources"/> + <classpathentry excluding="**" kind="src" output="modules/jpdl/identity/target/test-classes" path="modules/jpdl/identity/src/test/resources"/> + <classpathentry kind="src" output="modules/jpdl/simulation/target/classes" path="modules/jpdl/simulation/src/main/java"/> + <classpathentry kind="src" output="modules/jpdl/simulation/target/test-classes" path="modules/jpdl/simulation/src/test/java"/> + <classpathentry excluding="**" kind="src" output="modules/jpdl/simulation/target/classes" path="modules/jpdl/simulation/src/main/resources"/> + <classpathentry kind="src" output="modules/jpdl/ws/target/classes" path="modules/jpdl/ws/src/main/java"/> + <classpathentry excluding="**" kind="src" output="modules/jpdl/ws/target/classes" path="modules/jpdl/ws/src/main/resources"/> + <classpathentry excluding="**" kind="src" output="modules/console/target/classes" path="modules/console/src/main/resources"/> + <classpathentry kind="src" output="modules/enterprise/target/classes" path="modules/enterprise/src/main/java"/> + <classpathentry kind="src" output="modules/enterprise/target/test-classes" path="modules/enterprise/src/test/java"/> + <classpathentry excluding="**" kind="src" output="modules/enterprise/target/classes" path="modules/enterprise/src/main/resources"/> + <classpathentry excluding="**" kind="src" output="modules/enterprise/target/test-classes" path="modules/enterprise/src/test/resources"/> + <classpathentry kind="src" output="modules/jbpm4jsf/target/classes" path="modules/jbpm4jsf/src/main/java"/> + <classpathentry excluding="**" kind="src" output="modules/jbpm4jsf/target/classes" path="modules/jbpm4jsf/src/main/resources"/> + <classpathentry kind="src" output="modules/bamconsole/ejb/target/classes" path="modules/bamconsole/ejb/src/main/java"/> + <classpathentry kind="src" output="modules/bamconsole/ejb/target/test-classes" path="modules/bamconsole/ejb/src/test/java"/> + <classpathentry excluding="**" kind="src" output="modules/bamconsole/ejb/target/classes" path="modules/bamconsole/ejb/src/main/resources"/> + <classpathentry excluding="**" kind="src" output="modules/bamconsole/ejb/target/test-classes" path="modules/bamconsole/ejb/src/test/resources"/> + <classpathentry excluding="**" kind="src" output="modules/bamconsole/war/target/classes" path="modules/bamconsole/war/src/main/resources"/> + <classpathentry excluding="**" kind="src" output="modules/bamconsole/ear/target/classes" path="modules/bamconsole/ear/src/main/resources"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/> - <classpathentry kind="output" path="target/eclipse-classes"/> + <classpathentry kind="output" path="target/classes"/> </classpath> Modified: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ExecutionImpl.java =================================================================== --- jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ExecutionImpl.java 2008-07-04 10:04:28 UTC (rev 1507) +++ jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ExecutionImpl.java 2008-07-04 10:10:04 UTC (rev 1508) @@ -23,22 +23,27 @@ //$Id$ +import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + import org.jboss.bpm.Context; -import org.jboss.bpm.NotImplementedException; import org.jboss.bpm.client.Execution; import org.jboss.bpm.client.ProcessInstance; import org.jboss.bpm.client.internal.AbstractExecution; import org.jboss.bpm.def.Node; /** - * TODO + * Represents an execution of a process instance. * * @author tho...@jb... * @since 18-Jun-2008 */ public class ExecutionImpl extends AbstractExecution { - org.jbpm.graph.exe.Execution oldEx; + private org.jbpm.graph.exe.Execution oldEx; + private Context context = new ContextImpl(); ExecutionImpl(ProcessInstance pi, org.jbpm.graph.exe.Execution oldEx) { @@ -77,6 +82,96 @@ @Override public Context getContext() { - throw new NotImplementedException(); + return context; } + + private class ContextImpl extends Context + { + @SuppressWarnings("unchecked") + public <T> T addAttachment(Class<T> clazz, Object value) + { + Key key = new Key(clazz, null); + oldEx.getContextInstance().setTransientVariable(key, value); + return (T)value; + } + + @SuppressWarnings("unchecked") + public <T> T addAttachment(Class<T> clazz, String name, Object value) + { + Key key = new Key(clazz, name); + oldEx.getContextInstance().setTransientVariable(key, value); + return (T)value; + } + + @SuppressWarnings("unchecked") + public <T> T addAttachment(String name, Object value) + { + Key key = new Key(null, name); + oldEx.getContextInstance().setTransientVariable(key, value); + return (T)value; + } + + @SuppressWarnings("unchecked") + public <T> T getAttachment(Class<T> clazz) + { + Key key = new Key(clazz, null); + Object value = oldEx.getContextInstance().getTransientVariable(key); + return (T)value; + } + + @SuppressWarnings("unchecked") + public <T> T getAttachment(Class<T> clazz, String name) + { + Key key = new Key(clazz, name); + Object value = oldEx.getContextInstance().getTransientVariable(key); + return (T)value; + } + + @SuppressWarnings("unchecked") + public <T> T getAttachment(String name) + { + Key key = new Key(null, name); + Object value = oldEx.getContextInstance().getTransientVariable(key); + return (T)value; + } + + public Collection<Key> getAttachments() + { + Set<Key> keys = new HashSet<Key>(); + Iterator<?> itKeys = oldEx.getContextInstance().getTransientVariables().keySet().iterator(); + while (itKeys.hasNext()) + { + Object key = itKeys.next(); + if (key instanceof Key) + { + keys.add((Key)key); + } + } + return keys; + } + + @SuppressWarnings("unchecked") + public <T> T removeAttachment(Class<T> clazz) + { + Key key = new Key(clazz, null); + Object value = oldEx.getContextInstance().deleteTransientVariable(key); + return (T)value; + } + + @SuppressWarnings("unchecked") + public <T> T removeAttachment(Class<T> clazz, String name) + { + Key key = new Key(clazz, name); + Object value = oldEx.getContextInstance().deleteTransientVariable(key); + return (T)value; + } + + @SuppressWarnings("unchecked") + public <T> T removeAttachment(String name) + { + Key key = new Key(null, name); + Object value = oldEx.getContextInstance().deleteTransientVariable(key); + return (T)value; + } + } } Modified: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/runtime/ActivityWrapper.java =================================================================== --- jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/runtime/ActivityWrapper.java 2008-07-04 10:04:28 UTC (rev 1507) +++ jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/runtime/ActivityWrapper.java 2008-07-04 10:10:04 UTC (rev 1508) @@ -23,7 +23,6 @@ // $Id$ -import org.jboss.bpm.JBPMException; import org.jboss.bpm.client.Execution; import org.jboss.bpm.runtime.Activity; import org.jbpm.context.exe.ContextInstance; @@ -39,12 +38,12 @@ */ public class ActivityWrapper implements ActionHandler { - private Action action; + private static final long serialVersionUID = 3617376097428098837L; + private Activity activity; public ActivityWrapper(Action action, Activity activity) { - this.action = action; this.activity = activity; } @@ -55,6 +54,6 @@ if (ex == null) throw new IllegalStateException("Cannot obtain API Execution"); - activity.execute(null, null); + activity.execute(ex.getNode(), ex.getContext()); } } |
From: <do-...@jb...> - 2008-07-04 10:04:36
|
Author: tho...@jb... Date: 2008-07-04 06:04:28 -0400 (Fri, 04 Jul 2008) New Revision: 1507 Modified: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/context/exe/ContextInstance.java Log: [JBPM-1255] return the previous value on deleteTransientVariable Modified: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/context/exe/ContextInstance.java =================================================================== --- jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/context/exe/ContextInstance.java 2008-07-04 09:55:14 UTC (rev 1506) +++ jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/context/exe/ContextInstance.java 2008-07-04 10:04:28 UTC (rev 1507) @@ -304,10 +304,10 @@ /** * removes the transient variable. */ - public void deleteTransientVariable(Object name) { + public Object deleteTransientVariable(Object name) { if (transientVariables == null) - return; - transientVariables.remove(name); + return null; + return transientVariables.remove(name); } |
From: <do-...@jb...> - 2008-07-04 09:55:19
|
Author: tho...@jb... Date: 2008-07-04 05:55:14 -0400 (Fri, 04 Jul 2008) New Revision: 1506 Modified: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/context/exe/ContextInstance.java Log: [JBPM-1255] Use Object as the key for transient variables Modified: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/context/exe/ContextInstance.java =================================================================== --- jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/context/exe/ContextInstance.java 2008-07-04 09:15:55 UTC (rev 1505) +++ jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/context/exe/ContextInstance.java 2008-07-04 09:55:14 UTC (rev 1506) @@ -257,7 +257,7 @@ /** * retrieves the transient variable for the given name. */ - public Object getTransientVariable(String name) { + public Object getTransientVariable(Object name) { Object transientVariable = null; if (transientVariables!= null) { transientVariable = transientVariables.get(name); @@ -268,7 +268,7 @@ /** * sets the transient variable for the given name to the given value. */ - public void setTransientVariable(String name, Object value) { + public void setTransientVariable(Object name, Object value) { if (transientVariables == null) { transientVariables = new HashMap(); } @@ -278,7 +278,7 @@ /** * tells if a transient variable with the given name is present. */ - public boolean hasTransientVariable(String name) { + public boolean hasTransientVariable(Object name) { if (transientVariables == null) { return false; } @@ -304,7 +304,7 @@ /** * removes the transient variable. */ - public void deleteTransientVariable(String name) { + public void deleteTransientVariable(Object name) { if (transientVariables == null) return; transientVariables.remove(name); |
From: <do-...@jb...> - 2008-07-04 09:15:58
|
Author: tho...@jb... Date: 2008-07-04 05:15:55 -0400 (Fri, 04 Jul 2008) New Revision: 1505 Added: api/trunk/docs/VioletUML/ClientView.png api/trunk/docs/VioletUML/EngineAndManagers.png api/trunk/docs/VioletUML/RuntimeView.png Modified: api/trunk/.classpath api/trunk/.project api/trunk/modules/api/src/main/java/org/jboss/bpm/Context.java api/trunk/modules/api/src/main/java/org/jboss/bpm/EngineShutdownException.java api/trunk/modules/api/src/main/java/org/jboss/bpm/InvalidProcessDefinitionException.java api/trunk/modules/api/src/main/java/org/jboss/bpm/JBPMException.java api/trunk/modules/api/src/main/java/org/jboss/bpm/NameNotUniqueException.java api/trunk/modules/api/src/main/java/org/jboss/bpm/NotImplementedException.java api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessDefinitionManager.java api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessEngineLocator.java api/trunk/modules/api/src/main/java/org/jboss/bpm/client/internal/DefaultContext.java api/trunk/modules/api/src/main/java/org/jboss/bpm/def/ProcessDefinition.java Log: Fix all eclipse warnings Modified: api/trunk/.classpath =================================================================== --- api/trunk/.classpath 2008-07-03 21:44:42 UTC (rev 1504) +++ api/trunk/.classpath 2008-07-04 09:15:55 UTC (rev 1505) @@ -1,9 +1,11 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="src" path="modules/api/src/main/java"/> - <classpathentry kind="src" path="modules/testsuite/src/test/java"/> - <classpathentry kind="src" path="modules/api/src/test/java"/> + <classpathentry kind="src" output="modules/api/target/classes" path="modules/api/src/main/java"/> + <classpathentry kind="src" output="modules/api/target/test-classes" path="modules/api/src/test/java"/> + <classpathentry excluding="**" kind="src" output="modules/api/target/test-classes" path="modules/api/src/test/resources"/> + <classpathentry kind="src" output="modules/testsuite/target/test-classes" path="modules/testsuite/src/test/java"/> + <classpathentry excluding="**" kind="src" output="modules/testsuite/target/test-classes" path="modules/testsuite/src/test/resources"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/> - <classpathentry kind="output" path="target/eclipse-classes"/> + <classpathentry kind="output" path="target/classes"/> </classpath> Modified: api/trunk/.project =================================================================== --- api/trunk/.project 2008-07-03 21:44:42 UTC (rev 1504) +++ api/trunk/.project 2008-07-04 09:15:55 UTC (rev 1505) @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <projectDescription> - <name>jbpm-api</name> + <name>jbpm-api-root</name> <comment></comment> <projects> </projects> Added: api/trunk/docs/VioletUML/ClientView.png =================================================================== (Binary files differ) Property changes on: api/trunk/docs/VioletUML/ClientView.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: api/trunk/docs/VioletUML/EngineAndManagers.png =================================================================== (Binary files differ) Property changes on: api/trunk/docs/VioletUML/EngineAndManagers.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: api/trunk/docs/VioletUML/RuntimeView.png =================================================================== (Binary files differ) Property changes on: api/trunk/docs/VioletUML/RuntimeView.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/Context.java =================================================================== --- api/trunk/modules/api/src/main/java/org/jboss/bpm/Context.java 2008-07-03 21:44:42 UTC (rev 1504) +++ api/trunk/modules/api/src/main/java/org/jboss/bpm/Context.java 2008-07-04 09:15:55 UTC (rev 1505) @@ -31,41 +31,79 @@ * @author Tho...@jb... * @since 20-Apr-2007 */ -public interface Context +public abstract class Context { /** Get arbitrary attachments */ - Collection<Key> getAttachments(); + public abstract Collection<Key> getAttachments(); /** Add arbitrary attachment */ - <T> T addAttachment(Class<T> clazz, Object value); + public abstract <T> T addAttachment(Class<T> clazz, Object value); /** Add arbitrary attachment with name */ - <T> T addAttachment(Class<T> clazz, String name, Object value); + public abstract <T> T addAttachment(Class<T> clazz, String name, Object value); /** Add arbitrary attachment with name */ - <T> T addAttachment(String name, Object value); + public abstract <T> T addAttachment(String name, Object value); /** Get an arbitrary attachment */ - <T> T getAttachment(Class<T> clazz); + public abstract <T> T getAttachment(Class<T> clazz); /** Get an arbitrary attachment */ - <T> T getAttachment(Class<T> clazz, String name); + public abstract <T> T getAttachment(Class<T> clazz, String name); /** Get an arbitrary attachment */ - <T> T getAttachment(String name); + public abstract <T> T getAttachment(String name); /** Remove arbitrary attachments */ - <T> T removeAttachment(Class<T> clazz); + public abstract <T> T removeAttachment(Class<T> clazz); /** Remove arbitrary attachments */ - <T> T removeAttachment(Class<T> clazz, String name); + public abstract <T> T removeAttachment(Class<T> clazz, String name); /** Remove arbitrary attachments */ - <T> T removeAttachment(String name); + public abstract <T> T removeAttachment(String name); - interface Key + public static class Key { - Class getClazz(); - String getName(); + Class<?> clazz; + String name; + + public Key(Class<?> clazz, String name) + { + this.clazz = clazz; + this.name = name; + } + + public Class<?> getClazz() + { + return clazz; + } + + public String getName() + { + return name; + } + + @Override + public boolean equals(Object obj) + { + if (!(obj instanceof Key)) + return false; + if (obj == this) + return true; + return obj.toString().equals(toString()); + } + + @Override + public int hashCode() + { + return toString().hashCode(); + } + + @Override + public String toString() + { + return "[" + clazz.getName() + "," + name + "]"; + } } } \ No newline at end of file Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/EngineShutdownException.java =================================================================== --- api/trunk/modules/api/src/main/java/org/jboss/bpm/EngineShutdownException.java 2008-07-03 21:44:42 UTC (rev 1504) +++ api/trunk/modules/api/src/main/java/org/jboss/bpm/EngineShutdownException.java 2008-07-04 09:15:55 UTC (rev 1505) @@ -32,6 +32,11 @@ */ public class EngineShutdownException extends JBPMException { + /** + * + */ + private static final long serialVersionUID = 1L; + public EngineShutdownException() { super(); } Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/InvalidProcessDefinitionException.java =================================================================== --- api/trunk/modules/api/src/main/java/org/jboss/bpm/InvalidProcessDefinitionException.java 2008-07-03 21:44:42 UTC (rev 1504) +++ api/trunk/modules/api/src/main/java/org/jboss/bpm/InvalidProcessDefinitionException.java 2008-07-04 09:15:55 UTC (rev 1505) @@ -32,6 +32,11 @@ */ public class InvalidProcessDefinitionException extends JBPMException { + /** + * + */ + private static final long serialVersionUID = 1L; + public InvalidProcessDefinitionException() { super(); Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/JBPMException.java =================================================================== --- api/trunk/modules/api/src/main/java/org/jboss/bpm/JBPMException.java 2008-07-03 21:44:42 UTC (rev 1504) +++ api/trunk/modules/api/src/main/java/org/jboss/bpm/JBPMException.java 2008-07-04 09:15:55 UTC (rev 1505) @@ -31,6 +31,11 @@ */ public class JBPMException extends RuntimeException { + /** + * + */ + private static final long serialVersionUID = 1L; + public JBPMException() { super(); } Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/NameNotUniqueException.java =================================================================== --- api/trunk/modules/api/src/main/java/org/jboss/bpm/NameNotUniqueException.java 2008-07-03 21:44:42 UTC (rev 1504) +++ api/trunk/modules/api/src/main/java/org/jboss/bpm/NameNotUniqueException.java 2008-07-04 09:15:55 UTC (rev 1505) @@ -31,6 +31,11 @@ */ public class NameNotUniqueException extends JBPMException { + /** + * + */ + private static final long serialVersionUID = 1L; + public NameNotUniqueException() { super(); } Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/NotImplementedException.java =================================================================== --- api/trunk/modules/api/src/main/java/org/jboss/bpm/NotImplementedException.java 2008-07-03 21:44:42 UTC (rev 1504) +++ api/trunk/modules/api/src/main/java/org/jboss/bpm/NotImplementedException.java 2008-07-04 09:15:55 UTC (rev 1505) @@ -31,6 +31,11 @@ */ public class NotImplementedException extends RuntimeException { + /** + * + */ + private static final long serialVersionUID = 1L; + public NotImplementedException() { super(); } Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessDefinitionManager.java =================================================================== --- api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessDefinitionManager.java 2008-07-03 21:44:42 UTC (rev 1504) +++ api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessDefinitionManager.java 2008-07-04 09:15:55 UTC (rev 1505) @@ -31,7 +31,6 @@ import org.jboss.bpm.EngineShutdownException; import org.jboss.bpm.def.ProcessDefinition; -import org.jboss.bpm.def.internal.AbstractProcessDefinition; /** * The process definition manager is the entry point to create, find and otherwise manage process definitions. @@ -117,7 +116,7 @@ ProcessDefinition pdef = null; for (ProcessDefinition aux : pdefs) { - if (pdef.getName().equals(name)) + if (aux.getName().equals(name)) { pdef = aux; break; Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessEngineLocator.java =================================================================== --- api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessEngineLocator.java 2008-07-03 21:44:42 UTC (rev 1504) +++ api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessEngineLocator.java 2008-07-04 09:15:55 UTC (rev 1505) @@ -32,17 +32,17 @@ import org.jboss.kernel.spi.registry.KernelRegistryEntryNotFoundException; /** - * The ProcessEngineLocator is the main entry point for all client operations. + * The ProcessEngineLocator is the main entry point for all client operations. It locates the process engine instance shared by all clients. * - * It locates the process engine instance shared by all clients. - * * @author tho...@jb... * @since 18-Jun-2008 */ -public abstract class ProcessEngineLocator { +public abstract class ProcessEngineLocator +{ // Hide the constructor - private ProcessEngineLocator() { + private ProcessEngineLocator() + { } /** @@ -50,11 +50,12 @@ * * @return The configured instance of a process engine */ - public static ProcessEngine locateProcessEngine() { - + @SuppressWarnings("deprecation") + public static ProcessEngine locateProcessEngine() + { Kernel kernel = KernelLocator.getKernel(); - KernelRegistryEntry entry = null; - if (kernel == null) + KernelRegistryEntry entry = null; + if (kernel == null) { deployEngineConfiguration(); kernel = KernelLocator.getKernel(); @@ -62,20 +63,24 @@ } else { - try { + try + { entry = kernel.getRegistry().getEntry(ProcessEngine.BEAN_NAME_JBPMENGINE); - } catch (KernelRegistryEntryNotFoundException ex) { + } + catch (KernelRegistryEntryNotFoundException ex) + { deployEngineConfiguration(); entry = kernel.getRegistry().getEntry(ProcessEngine.BEAN_NAME_JBPMENGINE); } } - ProcessEngine engine = (ProcessEngine) entry.getTarget(); + ProcessEngine engine = (ProcessEngine)entry.getTarget(); return engine; } - private static void deployEngineConfiguration() { - + private static void deployEngineConfiguration() + { + String config = ProcessEngine.JBPM_ENGINE_CONFIG; URL url = Thread.currentThread().getContextClassLoader().getResource(config); if (url == null) Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/client/internal/DefaultContext.java =================================================================== --- api/trunk/modules/api/src/main/java/org/jboss/bpm/client/internal/DefaultContext.java 2008-07-03 21:44:42 UTC (rev 1504) +++ api/trunk/modules/api/src/main/java/org/jboss/bpm/client/internal/DefaultContext.java 2008-07-04 09:15:55 UTC (rev 1505) @@ -35,7 +35,7 @@ * @author Tho...@jb... * @since 20-Apr-2007 */ -public class DefaultContext implements Context +public class DefaultContext extends Context { private Map<Key, Object> attachments = new HashMap<Key, Object>(); @@ -44,92 +44,57 @@ return attachments.keySet(); } + @SuppressWarnings("unchecked") public <T> T getAttachment(Class<T> clazz) { - return (T)attachments.get(new KeyImpl(clazz, null)); + return (T)attachments.get(new Key(clazz, null)); } + @SuppressWarnings("unchecked") public <T> T getAttachment(Class<T> clazz, String name) { - return (T)attachments.get(new KeyImpl(clazz, name)); + return (T)attachments.get(new Key(clazz, name)); } + @SuppressWarnings("unchecked") public <T> T getAttachment(String name) { - return (T)attachments.get(new KeyImpl(Object.class, name)); + return (T)attachments.get(new Key(Object.class, name)); } + @SuppressWarnings("unchecked") public <T> T addAttachment(Class<T> clazz, Object obj) { - return (T)attachments.put(new KeyImpl(clazz, null), obj); + return (T)attachments.put(new Key(clazz, null), obj); } + @SuppressWarnings("unchecked") public <T> T addAttachment(Class<T> clazz, String name, Object obj) { - return (T)attachments.put(new KeyImpl(clazz, name), obj); + return (T)attachments.put(new Key(clazz, name), obj); } + @SuppressWarnings("unchecked") public <T> T addAttachment(String name, Object obj) { - return (T)attachments.put(new KeyImpl(Object.class, name), obj); + return (T)attachments.put(new Key(Object.class, name), obj); } + @SuppressWarnings("unchecked") public <T> T removeAttachment(Class<T> clazz) { - return (T)attachments.remove(new KeyImpl(clazz, null)); + return (T)attachments.remove(new Key(clazz, null)); } + @SuppressWarnings("unchecked") public <T> T removeAttachment(Class<T> clazz, String name) { - return (T)attachments.remove(new KeyImpl(clazz, name)); + return (T)attachments.remove(new Key(clazz, name)); } + @SuppressWarnings("unchecked") public <T> T removeAttachment(String name) { - return (T)attachments.remove(new KeyImpl(Object.class, name)); + return (T)attachments.remove(new Key(Object.class, name)); } - - static class KeyImpl implements Key - { - Class clazz; - String name; - - public KeyImpl(Class clazz, String name) - { - this.clazz = clazz; - this.name = name; - } - - public Class getClazz() - { - return clazz; - } - - public String getName() - { - return name; - } - - @Override - public boolean equals(Object obj) - { - if (!(obj instanceof Key)) - return false; - if (obj == this) - return true; - return obj.toString().equals(toString()); - } - - @Override - public int hashCode() - { - return toString().hashCode(); - } - - @Override - public String toString() - { - return "[" + clazz.getName() + "," + name + "]"; - } - } } Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/def/ProcessDefinition.java =================================================================== --- api/trunk/modules/api/src/main/java/org/jboss/bpm/def/ProcessDefinition.java 2008-07-03 21:44:42 UTC (rev 1504) +++ api/trunk/modules/api/src/main/java/org/jboss/bpm/def/ProcessDefinition.java 2008-07-04 09:15:55 UTC (rev 1505) @@ -26,7 +26,6 @@ import java.util.List; import java.util.Set; -import org.jboss.bpm.InvalidProcessDefinitionException; import org.jboss.bpm.client.Execution; import org.jboss.bpm.client.ProcessInstance; |
From: <do-...@jb...> - 2008-07-03 21:44:44
|
Author: tho...@jb... Date: 2008-07-03 17:44:42 -0400 (Thu, 03 Jul 2008) New Revision: 1504 Removed: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/NodeImpl.java Modified: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ExecutionImpl.java jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ProcessInstanceImpl.java jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/EndNodeImpl.java jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/NodeImpl.java jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/ProcessDefinitionAdapter.java jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/ProcessDefinitionImpl.java jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/StartNodeImpl.java Log: Refactor API to use interfaces Modified: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ExecutionImpl.java =================================================================== --- jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ExecutionImpl.java 2008-07-03 21:44:34 UTC (rev 1503) +++ jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ExecutionImpl.java 2008-07-03 21:44:42 UTC (rev 1504) @@ -23,8 +23,11 @@ //$Id$ +import org.jboss.bpm.Context; +import org.jboss.bpm.NotImplementedException; import org.jboss.bpm.client.Execution; import org.jboss.bpm.client.ProcessInstance; +import org.jboss.bpm.client.internal.AbstractExecution; import org.jboss.bpm.def.Node; /** @@ -33,7 +36,7 @@ * @author tho...@jb... * @since 18-Jun-2008 */ -public class ExecutionImpl extends Execution +public class ExecutionImpl extends AbstractExecution { org.jbpm.graph.exe.Execution oldEx; @@ -70,4 +73,10 @@ { oldEx.setKey(name); } + + @Override + public Context getContext() + { + throw new NotImplementedException(); + } } Deleted: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/NodeImpl.java =================================================================== --- jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/NodeImpl.java 2008-07-03 21:44:34 UTC (rev 1503) +++ jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/NodeImpl.java 2008-07-03 21:44:42 UTC (rev 1504) @@ -1,57 +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.jbpm.integration.client; - -//$Id$ - -import org.jboss.bpm.def.Node; -import org.jboss.bpm.def.ProcessDefinition; - -/** - * TODO - * - * @author tho...@jb... - * @since 18-Jun-2008 - */ -public class NodeImpl extends Node -{ - private org.jbpm.graph.def.Node oldNode; - - NodeImpl(ProcessDefinition def, org.jbpm.graph.def.Node oldNode) - { - super(def); - this.oldNode = oldNode; - init(oldNode.getName()); - } - - @Override - public String getName() - { - return oldNode.getName(); - } - - @Override - protected void setName(String name) - { - oldNode.setName(name); - } -} Modified: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ProcessInstanceImpl.java =================================================================== --- jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ProcessInstanceImpl.java 2008-07-03 21:44:34 UTC (rev 1503) +++ jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ProcessInstanceImpl.java 2008-07-03 21:44:42 UTC (rev 1504) @@ -23,7 +23,7 @@ //$Id$ -import org.jboss.bpm.client.ProcessInstance; +import org.jboss.bpm.client.internal.AbstractProcessInstance; import org.jboss.bpm.def.ProcessDefinition; /** @@ -32,7 +32,7 @@ * @author tho...@jb... * @since 18-Jun-2008 */ -public class ProcessInstanceImpl extends ProcessInstance +public class ProcessInstanceImpl extends AbstractProcessInstance { ProcessInstanceImpl(ProcessDefinition pdef) { Modified: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/EndNodeImpl.java =================================================================== --- jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/EndNodeImpl.java 2008-07-03 21:44:34 UTC (rev 1503) +++ jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/EndNodeImpl.java 2008-07-03 21:44:42 UTC (rev 1504) @@ -32,26 +32,10 @@ * @author tho...@jb... * @since 18-Jun-2008 */ -public class EndNodeImpl extends EndNode +public class EndNodeImpl extends NodeImpl implements EndNode { - private org.jbpm.graph.def.Node oldNode; - - EndNodeImpl(ProcessDefinition def, org.jbpm.graph.def.Node oldNode) + public EndNodeImpl(ProcessDefinition def, org.jbpm.graph.def.Node oldNode) { - super(def); - this.oldNode = oldNode; - init(oldNode.getName()); + super(def, oldNode); } - - @Override - public String getName() - { - return oldNode.getName(); - } - - @Override - protected void setName(String name) - { - oldNode.setName(name); - } } Modified: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/NodeImpl.java =================================================================== --- jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/NodeImpl.java 2008-07-03 21:44:34 UTC (rev 1503) +++ jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/NodeImpl.java 2008-07-03 21:44:42 UTC (rev 1504) @@ -23,8 +23,8 @@ //$Id$ -import org.jboss.bpm.def.Node; import org.jboss.bpm.def.ProcessDefinition; +import org.jboss.bpm.def.internal.AbstractNode; /** * TODO @@ -32,7 +32,7 @@ * @author tho...@jb... * @since 18-Jun-2008 */ -public class NodeImpl extends Node +public class NodeImpl extends AbstractNode { private org.jbpm.graph.def.Node oldNode; Modified: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/ProcessDefinitionAdapter.java =================================================================== --- jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/ProcessDefinitionAdapter.java 2008-07-03 21:44:34 UTC (rev 1503) +++ jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/ProcessDefinitionAdapter.java 2008-07-03 21:44:42 UTC (rev 1504) @@ -21,7 +21,7 @@ */ package org.jbpm.integration.def; -// $Id$ +// $Id: $ import java.util.List; Modified: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/ProcessDefinitionImpl.java =================================================================== --- jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/ProcessDefinitionImpl.java 2008-07-03 21:44:34 UTC (rev 1503) +++ jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/ProcessDefinitionImpl.java 2008-07-03 21:44:42 UTC (rev 1504) @@ -24,7 +24,7 @@ //$Id$ import org.jboss.bpm.def.Node; -import org.jboss.bpm.def.ProcessDefinition; +import org.jboss.bpm.def.internal.AbstractProcessDefinition; /** * A jBPM3 implementation of a process definition @@ -32,7 +32,7 @@ * @author tho...@jb... * @since 18-Jun-2008 */ -public class ProcessDefinitionImpl extends ProcessDefinition +public class ProcessDefinitionImpl extends AbstractProcessDefinition { public org.jbpm.graph.def.ProcessDefinition oldPD; @@ -42,7 +42,7 @@ init(oldPD.getName()); } - // Add a node + // Provide public access public void addNode(Node apiNode) { super.addNode(apiNode); Modified: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/StartNodeImpl.java =================================================================== --- jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/StartNodeImpl.java 2008-07-03 21:44:34 UTC (rev 1503) +++ jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/StartNodeImpl.java 2008-07-03 21:44:42 UTC (rev 1504) @@ -32,26 +32,10 @@ * @author tho...@jb... * @since 18-Jun-2008 */ -public class StartNodeImpl extends StartNode +public class StartNodeImpl extends NodeImpl implements StartNode { - private org.jbpm.graph.def.Node oldNode; - StartNodeImpl(ProcessDefinition def, org.jbpm.graph.def.Node oldNode) { - super(def); - this.oldNode = oldNode; - init(oldNode.getName()); + super(def, oldNode); } - - @Override - public String getName() - { - return oldNode.getName(); - } - - @Override - protected void setName(String name) - { - oldNode.setName(name); - } } |
From: <do-...@jb...> - 2008-07-03 21:44:42
|
Author: tho...@jb... Date: 2008-07-03 17:44:34 -0400 (Thu, 03 Jul 2008) New Revision: 1503 Added: api/trunk/modules/api/src/main/java/org/jboss/bpm/client/internal/ api/trunk/modules/api/src/main/java/org/jboss/bpm/client/internal/AbstractExecution.java api/trunk/modules/api/src/main/java/org/jboss/bpm/client/internal/AbstractProcessInstance.java api/trunk/modules/api/src/main/java/org/jboss/bpm/client/internal/DefaultContext.java api/trunk/modules/api/src/main/java/org/jboss/bpm/def/internal/ api/trunk/modules/api/src/main/java/org/jboss/bpm/def/internal/AbstractNode.java api/trunk/modules/api/src/main/java/org/jboss/bpm/def/internal/AbstractProcessDefinition.java api/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/internal/ api/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/internal/AbstractRuntimeNode.java Removed: api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ContextImpl.java Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/client/Execution.java api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessDefinitionManager.java api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessInstance.java api/trunk/modules/api/src/main/java/org/jboss/bpm/def/EndNode.java api/trunk/modules/api/src/main/java/org/jboss/bpm/def/Node.java api/trunk/modules/api/src/main/java/org/jboss/bpm/def/ProcessDefinition.java api/trunk/modules/api/src/main/java/org/jboss/bpm/def/StartNode.java api/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/RuntimeExecution.java api/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/RuntimeNode.java api/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/TransitionRouter.java Log: Refactor API to use interfaces Deleted: api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ContextImpl.java =================================================================== --- api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ContextImpl.java 2008-07-03 16:48:16 UTC (rev 1502) +++ api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ContextImpl.java 2008-07-03 21:44:34 UTC (rev 1503) @@ -1,135 +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.client; - -//$Id$ - -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -import org.jboss.bpm.Context; - -/** - * A general extendible artifact - * - * @author Tho...@jb... - * @since 20-Apr-2007 - */ -class ContextImpl implements Context -{ - private Map<Key, Object> attachments = new HashMap<Key, Object>(); - - public Collection<Key> getAttachments() - { - return attachments.keySet(); - } - - public <T> T getAttachment(Class<T> clazz) - { - return (T)attachments.get(new KeyImpl(clazz, null)); - } - - public <T> T getAttachment(Class<T> clazz, String name) - { - return (T)attachments.get(new KeyImpl(clazz, name)); - } - - public <T> T getAttachment(String name) - { - return (T)attachments.get(new KeyImpl(Object.class, name)); - } - - public <T> T addAttachment(Class<T> clazz, Object obj) - { - return (T)attachments.put(new KeyImpl(clazz, null), obj); - } - - public <T> T addAttachment(Class<T> clazz, String name, Object obj) - { - return (T)attachments.put(new KeyImpl(clazz, name), obj); - } - - public <T> T addAttachment(String name, Object obj) - { - return (T)attachments.put(new KeyImpl(Object.class, name), obj); - } - - public <T> T removeAttachment(Class<T> clazz) - { - return (T)attachments.remove(new KeyImpl(clazz, null)); - } - - public <T> T removeAttachment(Class<T> clazz, String name) - { - return (T)attachments.remove(new KeyImpl(clazz, name)); - } - - public <T> T removeAttachment(String name) - { - return (T)attachments.remove(new KeyImpl(Object.class, name)); - } - - static class KeyImpl implements Key - { - Class clazz; - String name; - - public KeyImpl(Class clazz, String name) - { - this.clazz = clazz; - this.name = name; - } - - public Class getClazz() - { - return clazz; - } - - public String getName() - { - return name; - } - - @Override - public boolean equals(Object obj) - { - if (!(obj instanceof Key)) - return false; - if (obj == this) - return true; - return obj.toString().equals(toString()); - } - - @Override - public int hashCode() - { - return toString().hashCode(); - } - - @Override - public String toString() - { - return "[" + clazz.getName() + "," + name + "]"; - } - } -} Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/client/Execution.java =================================================================== --- api/trunk/modules/api/src/main/java/org/jboss/bpm/client/Execution.java 2008-07-03 16:48:16 UTC (rev 1502) +++ api/trunk/modules/api/src/main/java/org/jboss/bpm/client/Execution.java 2008-07-03 21:44:34 UTC (rev 1503) @@ -21,94 +21,45 @@ */ package org.jboss.bpm.client; +//$Id$ + import org.jboss.bpm.Context; import org.jboss.bpm.def.Node; -// $Id$ - /** - * Represents an execution of a process instance. The name of an execution is unique in the scope of the process instance. + * Represents an execution of a process instance. * + * The name of an execution is unique in the scope of the process instance. + * * @author tho...@jb... * @since 18-Jun-2008 */ -public abstract class Execution +public interface Execution { - // The associated process instance - private ProcessInstance pinst; - // The execution context - private Context context = new ContextImpl(); - // Construct the execution - protected Execution(ProcessInstance pinst) - { - if (pinst == null) - throw new IllegalArgumentException("Process instance cannot be null"); - - this.pinst = pinst; - } - - // Construct the execution from a copy - protected Execution(Execution ex) - { - this(ex.getProcessInstance()); - } - - // Call to initialize fully - protected void init(String name) - { - if (name == null) - { - name = "AnonymousExecution#" + pinst.getExecutions().size(); - setName(name); - } - } - /** * Get the associated process instance */ - public ProcessInstance getProcessInstance() - { - return pinst; - } + ProcessInstance getProcessInstance(); /** * Get the name for the execution */ - public abstract String getName(); + String getName(); /** * Get the context for this execution */ - public Context getContext() - { - return context; - } + Context getContext(); - // Set the name for the execution - protected abstract void setName(String name); - /** * Get the current node for this execution */ - public final Node getNode() - { - Node node = getNodeOverride(); - return node; - } + Node getNode(); - // Override to get the node - protected abstract Node getNodeOverride(); - /** * Signal this execution */ - public final void signal() - { - signalOverride(); - } + void signal(); - // Override to implement execution signalling - protected abstract void signalOverride(); - } \ No newline at end of file Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessDefinitionManager.java =================================================================== --- api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessDefinitionManager.java 2008-07-03 16:48:16 UTC (rev 1502) +++ api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessDefinitionManager.java 2008-07-03 21:44:34 UTC (rev 1503) @@ -31,6 +31,7 @@ import org.jboss.bpm.EngineShutdownException; import org.jboss.bpm.def.ProcessDefinition; +import org.jboss.bpm.def.internal.AbstractProcessDefinition; /** * The process definition manager is the entry point to create, find and otherwise manage process definitions. Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessInstance.java =================================================================== --- api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessInstance.java 2008-07-03 16:48:16 UTC (rev 1502) +++ api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessInstance.java 2008-07-03 21:44:34 UTC (rev 1503) @@ -21,114 +21,54 @@ */ package org.jboss.bpm.client; -// $Id$ +//$Id$ -import java.util.Collections; -import java.util.HashSet; import java.util.Set; import org.jboss.bpm.Context; +import org.jboss.bpm.client.internal.AbstractExecution; import org.jboss.bpm.def.ProcessDefinition; /** - * Represents an instance of a BPM process. It is the combination of a process definition plus its associated instance data + * Represents an instance of a BPM process. * + * It is the combination of a process definition plus its associated instance data + * * @author tho...@jb... * @since 18-Jun-2008 */ -public abstract class ProcessInstance +public interface ProcessInstance { - // The process definition - private ProcessDefinition pdef; - // The name - private String name; - // The map of executions - private Set<Execution> execs = new HashSet<Execution>(); - // The pricess instance context - private Context context = new ContextImpl(); - - // Construct a process instance with a given process definition - protected ProcessInstance(ProcessDefinition pdef) - { - if (pdef == null) - throw new IllegalArgumentException("Process definition cannot be null"); - - this.pdef = pdef; - } - - // Call to initialize fully - protected void init(String name) - { - if (name == null) - { - name = "AnonymousInst#" + pdef.getProcessInstances().size(); - setName(name); - } - } - - /** + /* * Get the associated process definition */ - public ProcessDefinition getProcessDefinition() - { - return pdef; - } + public abstract ProcessDefinition getProcessDefinition(); - /** + /* * Get the name of this process instance */ - public String getName() - { - return name; - } + public abstract String getName(); - private void setName(String name) - { - this.name = name; - } - - /** + /* * Get the context for this execution */ - public Context getContext() - { - return context; - } + public abstract Context getContext(); - /** + /* * Get the set of registered executions */ - public Set<Execution> getExecutions() - { - return Collections.unmodifiableSet(execs); - } + public abstract Set<AbstractExecution> getExecutions(); - /** + /* * Find an execution for a given name * * @return null if it cannot be found */ - public Execution findExecution(String name) - { - for (Execution ex : execs) - { - if (ex.getName() == name) - return ex; - } - return null; - } + public abstract Execution findExecution(String name); - /** + /* * Remove an execution for a given name */ - public void removeExecution(String name) - { - for (Execution ex : execs) - { - if (ex.getName() == name) - { - execs.remove(ex); - } - } - } + public abstract void removeExecution(String name); + } \ No newline at end of file Added: api/trunk/modules/api/src/main/java/org/jboss/bpm/client/internal/AbstractExecution.java =================================================================== --- api/trunk/modules/api/src/main/java/org/jboss/bpm/client/internal/AbstractExecution.java (rev 0) +++ api/trunk/modules/api/src/main/java/org/jboss/bpm/client/internal/AbstractExecution.java 2008-07-03 21:44:34 UTC (rev 1503) @@ -0,0 +1,116 @@ +/* + * 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.client.internal; + +//$Id$ + +import org.jboss.bpm.Context; +import org.jboss.bpm.client.Execution; +import org.jboss.bpm.client.ProcessInstance; +import org.jboss.bpm.def.Node; + +/** + * Represents an execution of a process instance. + * + * The name of an execution is unique in the scope of the process instance. + * + * @author tho...@jb... + * @since 18-Jun-2008 + */ +public abstract class AbstractExecution implements Execution +{ + // The associated process instance + private ProcessInstance pinst; + + // Construct the execution + protected AbstractExecution(ProcessInstance pinst) + { + if (pinst == null) + throw new IllegalArgumentException("Process instance cannot be null"); + + this.pinst = pinst; + } + + // Construct the execution from a copy + protected AbstractExecution(Execution ex) + { + this(ex.getProcessInstance()); + } + + // Call to initialize fully + protected void init(String name) + { + if (name == null) + { + name = "AnonymousExecution#" + pinst.getExecutions().size(); + setName(name); + } + } + + /* + * Get the associated process instance + */ + /* (non-Javadoc) + * @see org.jboss.bpm.client.Execution#getProcessInstance() + */ + public ProcessInstance getProcessInstance() + { + return pinst; + } + + /** + * Get the name for the execution + */ + public abstract String getName(); + + /** + * Get the context for this execution + */ + public abstract Context getContext(); + + // Set the name for the execution + protected abstract void setName(String name); + + /** + * Get the current node for this execution + */ + public final Node getNode() + { + Node node = getNodeOverride(); + return node; + } + + // Override to get the node + protected abstract Node getNodeOverride(); + + /** + * Signal this execution + */ + public final void signal() + { + signalOverride(); + } + + // Override to implement execution signalling + protected abstract void signalOverride(); + +} \ No newline at end of file Property changes on: api/trunk/modules/api/src/main/java/org/jboss/bpm/client/internal/AbstractExecution.java ___________________________________________________________________ Name: svn:keywords + Id Revision Name: svn:eol-style + LF Added: api/trunk/modules/api/src/main/java/org/jboss/bpm/client/internal/AbstractProcessInstance.java =================================================================== --- api/trunk/modules/api/src/main/java/org/jboss/bpm/client/internal/AbstractProcessInstance.java (rev 0) +++ api/trunk/modules/api/src/main/java/org/jboss/bpm/client/internal/AbstractProcessInstance.java 2008-07-03 21:44:34 UTC (rev 1503) @@ -0,0 +1,153 @@ +/* + * 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.client.internal; + +// $Id$ + +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +import org.jboss.bpm.Context; +import org.jboss.bpm.client.Execution; +import org.jboss.bpm.client.ProcessInstance; +import org.jboss.bpm.def.ProcessDefinition; + +/** + * Represents an instance of a BPM process. + * + * It is the combination of a process definition plus its associated instance data + * + * @author tho...@jb... + * @since 18-Jun-2008 + */ +public abstract class AbstractProcessInstance implements ProcessInstance +{ + // The process definition + private ProcessDefinition pdef; + // The name + private String name; + // The map of executions + private Set<AbstractExecution> execs = new HashSet<AbstractExecution>(); + // The meta data for this process instance + private Context context = new DefaultContext(); + + // Construct a process instance with a given process definition + protected AbstractProcessInstance(ProcessDefinition pdef) + { + if (pdef == null) + throw new IllegalArgumentException("Process definition cannot be null"); + + this.pdef = pdef; + } + + // Call to initialize fully + protected void init(String name) + { + if (name == null) + { + name = "AnonymousInst#" + pdef.getProcessInstances().size(); + setName(name); + } + } + + /* + * Get the associated process definition + */ + /* (non-Javadoc) + * @see org.jboss.bpm.client.internal.ProcessInstance#getProcessDefinition() + */ + public ProcessDefinition getProcessDefinition() + { + return pdef; + } + + /* + * Get the name of this process instance + */ + /* (non-Javadoc) + * @see org.jboss.bpm.client.internal.ProcessInstance#getName() + */ + public String getName() + { + return name; + } + + private void setName(String name) + { + this.name = name; + } + + /** + * Get the context for this process instance + */ + public Context getContext() + { + return context; + } + + /* + * Get the set of registered executions + */ + /* (non-Javadoc) + * @see org.jboss.bpm.client.internal.ProcessInstance#getExecutions() + */ + public Set<AbstractExecution> getExecutions() + { + return Collections.unmodifiableSet(execs); + } + + /* + * Find an execution for a given name + * + * @return null if it cannot be found + */ + /* (non-Javadoc) + * @see org.jboss.bpm.client.internal.ProcessInstance#findExecution(java.lang.String) + */ + public Execution findExecution(String name) + { + for (Execution ex : execs) + { + if (ex.getName() == name) + return ex; + } + return null; + } + + /* + * Remove an execution for a given name + */ + /* (non-Javadoc) + * @see org.jboss.bpm.client.internal.ProcessInstance#removeExecution(java.lang.String) + */ + public void removeExecution(String name) + { + for (Execution ex : execs) + { + if (ex.getName() == name) + { + execs.remove(ex); + } + } + } +} \ No newline at end of file Property changes on: api/trunk/modules/api/src/main/java/org/jboss/bpm/client/internal/AbstractProcessInstance.java ___________________________________________________________________ Name: svn:keywords + Id Revision Name: svn:eol-style + LF Added: api/trunk/modules/api/src/main/java/org/jboss/bpm/client/internal/DefaultContext.java =================================================================== --- api/trunk/modules/api/src/main/java/org/jboss/bpm/client/internal/DefaultContext.java (rev 0) +++ api/trunk/modules/api/src/main/java/org/jboss/bpm/client/internal/DefaultContext.java 2008-07-03 21:44:34 UTC (rev 1503) @@ -0,0 +1,135 @@ +/* + * 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.client.internal; + +//$Id$ + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +import org.jboss.bpm.Context; + +/** + * A general extendible artifact + * + * @author Tho...@jb... + * @since 20-Apr-2007 + */ +public class DefaultContext implements Context +{ + private Map<Key, Object> attachments = new HashMap<Key, Object>(); + + public Collection<Key> getAttachments() + { + return attachments.keySet(); + } + + public <T> T getAttachment(Class<T> clazz) + { + return (T)attachments.get(new KeyImpl(clazz, null)); + } + + public <T> T getAttachment(Class<T> clazz, String name) + { + return (T)attachments.get(new KeyImpl(clazz, name)); + } + + public <T> T getAttachment(String name) + { + return (T)attachments.get(new KeyImpl(Object.class, name)); + } + + public <T> T addAttachment(Class<T> clazz, Object obj) + { + return (T)attachments.put(new KeyImpl(clazz, null), obj); + } + + public <T> T addAttachment(Class<T> clazz, String name, Object obj) + { + return (T)attachments.put(new KeyImpl(clazz, name), obj); + } + + public <T> T addAttachment(String name, Object obj) + { + return (T)attachments.put(new KeyImpl(Object.class, name), obj); + } + + public <T> T removeAttachment(Class<T> clazz) + { + return (T)attachments.remove(new KeyImpl(clazz, null)); + } + + public <T> T removeAttachment(Class<T> clazz, String name) + { + return (T)attachments.remove(new KeyImpl(clazz, name)); + } + + public <T> T removeAttachment(String name) + { + return (T)attachments.remove(new KeyImpl(Object.class, name)); + } + + static class KeyImpl implements Key + { + Class clazz; + String name; + + public KeyImpl(Class clazz, String name) + { + this.clazz = clazz; + this.name = name; + } + + public Class getClazz() + { + return clazz; + } + + public String getName() + { + return name; + } + + @Override + public boolean equals(Object obj) + { + if (!(obj instanceof Key)) + return false; + if (obj == this) + return true; + return obj.toString().equals(toString()); + } + + @Override + public int hashCode() + { + return toString().hashCode(); + } + + @Override + public String toString() + { + return "[" + clazz.getName() + "," + name + "]"; + } + } +} Property changes on: api/trunk/modules/api/src/main/java/org/jboss/bpm/client/internal/DefaultContext.java ___________________________________________________________________ Name: svn:keywords + Id Revision Name: svn:eol-style + LF Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/def/EndNode.java =================================================================== --- api/trunk/modules/api/src/main/java/org/jboss/bpm/def/EndNode.java 2008-07-03 16:48:16 UTC (rev 1502) +++ api/trunk/modules/api/src/main/java/org/jboss/bpm/def/EndNode.java 2008-07-03 21:44:34 UTC (rev 1503) @@ -30,10 +30,6 @@ * @author tho...@jb... * @since 18-Jun-2008 */ -public abstract class EndNode extends Node +public interface EndNode extends Node { - protected EndNode(ProcessDefinition pdef) - { - super(pdef); - } } \ No newline at end of file Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/def/Node.java =================================================================== --- api/trunk/modules/api/src/main/java/org/jboss/bpm/def/Node.java 2008-07-03 16:48:16 UTC (rev 1502) +++ api/trunk/modules/api/src/main/java/org/jboss/bpm/def/Node.java 2008-07-03 21:44:34 UTC (rev 1503) @@ -21,60 +21,18 @@ */ package org.jboss.bpm.def; +// $Id$ -// $Id:$ -/** - * Represents a node in the process definition. A node is an immutable object. The name of a node is unique in the scope of the process definition. - * - * @author tho...@jb... - * @since 18-Jun-2008 - */ -public abstract class Node +public interface Node { - // The associated process definition - private ProcessDefinition pdef; + /** + * Get the associated process instance + */ + ProcessDefinition getProcessDefinition(); - // Construct the node - protected Node(ProcessDefinition pdef) - { - if (pdef == null) - throw new IllegalArgumentException("Process definition cannot be null"); - - this.pdef = pdef; - } - - // Construct the node from a copy - protected Node(Node node) - { - this(node.getProcessDefinition()); - } - - // Call to initialize fully - protected void init(String name) - { - if (name == null) - { - name = "AnonymousNode#" + pdef.getNodes().size(); - setName(name); - } - } - - /** Get the associated process definition */ - public ProcessDefinition getProcessDefinition() - { - return pdef; - } - - /** Get the node name */ - public abstract String getName(); - - // Set the node name - protected abstract void setName(String name); - - /** Returns a string representation of the object. */ - public String toString() - { - return "Node[" + getName() + "]"; - } + /** + * Get the node name + */ + String getName(); } \ No newline at end of file Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/def/ProcessDefinition.java =================================================================== --- api/trunk/modules/api/src/main/java/org/jboss/bpm/def/ProcessDefinition.java 2008-07-03 16:48:16 UTC (rev 1502) +++ api/trunk/modules/api/src/main/java/org/jboss/bpm/def/ProcessDefinition.java 2008-07-03 21:44:34 UTC (rev 1503) @@ -23,21 +23,12 @@ // $Id$ -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; import java.util.List; import java.util.Set; import org.jboss.bpm.InvalidProcessDefinitionException; -import org.jboss.bpm.NameNotUniqueException; import org.jboss.bpm.client.Execution; -import org.jboss.bpm.client.ExecutionFactory; -import org.jboss.bpm.client.ProcessDefinitionManager; -import org.jboss.bpm.client.ProcessEngine; -import org.jboss.bpm.client.ProcessEngineLocator; import org.jboss.bpm.client.ProcessInstance; -import org.jboss.bpm.client.ProcessInstanceFactory; /** * Represents the structural definition of a BPM process @@ -45,192 +36,65 @@ * @author tho...@jb... * @since 18-Jun-2008 */ -public abstract class ProcessDefinition +public interface ProcessDefinition { - // The list of nodes - private List<Node> nodes = new ArrayList<Node>(); - // The set of process instances - private Set<ProcessInstance> pinstSet = new HashSet<ProcessInstance>(); - - // Construct the process definition - protected ProcessDefinition() - { - } - - // Call to initialize fully - protected void init(String name) - { - if (name == null) - { - ProcessDefinitionManager pdm = ProcessDefinitionManager.locateProcessDefinitionManager(); - name = "AnonymousDef#" + pdm.getProcessDefinitions().size(); - setName(name); - } - } - /** * Get the name */ - public abstract String getName(); + String getName(); - // Set the name - protected abstract void setName(String name); - - /** - * Get an unmutable list of node objects + /** + * Get an unmutable list of node objects */ - public List<Node> getNodes() - { - return Collections.unmodifiableList(nodes); - } + List<Node> getNodes(); /** * Find a node for a given name * * @return null if the node is not defined */ - public Node findNode(String name) - { - return findNodeInternal(name); - } + Node findNode(String name); /** * Get the start node for this process definition * * @return The start node - * - * @throws InvalidProcessDefinitionException if there is no start node */ - public StartNode getStartNode() - { - Node rootNode = getStartNodeInternal(); - if (rootNode == null) - throw new InvalidProcessDefinitionException("Process definition does not have a start node"); + StartNode getStartNode(); - return (StartNode)rootNode; - } - /** * Get the set of end nodes * * @return an emty set if */ - public Set<EndNode> getEndNodes() - { - Set<EndNode> endNodes = new HashSet<EndNode>(); - for (Node aux : nodes) - { - if (aux instanceof EndNode) - { - endNodes.add((EndNode)aux); - } - } - if (endNodes.size() == 0) - throw new InvalidProcessDefinitionException("Process definition does not have end nodes"); + Set<EndNode> getEndNodes(); - return endNodes; - } + ProcessInstance createProcessInstance(); - // Add a node - protected void addNode(Node apiNode) - { - if (apiNode instanceof StartNode && getStartNodeInternal() != null) - throw new InvalidProcessDefinitionException("Process definition cannot have multiple start nodes: " + apiNode); - - String name = apiNode.getName(); - if (findNodeInternal(name) != null) - throw new NameNotUniqueException("Node: " + name); - - nodes.add(apiNode); - } - /** * Create an instance of this process definition. */ - public ProcessInstance createProcessInstance() - { - ProcessEngine engine = ProcessEngineLocator.locateProcessEngine(); - ProcessInstanceFactory pim = engine.getProcessInstanceFactory(); - ProcessInstance pinst = pim.createProcessInstance(this); - return pinst; - } /** * Get the set of registered process instances */ - public Set<ProcessInstance> getProcessInstances() - { - return Collections.unmodifiableSet(pinstSet); - } + Set<ProcessInstance> getProcessInstances(); /** * Find a ProcessInstance for a given name + * * @return null if it cannot be found */ - public ProcessInstance findProcessInstance(String name) - { - for (ProcessInstance pinst : pinstSet) - { - if (pinst.getName() == name) - return pinst; - } - return null; - } + ProcessInstance findProcessInstance(String name); /** * Remove a ProcessInstance for a given name */ - public void removeProcessInstance(String name) - { - for (ProcessInstance pinst : pinstSet) - { - if (pinst.getName() == name) - { - pinstSet.remove(pinst); - break; - } - } - } + void removeProcessInstance(String name); - /* + /** * Create an execution for this process definition. Note, that this will automatically create a new process instance. */ - public Execution createExecution() - { - ProcessEngine engine = ProcessEngineLocator.locateProcessEngine(); - ProcessInstanceFactory pim = engine.getProcessInstanceFactory(); - ProcessInstance pinst = pim.createProcessInstance(this); - ExecutionFactory pem = engine.getExecutionFactory(); - return pem.createExecution(pinst); - } + Execution createExecution(); - // private - - private StartNode getStartNodeInternal() - { - Node rootNode = null; - for (Node aux : nodes) - { - if (aux instanceof StartNode) - { - rootNode = aux; - break; - } - } - return (StartNode)rootNode; - } - - private Node findNodeInternal(String name) - { - Node apiNode = null; - for (Node aux : nodes) - { - if (aux.getName().equals(name)) - { - apiNode = aux; - break; - } - } - return apiNode; - } } \ No newline at end of file Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/def/StartNode.java =================================================================== --- api/trunk/modules/api/src/main/java/org/jboss/bpm/def/StartNode.java 2008-07-03 16:48:16 UTC (rev 1502) +++ api/trunk/modules/api/src/main/java/org/jboss/bpm/def/StartNode.java 2008-07-03 21:44:34 UTC (rev 1503) @@ -30,10 +30,6 @@ * @author tho...@jb... * @since 18-Jun-2008 */ -public abstract class StartNode extends Node +public interface StartNode extends Node { - protected StartNode(ProcessDefinition pdef) - { - super(pdef); - } } \ No newline at end of file Added: api/trunk/modules/api/src/main/java/org/jboss/bpm/def/internal/AbstractNode.java =================================================================== --- api/trunk/modules/api/src/main/java/org/jboss/bpm/def/internal/AbstractNode.java (rev 0) +++ api/trunk/modules/api/src/main/java/org/jboss/bpm/def/internal/AbstractNode.java 2008-07-03 21:44:34 UTC (rev 1503) @@ -0,0 +1,92 @@ +/* + * 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.def.internal; + +import org.jboss.bpm.def.Node; +import org.jboss.bpm.def.ProcessDefinition; + + +// $Id$ + +/** + * Represents a node in the process definition. A node is an immutable object. The name of a node is unique in the scope of the process definition. + * + * @author tho...@jb... + * @since 18-Jun-2008 + */ +public abstract class AbstractNode implements Node +{ + // The associated process definition + private ProcessDefinition pdef; + + // Construct the node + protected AbstractNode(ProcessDefinition pdef) + { + if (pdef == null) + throw new IllegalArgumentException("Process definition cannot be null"); + + this.pdef = pdef; + } + + // Construct the node from a copy + protected AbstractNode(Node node) + { + this(node.getProcessDefinition()); + } + + // Call to initialize fully + protected void init(String name) + { + if (name == null) + { + name = "AnonymousNode#" + pdef.getNodes().size(); + setName(name); + } + } + + /** + * Get the associated process instance + */ + public ProcessDefinition getProcessDefinition() + { + return pdef; + } + + /** + * Get the node name + */ + public abstract String getName(); + + // Set the node name + protected abstract void setName(String name); + + /* (non-Javadoc) + * @see org.jboss.bpm.def.Node#toString() + */ + /* (non-Javadoc) + * @see org.jboss.bpm.def.internal.Node#toString() + */ + public String toString() + { + return "Node[" + getName() + "]"; + } +} \ No newline at end of file Property changes on: api/trunk/modules/api/src/main/java/org/jboss/bpm/def/internal/AbstractNode.java ___________________________________________________________________ Name: svn:keywords + Id Revision Name: svn:eol-style + LF Added: api/trunk/modules/api/src/main/java/org/jboss/bpm/def/internal/AbstractProcessDefinition.java =================================================================== --- api/trunk/modules/api/src/main/java/org/jboss/bpm/def/internal/AbstractProcessDefinition.java (rev 0) +++ api/trunk/modules/api/src/main/java/org/jboss/bpm/def/internal/AbstractProcessDefinition.java 2008-07-03 21:44:34 UTC (rev 1503) @@ -0,0 +1,243 @@ +/* + * 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.def.internal; + +// $Id$ + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.jboss.bpm.InvalidProcessDefinitionException; +import org.jboss.bpm.NameNotUniqueException; +import org.jboss.bpm.client.Execution; +import org.jboss.bpm.client.ExecutionFactory; +import org.jboss.bpm.client.ProcessDefinitionManager; +import org.jboss.bpm.client.ProcessEngine; +import org.jboss.bpm.client.ProcessEngineLocator; +import org.jboss.bpm.client.ProcessInstance; +import org.jboss.bpm.client.ProcessInstanceFactory; +import org.jboss.bpm.def.EndNode; +import org.jboss.bpm.def.Node; +import org.jboss.bpm.def.ProcessDefinition; +import org.jboss.bpm.def.StartNode; + +/** + * Represents the structural definition of a BPM process + * + * @author tho...@jb... + * @since 18-Jun-2008 + */ +public abstract class AbstractProcessDefinition implements ProcessDefinition +{ + // The list of nodes + private List<Node> nodes = new ArrayList<Node>(); + // The set of process instances + private Set<ProcessInstance> pinstSet = new HashSet<ProcessInstance>(); + + // Construct the process definition + protected AbstractProcessDefinition() + { + } + + // Call to initialize fully + protected void init(String name) + { + if (name == null) + { + ProcessDefinitionManager pdm = ProcessDefinitionManager.locateProcessDefinitionManager(); + name = "AnonymousDef#" + pdm.getProcessDefinitions().size(); + setName(name); + } + } + + /** + * Get the name + */ + public abstract String getName(); + + /** + * Set the name. Note, this MUST NOT leak into the public API + */ + protected abstract void setName(String name); + + /** + * Get an unmutable list of node objects + */ + public List<Node> getNodes() + { + return Collections.unmodifiableList(nodes); + } + + /** + * Find a node for a given name + * + * @return null if the node is not defined + */ + public Node findNode(String name) + { + return findNodeInternal(name); + } + + /** + * Get the start node for this process definition + * + * @return The start node + */ + public StartNode getStartNode() + { + Node rootNode = getStartNodeInternal(); + if (rootNode == null) + throw new InvalidProcessDefinitionException("Process definition does not have a start node"); + + return (StartNode)rootNode; + } + + /** + * Get the set of end nodes + * + * @return an emty set if + */ + public Set<EndNode> getEndNodes() + { + Set<EndNode> endNodes = new HashSet<EndNode>(); + for (Node aux : nodes) + { + if (aux instanceof EndNode) + { + endNodes.add((EndNode)aux); + } + } + if (endNodes.size() == 0) + throw new InvalidProcessDefinitionException("Process definition does not have end nodes"); + + return endNodes; + } + + /** + * Add a node. Note, this MUST NOT leak into the public API + */ + protected void addNode(Node apiNode) + { + if (apiNode instanceof StartNode && getStartNodeInternal() != null) + throw new InvalidProcessDefinitionException("Process definition cannot have multiple start nodes: " + apiNode); + + String name = apiNode.getName(); + if (findNodeInternal(name) != null) + throw new NameNotUniqueException("Node: " + name); + + nodes.add(apiNode); + } + + /** + * Create an instance of this process definition. + */ + public ProcessInstance createProcessInstance() + { + ProcessEngine engine = ProcessEngineLocator.locateProcessEngine(); + ProcessInstanceFactory pim = engine.getProcessInstanceFactory(); + ProcessInstance pinst = pim.createProcessInstance(this); + return pinst; + } + + /** + * Get the set of registered process instances + */ + public Set<ProcessInstance> getProcessInstances() + { + return Collections.unmodifiableSet(pinstSet); + } + + /** + * Find a ProcessInstance for a given name + * + * @return null if it cannot be found + */ + public ProcessInstance findProcessInstance(String name) + { + for (ProcessInstance pinst : pinstSet) + { + if (pinst.getName() == name) + return pinst; + } + return null; + } + + /** + * Remove a ProcessInstance for a given name + */ + public void removeProcessInstance(String name) + { + for (ProcessInstance pinst : pinstSet) + { + if (pinst.getName() == name) + { + pinstSet.remove(pinst); + break; + } + } + } + + /** + * Create an execution for this process definition. Note, that this will automatically create a new process instance. + */ + public Execution createExecution() + { + ProcessEngine engine = ProcessEngineLocator.locateProcessEngine(); + ProcessInstanceFactory pim = engine.getProcessInstanceFactory(); + ProcessInstance pinst = pim.createProcessInstance(this); + ExecutionFactory pem = engine.getExecutionFactory(); + return pem.createExecution(pinst); + } + + // private + + private StartNode getStartNodeInternal() + { + Node rootNode = null; + for (Node aux : nodes) + { + if (aux instanceof StartNode) + { + rootNode = aux; + break; + } + } + return (StartNode)rootNode; + } + + private Node findNodeInternal(String name) + { + Node apiNode = null; + for (Node aux : nodes) + { + if (aux.getName().equals(name)) + { + apiNode = aux; + break; + } + } + return apiNode; + } +} \ No newline at end of file Property changes on: api/trunk/modules/api/src/main/java/org/jboss/bpm/def/internal/AbstractProcessDefinition.java ___________________________________________________________________ Name: svn:keywords + Id Revision Name: svn:eol-style + LF Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/RuntimeExecution.java =================================================================== --- api/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/RuntimeExecution.java 2008-07-03 16:48:16 UTC (rev 1502) +++ api/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/RuntimeExecution.java 2008-07-03 21:44:34 UTC (rev 1503) @@ -26,27 +26,17 @@ import org.jboss.bpm.client.Execution; /** - * Represents a runtime execution in the process definition. A runtime node gives access to its leaving transitions. + * Represents a runtime execution in the process definition. * + * A runtime node gives access to its leaving transitions. + * * @author tho...@jb... * @since 03-Jul-2008 */ -public abstract class RuntimeExecution extends Execution +public interface RuntimeExecution extends Execution { - // Contruct the runtime execution for a copy - protected RuntimeExecution(Execution ex) - { - super(ex); - } - /** * Signal this execution with a names transition */ - public final void signal(String name) - { - signalOverride(name); - } - - // Override to implement execution signalling - protected abstract void signalOverride(String name); + void signal(String name); } \ No newline at end of file Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/RuntimeNode.java =================================================================== --- api/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/RuntimeNode.java 2008-07-03 16:48:16 UTC (rev 1502) +++ api/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/RuntimeNode.java 2008-07-03 21:44:34 UTC (rev 1503) @@ -23,12 +23,8 @@ //$Id$ -import java.util.ArrayList; -import java.util.Collections; import java.util.List; -import org.jboss.bpm.def.Node; - /** * Represents a runtime node in the process definition. * @@ -37,23 +33,12 @@ * @author tho...@jb... * @since 03-Jul-2008 */ -public abstract class RuntimeNode extends Node +public interface RuntimeNode { - private List<Transition> leavingTransitions = new ArrayList<Transition>(); - - // Contruct the runtime node for a copy - protected RuntimeNode(Node node) - { - super(node); - } - /** * Get the unmodifieable list of leaving transitions * @return an empty list if there are none */ - public List<Transition> getLeavingTransitions() - { - return Collections.unmodifiableList(leavingTransitions); - } + List<Transition> getLeavingTransitions(); } \ No newline at end of file Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/TransitionRouter.java =================================================================== --- api/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/TransitionRouter.java 2008-07-03 16:48:16 UTC (rev 1502) +++ api/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/TransitionRouter.java 2008-07-03 21:44:34 UTC (rev 1503) @@ -23,7 +23,6 @@ // $Id$ -import org.jboss.bpm.client.Execution; /** * A TransitionRouter is responsible for moving Added: api/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/internal/AbstractRuntimeNode.java =================================================================== --- api/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/internal/AbstractRuntimeNode.java (rev 0) +++ api/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/internal/AbstractRuntimeNode.java 2008-07-03 21:44:34 UTC (rev 1503) @@ -0,0 +1,61 @@ +/* + * 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.runtime.internal; + +//$Id$ + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.jboss.bpm.def.Node; +import org.jboss.bpm.def.internal.AbstractNode; +import org.jboss.bpm.runtime.RuntimeNode; +import org.jboss.bpm.runtime.Transition; + +/** + * Represents a runtime node in the process definition. + * + * A runtime node gives access to its leaving transitions. + * + * @author tho...@jb... + * @since 03-Jul-2008 + */ +public abstract class AbstractRuntimeNode extends AbstractNode implements RuntimeNode +{ + private List<Transition> leavingTransitions = new ArrayList<Transition>(); + + // Contruct the runtime node for a copy + protected AbstractRuntimeNode(Node node) + { + super(node); + } + + /* (non-Javadoc) + * @see org.jboss.bpm.runtime.internal.RuntimeNode#getLeavingTransitions() + */ + public List<Transition> getLeavingTransitions() + { + return Collections.unmodifiableList(leavingTransitions); + } + +} \ No newline at end of file Property changes on: api/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/internal/AbstractRuntimeNode.java ___________________________________________________________________ Name: svn:keywords + Id Revision Name: svn:eol-style + LF |
From: <do-...@jb...> - 2008-07-03 16:48:18
|
Author: tho...@jb... Date: 2008-07-03 12:48:16 -0400 (Thu, 03 Jul 2008) New Revision: 1502 Modified: api/trunk/modules/api/ api/trunk/modules/testsuite/ Log: svn:ignore target Property changes on: api/trunk/modules/api ___________________________________________________________________ Name: svn:ignore + target Property changes on: api/trunk/modules/testsuite ___________________________________________________________________ Name: svn:ignore + target |
From: <do-...@jb...> - 2008-07-03 16:47:00
|
Author: tho...@jb... Date: 2008-07-03 12:46:56 -0400 (Thu, 03 Jul 2008) New Revision: 1501 Added: api/trunk/modules/api/src/main/java/org/jboss/bpm/test/ api/trunk/modules/api/src/main/java/org/jboss/bpm/test/AbstractAPITestCase.java api/trunk/modules/api/src/main/java/org/jboss/bpm/test/DefaultEngineTestCase.java api/trunk/modules/api/src/test/ api/trunk/modules/api/src/test/java/ api/trunk/modules/api/src/test/java/org/ api/trunk/modules/api/src/test/java/org/jboss/ api/trunk/modules/api/src/test/java/org/jboss/bpm/ api/trunk/modules/api/src/test/java/org/jboss/bpm/AbstractMockEngineTestCase.java api/trunk/modules/api/src/test/java/org/jboss/bpm/client/ api/trunk/modules/api/src/test/java/org/jboss/bpm/client/MockProcessEngine.java api/trunk/modules/api/src/test/java/org/jboss/bpm/client/ProcessEngineLocatorTest.java api/trunk/modules/api/src/test/resources/ api/trunk/modules/api/src/test/resources/jbpm-mock-beans.xml Removed: api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/AbstractAPITestCase.java api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/AbstractMockEngineTestCase.java api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/DefaultEngineTestCase.java api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/client/MockProcessEngine.java api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/client/ProcessEngineLocatorTest.java api/trunk/modules/testsuite/src/test/resources/jbpm-mock-beans.xml Modified: api/trunk/.classpath api/trunk/modules/api/pom.xml api/trunk/modules/testsuite/pom.xml api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/client/ProcessDefinitionTest.java api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/activity/BasicActivityTest.java api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/basic/BasicSequenceTest.java Log: Move API tests to api module Modified: api/trunk/.classpath =================================================================== --- api/trunk/.classpath 2008-07-03 16:26:40 UTC (rev 1500) +++ api/trunk/.classpath 2008-07-03 16:46:56 UTC (rev 1501) @@ -1,7 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="src" path="src/main/java"/> - <classpathentry kind="src" path="src/test/java"/> + <classpathentry kind="src" path="modules/api/src/main/java"/> + <classpathentry kind="src" path="modules/testsuite/src/test/java"/> + <classpathentry kind="src" path="modules/api/src/test/java"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/> <classpathentry kind="output" path="target/eclipse-classes"/> Modified: api/trunk/modules/api/pom.xml =================================================================== --- api/trunk/modules/api/pom.xml 2008-07-03 16:26:40 UTC (rev 1500) +++ api/trunk/modules/api/pom.xml 2008-07-03 16:46:56 UTC (rev 1501) @@ -41,6 +41,12 @@ <artifactId>commons-logging</artifactId> </dependency> + <!-- Provided Dependencies --> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>provided</scope> + </dependency> </dependencies> <!-- Reporting --> Copied: api/trunk/modules/api/src/main/java/org/jboss/bpm/test/AbstractAPITestCase.java (from rev 1499, api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/AbstractAPITestCase.java) =================================================================== --- api/trunk/modules/api/src/main/java/org/jboss/bpm/test/AbstractAPITestCase.java (rev 0) +++ api/trunk/modules/api/src/main/java/org/jboss/bpm/test/AbstractAPITestCase.java 2008-07-03 16:46:56 UTC (rev 1501) @@ -0,0 +1,85 @@ +/* + * 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; + +// $Id$ + +import java.net.URL; + +import junit.framework.TestCase; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jboss.bpm.JBPMException; +import org.jboss.bpm.client.EmbeddedBeansDeployer; + +public abstract class AbstractAPITestCase extends TestCase +{ + // provide logging + private static final Log log = LogFactory.getLog(AbstractAPITestCase.class); + + // Every test case has a deployer + private EmbeddedBeansDeployer deployer; + + /** Overwrite to provide beans config */ + protected abstract String getBeansConfig(); + + @Override + protected void setUp() throws Exception + { + super.setUp(); + log.debug("setUp: " + getName()); + deployer = new EmbeddedBeansDeployer(); + deployTestBeans(getBeansConfig()); + } + + @Override + protected void tearDown() throws Exception + { + log.debug("tearDown: " + getName()); + undeployTestBeans(getBeansConfig()); + super.tearDown(); + } + + // Deploy a beans config + protected void deployTestBeans(String resourceName) + { + URL url = getBeansConfigURL(resourceName); + deployer.deploy(url); + } + + // Undeploy a beans config + protected void undeployTestBeans(String resourceName) + { + URL url = getBeansConfigURL(resourceName); + deployer.undeploy(url); + deployer = null; + } + + private URL getBeansConfigURL(String resourceName) + { + URL url = Thread.currentThread().getContextClassLoader().getResource(resourceName); + if (url == null) + throw new JBPMException("Cannot find resource: " + resourceName); + return url; + } +} Copied: api/trunk/modules/api/src/main/java/org/jboss/bpm/test/DefaultEngineTestCase.java (from rev 1499, api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/DefaultEngineTestCase.java) =================================================================== --- api/trunk/modules/api/src/main/java/org/jboss/bpm/test/DefaultEngineTestCase.java (rev 0) +++ api/trunk/modules/api/src/main/java/org/jboss/bpm/test/DefaultEngineTestCase.java 2008-07-03 16:46:56 UTC (rev 1501) @@ -0,0 +1,35 @@ +/* + * 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; + +// $Id$ + +import org.jboss.bpm.client.ProcessEngine; + +public abstract class DefaultEngineTestCase extends AbstractAPITestCase +{ + @Override + protected String getBeansConfig() + { + return ProcessEngine.JBPM_ENGINE_CONFIG; + } +} Copied: api/trunk/modules/api/src/test/java/org/jboss/bpm/AbstractMockEngineTestCase.java (from rev 1499, api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/AbstractMockEngineTestCase.java) =================================================================== --- api/trunk/modules/api/src/test/java/org/jboss/bpm/AbstractMockEngineTestCase.java (rev 0) +++ api/trunk/modules/api/src/test/java/org/jboss/bpm/AbstractMockEngineTestCase.java 2008-07-03 16:46:56 UTC (rev 1501) @@ -0,0 +1,37 @@ +/* + * 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; + +//$Id$ + +import org.jboss.bpm.test.AbstractAPITestCase; + +public abstract class AbstractMockEngineTestCase extends AbstractAPITestCase +{ + + @Override + protected String getBeansConfig() + { + return "jbpm-mock-beans.xml"; + } + +} Copied: api/trunk/modules/api/src/test/java/org/jboss/bpm/client/MockProcessEngine.java (from rev 1499, api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/client/MockProcessEngine.java) =================================================================== --- api/trunk/modules/api/src/test/java/org/jboss/bpm/client/MockProcessEngine.java (rev 0) +++ api/trunk/modules/api/src/test/java/org/jboss/bpm/client/MockProcessEngine.java 2008-07-03 16:46:56 UTC (rev 1501) @@ -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.client; + +//$Id$ + +import org.jboss.bpm.client.ExecutionFactory; +import org.jboss.bpm.client.ProcessDefinitionManager; +import org.jboss.bpm.client.ProcessEngine; +import org.jboss.bpm.client.ProcessInstanceFactory; + +/** + * A process engine with public access + * + * @author tho...@jb... + * @since 18-Jun-2008 + */ +public class MockProcessEngine extends ProcessEngine { + + public void setProcessDefinitionManager(ProcessDefinitionManager processDefinitionManager) { + this.processDefinitionManager = processDefinitionManager; + } + + public void setProcessInstanceManager(ProcessInstanceFactory processInstanceManager) { + this.processInstanceFactory = processInstanceManager; + } + + public void setExecutionManager(ExecutionFactory executionManager) { + this.executionFactory = executionManager; + } +} \ No newline at end of file Copied: api/trunk/modules/api/src/test/java/org/jboss/bpm/client/ProcessEngineLocatorTest.java (from rev 1499, api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/client/ProcessEngineLocatorTest.java) =================================================================== --- api/trunk/modules/api/src/test/java/org/jboss/bpm/client/ProcessEngineLocatorTest.java (rev 0) +++ api/trunk/modules/api/src/test/java/org/jboss/bpm/client/ProcessEngineLocatorTest.java 2008-07-03 16:46:56 UTC (rev 1501) @@ -0,0 +1,38 @@ +/* + * 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.client; + +// $Id$ + +import org.jboss.bpm.AbstractMockEngineTestCase; +import org.jboss.bpm.client.ProcessEngine; +import org.jboss.bpm.client.ProcessEngineLocator; + +public class ProcessEngineLocatorTest extends AbstractMockEngineTestCase +{ + + public void testLocateProcessEngine() throws Exception + { + ProcessEngine engine = ProcessEngineLocator.locateProcessEngine(); + assertNotNull(engine); + } +} Copied: api/trunk/modules/api/src/test/resources/jbpm-mock-beans.xml (from rev 1499, api/trunk/modules/testsuite/src/test/resources/jbpm-mock-beans.xml) =================================================================== --- api/trunk/modules/api/src/test/resources/jbpm-mock-beans.xml (rev 0) +++ api/trunk/modules/api/src/test/resources/jbpm-mock-beans.xml 2008-07-03 16:46:56 UTC (rev 1501) @@ -0,0 +1,10 @@ +<deployment xmlns="urn:jboss:bean-deployer:2.0"> + + <!-- The Kernel Locator --> + <bean name="KernelLocator" class="org.jboss.kernel.plugins.util.KernelLocator"/> + + <!-- The BPM Process Engine --> + <bean name="jBPMProcessEngine" class="org.jboss.bpm.client.MockProcessEngine"> + </bean> + +</deployment> \ No newline at end of file Modified: api/trunk/modules/testsuite/pom.xml =================================================================== --- api/trunk/modules/testsuite/pom.xml 2008-07-03 16:26:40 UTC (rev 1500) +++ api/trunk/modules/testsuite/pom.xml 2008-07-03 16:46:56 UTC (rev 1501) @@ -15,7 +15,7 @@ <name>JBoss jBPM - API Testsuite</name> <groupId>org.jboss.jbpm</groupId> <artifactId>jbpm-api-testsuite</artifactId> - <packaging>pom</packaging> + <packaging>jar</packaging> <!-- Parent --> <parent> Deleted: api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/AbstractAPITestCase.java =================================================================== --- api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/AbstractAPITestCase.java 2008-07-03 16:26:40 UTC (rev 1500) +++ api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/AbstractAPITestCase.java 2008-07-03 16:46:56 UTC (rev 1501) @@ -1,85 +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; - -// $Id$ - -import java.net.URL; - -import junit.framework.TestCase; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.jboss.bpm.JBPMException; -import org.jboss.bpm.client.EmbeddedBeansDeployer; - -public abstract class AbstractAPITestCase extends TestCase -{ - // provide logging - private static final Log log = LogFactory.getLog(AbstractAPITestCase.class); - - // Every test case has a deployer - private EmbeddedBeansDeployer deployer; - - /** Overwrite to provide beans config */ - protected abstract String getBeansConfig(); - - @Override - protected void setUp() throws Exception - { - super.setUp(); - log.debug("setUp: " + getName()); - deployer = new EmbeddedBeansDeployer(); - deployTestBeans(getBeansConfig()); - } - - @Override - protected void tearDown() throws Exception - { - log.debug("tearDown: " + getName()); - undeployTestBeans(getBeansConfig()); - super.tearDown(); - } - - // Deploy a beans config - protected void deployTestBeans(String resourceName) - { - URL url = getBeansConfigURL(resourceName); - deployer.deploy(url); - } - - // Undeploy a beans config - protected void undeployTestBeans(String resourceName) - { - URL url = getBeansConfigURL(resourceName); - deployer.undeploy(url); - deployer = null; - } - - private URL getBeansConfigURL(String resourceName) - { - URL url = Thread.currentThread().getContextClassLoader().getResource(resourceName); - if (url == null) - throw new JBPMException("Cannot find resource: " + resourceName); - return url; - } -} Deleted: api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/AbstractMockEngineTestCase.java =================================================================== --- api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/AbstractMockEngineTestCase.java 2008-07-03 16:26:40 UTC (rev 1500) +++ api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/AbstractMockEngineTestCase.java 2008-07-03 16:46:56 UTC (rev 1501) @@ -1,35 +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; - -// $Id$ - -public abstract class AbstractMockEngineTestCase extends AbstractAPITestCase -{ - - @Override - protected String getBeansConfig() - { - return "jbpm-mock-beans.xml"; - } - -} Deleted: api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/DefaultEngineTestCase.java =================================================================== --- api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/DefaultEngineTestCase.java 2008-07-03 16:26:40 UTC (rev 1500) +++ api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/DefaultEngineTestCase.java 2008-07-03 16:46:56 UTC (rev 1501) @@ -1,35 +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; - -// $Id$ - -import org.jboss.bpm.client.ProcessEngine; - -public abstract class DefaultEngineTestCase extends AbstractAPITestCase -{ - @Override - protected String getBeansConfig() - { - return ProcessEngine.JBPM_ENGINE_CONFIG; - } -} Deleted: api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/client/MockProcessEngine.java =================================================================== --- api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/client/MockProcessEngine.java 2008-07-03 16:26:40 UTC (rev 1500) +++ api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/client/MockProcessEngine.java 2008-07-03 16:46:56 UTC (rev 1501) @@ -1,50 +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.client; - -//$Id$ - -import org.jboss.bpm.client.ExecutionFactory; -import org.jboss.bpm.client.ProcessDefinitionManager; -import org.jboss.bpm.client.ProcessEngine; -import org.jboss.bpm.client.ProcessInstanceFactory; - -/** - * A process engine with public access - * - * @author tho...@jb... - * @since 18-Jun-2008 - */ -public class MockProcessEngine extends ProcessEngine { - - public void setProcessDefinitionManager(ProcessDefinitionManager processDefinitionManager) { - this.processDefinitionManager = processDefinitionManager; - } - - public void setProcessInstanceManager(ProcessInstanceFactory processInstanceManager) { - this.processInstanceFactory = processInstanceManager; - } - - public void setExecutionManager(ExecutionFactory executionManager) { - this.executionFactory = executionManager; - } -} \ No newline at end of file Modified: api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/client/ProcessDefinitionTest.java =================================================================== --- api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/client/ProcessDefinitionTest.java 2008-07-03 16:26:40 UTC (rev 1500) +++ api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/client/ProcessDefinitionTest.java 2008-07-03 16:46:56 UTC (rev 1501) @@ -26,13 +26,12 @@ import java.util.List; import java.util.Set; -import org.jboss.bpm.DefaultEngineTestCase; import org.jboss.bpm.InvalidProcessDefinitionException; -import org.jboss.bpm.client.ProcessDefinitionManager; import org.jboss.bpm.def.EndNode; import org.jboss.bpm.def.Node; import org.jboss.bpm.def.ProcessDefinition; import org.jboss.bpm.def.StartNode; +import org.jboss.bpm.test.DefaultEngineTestCase; public class ProcessDefinitionTest extends DefaultEngineTestCase { Deleted: api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/client/ProcessEngineLocatorTest.java =================================================================== --- api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/client/ProcessEngineLocatorTest.java 2008-07-03 16:26:40 UTC (rev 1500) +++ api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/client/ProcessEngineLocatorTest.java 2008-07-03 16:46:56 UTC (rev 1501) @@ -1,38 +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.client; - -// $Id$ - -import org.jboss.bpm.AbstractMockEngineTestCase; -import org.jboss.bpm.client.ProcessEngine; -import org.jboss.bpm.client.ProcessEngineLocator; - -public class ProcessEngineLocatorTest extends AbstractMockEngineTestCase -{ - - public void testLocateProcessEngine() throws Exception - { - ProcessEngine engine = ProcessEngineLocator.locateProcessEngine(); - assertNotNull(engine); - } -} Modified: api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/activity/BasicActivityTest.java =================================================================== --- api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/activity/BasicActivityTest.java 2008-07-03 16:26:40 UTC (rev 1500) +++ api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/activity/BasicActivityTest.java 2008-07-03 16:46:56 UTC (rev 1501) @@ -23,10 +23,10 @@ // $Id$ -import org.jboss.bpm.DefaultEngineTestCase; import org.jboss.bpm.client.Execution; import org.jboss.bpm.client.ProcessDefinitionManager; import org.jboss.bpm.def.ProcessDefinition; +import org.jboss.bpm.test.DefaultEngineTestCase; /** * Test the basic activity execution Modified: api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/basic/BasicSequenceTest.java =================================================================== --- api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/basic/BasicSequenceTest.java 2008-07-03 16:26:40 UTC (rev 1500) +++ api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/basic/BasicSequenceTest.java 2008-07-03 16:46:56 UTC (rev 1501) @@ -23,7 +23,6 @@ // $Id$ -import org.jboss.bpm.DefaultEngineTestCase; import org.jboss.bpm.client.Execution; import org.jboss.bpm.client.ExecutionFactory; import org.jboss.bpm.client.ProcessDefinitionManager; @@ -39,7 +38,7 @@ * @author tho...@jb... * @since 03-Jul-2008 */ -public class BasicSequenceTest extends DefaultEngineTestCase +public class BasicSequenceTest extends org.jboss.bpm.test.DefaultEngineTestCase { String jpdl = "<process-definition>" + Deleted: api/trunk/modules/testsuite/src/test/resources/jbpm-mock-beans.xml =================================================================== --- api/trunk/modules/testsuite/src/test/resources/jbpm-mock-beans.xml 2008-07-03 16:26:40 UTC (rev 1500) +++ api/trunk/modules/testsuite/src/test/resources/jbpm-mock-beans.xml 2008-07-03 16:46:56 UTC (rev 1501) @@ -1,10 +0,0 @@ -<deployment xmlns="urn:jboss:bean-deployer:2.0"> - - <!-- The Kernel Locator --> - <bean name="KernelLocator" class="org.jboss.kernel.plugins.util.KernelLocator"/> - - <!-- The BPM Process Engine --> - <bean name="jBPMProcessEngine" class="org.jboss.bpm.client.MockProcessEngine"> - </bean> - -</deployment> \ No newline at end of file |
From: <do-...@jb...> - 2008-07-03 16:26:42
|
Author: tho...@jb... Date: 2008-07-03 12:26:40 -0400 (Thu, 03 Jul 2008) New Revision: 1500 Removed: jbpm3/trunk/modules/jpdl/integration/ Modified: jbpm3/trunk/modules/jpdl/core/pom.xml jbpm3/trunk/modules/jpdl/core/src/ jbpm3/trunk/modules/jpdl/pom.xml jbpm3/trunk/pom.xml Log: Use API modules to avoid circular dependencies Modified: jbpm3/trunk/modules/jpdl/core/pom.xml =================================================================== --- jbpm3/trunk/modules/jpdl/core/pom.xml 2008-07-03 16:25:41 UTC (rev 1499) +++ jbpm3/trunk/modules/jpdl/core/pom.xml 2008-07-03 16:26:40 UTC (rev 1500) @@ -34,6 +34,11 @@ <groupId>org.jboss.jbpm</groupId> <artifactId>jbpm-api</artifactId> </dependency> + <dependency> + <groupId>org.jboss.jbpm</groupId> + <artifactId>jbpm-api-testsuite</artifactId> + <type>zip</type> + </dependency> <!-- Compile Dependencies --> <dependency> @@ -132,6 +137,55 @@ </executions> </plugin> <plugin> + <artifactId>maven-clean-plugin</artifactId> + <configuration> + <filesets> + <fileset> + <directory>src/testsuite</directory> + </fileset> + </filesets> + </configuration> + </plugin> + <plugin> + <artifactId>maven-dependency-plugin</artifactId> + <executions> + <execution> + <phase>generate-sources</phase> + <goals> + <goal>unpack</goal> + </goals> + <configuration> + <artifactItems> + <artifactItem> + <groupId>org.jboss.jbpm</groupId> + <artifactId>jbpm-api-testsuite</artifactId> + <type>zip</type> + </artifactItem> + </artifactItems> + <outputDirectory>src/testsuite</outputDirectory> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <executions> + <execution> + <id>add-test-source</id> + <phase>generate-sources</phase> + <goals> + <goal>add-test-source</goal> + </goals> + <configuration> + <sources> + <source>src/testsuite</source> + </sources> + </configuration> + </execution> + </executions> + </plugin> + <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <showDeprecation>false</showDeprecation> Property changes on: jbpm3/trunk/modules/jpdl/core/src ___________________________________________________________________ Name: svn:ignore + testsuite Modified: jbpm3/trunk/modules/jpdl/pom.xml =================================================================== --- jbpm3/trunk/modules/jpdl/pom.xml 2008-07-03 16:25:41 UTC (rev 1499) +++ jbpm3/trunk/modules/jpdl/pom.xml 2008-07-03 16:26:40 UTC (rev 1500) @@ -34,7 +34,6 @@ <module>db</module> <module>examples</module> <module>identity</module> - <module>integration</module> <module>simulation</module> <module>userguide</module> <module>ws</module> Modified: jbpm3/trunk/pom.xml =================================================================== --- jbpm3/trunk/pom.xml 2008-07-03 16:25:41 UTC (rev 1499) +++ jbpm3/trunk/pom.xml 2008-07-03 16:26:40 UTC (rev 1500) @@ -90,8 +90,7 @@ </dependency> <dependency> <groupId>org.jboss.jbpm</groupId> - <artifactId>jbpm-api</artifactId> - <classifier>testsuite</classifier> + <artifactId>jbpm-api-testsuite</artifactId> <version>${jboss.jbpm.api.version}</version> <type>zip</type> </dependency> @@ -172,6 +171,16 @@ <groupId>jaxen</groupId> <artifactId>jaxen</artifactId> <version>${jaxen.version}</version> + <exclusions> + <exclusion> + <groupId>xerces</groupId> + <artifactId>xercesImpl</artifactId> + </exclusion> + <exclusion> + <groupId>xerces</groupId> + <artifactId>xmlParserAPIs</artifactId> + </exclusion> + </exclusions> </dependency> <dependency> <groupId>javax.ejb</groupId> @@ -247,6 +256,12 @@ <groupId>org.apache.jackrabbit</groupId> <artifactId>jackrabbit-core</artifactId> <version>${apache.jackrabbit.version}</version> + <exclusions> + <exclusion> + <groupId>xerces</groupId> + <artifactId>xercesImpl</artifactId> + </exclusion> + </exclusions> </dependency> <dependency> <groupId>org.hibernate</groupId> |
From: <do-...@jb...> - 2008-07-03 16:25:43
|
Author: tho...@jb... Date: 2008-07-03 12:25:41 -0400 (Thu, 03 Jul 2008) New Revision: 1499 Added: api/trunk/modules/ api/trunk/modules/api/ api/trunk/modules/api/pom.xml api/trunk/modules/api/src/ api/trunk/modules/api/src/main/ api/trunk/modules/api/src/main/java/ api/trunk/modules/api/src/main/java/org/ api/trunk/modules/api/src/main/java/org/jboss/ api/trunk/modules/api/src/main/java/org/jboss/bpm/ api/trunk/modules/api/src/main/java/org/jboss/bpm/Context.java api/trunk/modules/api/src/main/java/org/jboss/bpm/EngineShutdownException.java api/trunk/modules/api/src/main/java/org/jboss/bpm/InvalidProcessDefinitionException.java api/trunk/modules/api/src/main/java/org/jboss/bpm/JBPMException.java api/trunk/modules/api/src/main/java/org/jboss/bpm/NameNotUniqueException.java api/trunk/modules/api/src/main/java/org/jboss/bpm/NotImplementedException.java api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ContextImpl.java api/trunk/modules/api/src/main/java/org/jboss/bpm/client/EmbeddedBeansDeployer.java api/trunk/modules/api/src/main/java/org/jboss/bpm/client/Execution.java api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ExecutionFactory.java api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessDefinitionManager.java api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessEngine.java api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessEngineLocator.java api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessInstance.java api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessInstanceFactory.java api/trunk/modules/api/src/main/java/org/jboss/bpm/def/ api/trunk/modules/api/src/main/java/org/jboss/bpm/def/EndNode.java api/trunk/modules/api/src/main/java/org/jboss/bpm/def/Node.java api/trunk/modules/api/src/main/java/org/jboss/bpm/def/ProcessDefinition.java api/trunk/modules/api/src/main/java/org/jboss/bpm/def/StartNode.java api/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/ api/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/Activity.java api/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/RuntimeExecution.java api/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/RuntimeNode.java api/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/Transition.java api/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/TransitionRouter.java api/trunk/modules/api/src/main/scripts/ api/trunk/modules/testsuite/ api/trunk/modules/testsuite/pom.xml api/trunk/modules/testsuite/scripts/ api/trunk/modules/testsuite/scripts/assembly-testsuite.xml api/trunk/modules/testsuite/src/ api/trunk/modules/testsuite/src/test/ api/trunk/modules/testsuite/src/test/java/ api/trunk/modules/testsuite/src/test/java/org/ api/trunk/modules/testsuite/src/test/java/org/jboss/ api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/ api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/AbstractAPITestCase.java api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/AbstractMockEngineTestCase.java api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/DefaultEngineTestCase.java api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/client/ api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/client/MockProcessEngine.java api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/client/ProcessDefinitionTest.java api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/client/ProcessEngineLocatorTest.java api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/ api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/activity/ api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/activity/BasicActivityTest.java api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/activity/MyActivity.java api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/basic/ api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/basic/BasicSequenceTest.java api/trunk/modules/testsuite/src/test/resources/ api/trunk/modules/testsuite/src/test/resources/jbpm-mock-beans.xml api/trunk/modules/testsuite/src/test/resources/log4j.xml Removed: api/trunk/src/ Modified: api/trunk/pom.xml Log: Use API modules to avoid circular dependencies Added: api/trunk/modules/api/pom.xml =================================================================== --- api/trunk/modules/api/pom.xml (rev 0) +++ api/trunk/modules/api/pom.xml 2008-07-03 16:25:41 UTC (rev 1499) @@ -0,0 +1,58 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- ====================================================================== --> +<!-- --> +<!-- JBoss, the OpenSource J2EE webOS --> +<!-- --> +<!-- Distributable under LGPL license. --> +<!-- See terms of license at http://www.gnu.org. --> +<!-- --> +<!-- ====================================================================== --> + +<!-- $Id$ --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <name>JBoss jBPM - API Source</name> + <groupId>org.jboss.jbpm</groupId> + <artifactId>jbpm-api</artifactId> + <packaging>jar</packaging> + + <!-- Parent --> + <parent> + <groupId>org.jboss.jbpm</groupId> + <artifactId>jbpm-api-root</artifactId> + <version>1.0.0-SNAPSHOT</version> + <relativePath>../../pom.xml</relativePath> + </parent> + + <!-- Dependencies --> + <dependencies> + + <!-- Compile Dependencies --> + <dependency> + <groupId>org.jboss.microcontainer</groupId> + <artifactId>jboss-kernel</artifactId> + </dependency> + <dependency> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </dependency> + + </dependencies> + + <!-- Reporting --> + <reporting> + <plugins> + <plugin> + <artifactId>maven-javadoc-plugin</artifactId> + <configuration> + <show>public</show> + </configuration> + </plugin> + </plugins> + </reporting> + +</project> \ No newline at end of file Property changes on: api/trunk/modules/api/pom.xml ___________________________________________________________________ Name: svn:keywords + Id Revision Name: svn:eol-style + LF Added: api/trunk/modules/api/src/main/java/org/jboss/bpm/Context.java =================================================================== --- api/trunk/modules/api/src/main/java/org/jboss/bpm/Context.java (rev 0) +++ api/trunk/modules/api/src/main/java/org/jboss/bpm/Context.java 2008-07-03 16:25:41 UTC (rev 1499) @@ -0,0 +1,71 @@ +/* + * 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; + +//$Id$ + +import java.util.Collection; + +/** + * A general extendible artifact + * + * @author Tho...@jb... + * @since 20-Apr-2007 + */ +public interface Context +{ + /** Get arbitrary attachments */ + Collection<Key> getAttachments(); + + /** Add arbitrary attachment */ + <T> T addAttachment(Class<T> clazz, Object value); + + /** Add arbitrary attachment with name */ + <T> T addAttachment(Class<T> clazz, String name, Object value); + + /** Add arbitrary attachment with name */ + <T> T addAttachment(String name, Object value); + + /** Get an arbitrary attachment */ + <T> T getAttachment(Class<T> clazz); + + /** Get an arbitrary attachment */ + <T> T getAttachment(Class<T> clazz, String name); + + /** Get an arbitrary attachment */ + <T> T getAttachment(String name); + + /** Remove arbitrary attachments */ + <T> T removeAttachment(Class<T> clazz); + + /** Remove arbitrary attachments */ + <T> T removeAttachment(Class<T> clazz, String name); + + /** Remove arbitrary attachments */ + <T> T removeAttachment(String name); + + interface Key + { + Class getClazz(); + String getName(); + } +} \ No newline at end of file Property changes on: api/trunk/modules/api/src/main/java/org/jboss/bpm/Context.java ___________________________________________________________________ Name: svn:keywords + Id Revision Name: svn:eol-style + LF Added: api/trunk/modules/api/src/main/java/org/jboss/bpm/EngineShutdownException.java =================================================================== --- api/trunk/modules/api/src/main/java/org/jboss/bpm/EngineShutdownException.java (rev 0) +++ api/trunk/modules/api/src/main/java/org/jboss/bpm/EngineShutdownException.java 2008-07-03 16:25:41 UTC (rev 1499) @@ -0,0 +1,42 @@ +/* + * 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; + +// $Id$ + +/** + * A JBPMException that is thrown when an invalid operation is invoked on + * engine shutdown. + * + * @author tho...@jb... + * @since 18-Jun-2008 + */ +public class EngineShutdownException extends JBPMException { + + public EngineShutdownException() { + super(); + } + + public EngineShutdownException(String message) { + super(message); + } +} Property changes on: api/trunk/modules/api/src/main/java/org/jboss/bpm/EngineShutdownException.java ___________________________________________________________________ Name: svn:keywords + Id Revision Name: svn:eol-style + LF Added: api/trunk/modules/api/src/main/java/org/jboss/bpm/InvalidProcessDefinitionException.java =================================================================== --- api/trunk/modules/api/src/main/java/org/jboss/bpm/InvalidProcessDefinitionException.java (rev 0) +++ api/trunk/modules/api/src/main/java/org/jboss/bpm/InvalidProcessDefinitionException.java 2008-07-03 16:25:41 UTC (rev 1499) @@ -0,0 +1,54 @@ +/* + * 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; + + +// $Id$ + +/** + * A RuntimeException that is thrown for invalid process definitions + * + * @author tho...@jb... + * @since 18-Jun-2008 + */ +public class InvalidProcessDefinitionException extends JBPMException +{ + public InvalidProcessDefinitionException() + { + super(); + } + + public InvalidProcessDefinitionException(String message) + { + super(message); + } + + public InvalidProcessDefinitionException(String message, Throwable cause) + { + super(message, cause); + } + + public InvalidProcessDefinitionException(Throwable cause) + { + super(cause); + } +} Property changes on: api/trunk/modules/api/src/main/java/org/jboss/bpm/InvalidProcessDefinitionException.java ___________________________________________________________________ Name: svn:keywords + Id Revision Name: svn:eol-style + LF Added: api/trunk/modules/api/src/main/java/org/jboss/bpm/JBPMException.java =================================================================== --- api/trunk/modules/api/src/main/java/org/jboss/bpm/JBPMException.java (rev 0) +++ api/trunk/modules/api/src/main/java/org/jboss/bpm/JBPMException.java 2008-07-03 16:25:41 UTC (rev 1499) @@ -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; + +// $Id$ + +/** + * A RuntimeException that can be thrown for unrecoverable API errors + * + * @author tho...@jb... + * @since 18-Jun-2008 + */ +public class JBPMException extends RuntimeException { + + public JBPMException() { + super(); + } + + public JBPMException(String message, Throwable cause) { + super(message, cause); + } + + public JBPMException(String message) { + super(message); + } + + public JBPMException(Throwable cause) { + super(cause); + } + +} Property changes on: api/trunk/modules/api/src/main/java/org/jboss/bpm/JBPMException.java ___________________________________________________________________ Name: svn:keywords + Id Revision Name: svn:eol-style + LF Added: api/trunk/modules/api/src/main/java/org/jboss/bpm/NameNotUniqueException.java =================================================================== --- api/trunk/modules/api/src/main/java/org/jboss/bpm/NameNotUniqueException.java (rev 0) +++ api/trunk/modules/api/src/main/java/org/jboss/bpm/NameNotUniqueException.java 2008-07-03 16:25:41 UTC (rev 1499) @@ -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.jboss.bpm; + +// $Id$ + +/** + * A JBPMException that is thrown when an element name is not unique. + * + * @author tho...@jb... + * @since 18-Jun-2008 + */ +public class NameNotUniqueException extends JBPMException { + + public NameNotUniqueException() { + super(); + } + + public NameNotUniqueException(String message) { + super(message); + } +} Property changes on: api/trunk/modules/api/src/main/java/org/jboss/bpm/NameNotUniqueException.java ___________________________________________________________________ Name: svn:keywords + Id Revision Name: svn:eol-style + LF Added: api/trunk/modules/api/src/main/java/org/jboss/bpm/NotImplementedException.java =================================================================== --- api/trunk/modules/api/src/main/java/org/jboss/bpm/NotImplementedException.java (rev 0) +++ api/trunk/modules/api/src/main/java/org/jboss/bpm/NotImplementedException.java 2008-07-03 16:25:41 UTC (rev 1499) @@ -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.jboss.bpm; + +// $Id$ + +/** + * A RuntimeException that should be thrown for unimplemented features + * + * @author tho...@jb... + * @since 18-Jun-2008 + */ +public class NotImplementedException extends RuntimeException { + + public NotImplementedException() { + super(); + } + + public NotImplementedException(String message) { + super(message); + } +} Property changes on: api/trunk/modules/api/src/main/java/org/jboss/bpm/NotImplementedException.java ___________________________________________________________________ Name: svn:keywords + Id Revision Name: svn:eol-style + LF Added: api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ContextImpl.java =================================================================== --- api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ContextImpl.java (rev 0) +++ api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ContextImpl.java 2008-07-03 16:25:41 UTC (rev 1499) @@ -0,0 +1,135 @@ +/* + * 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.client; + +//$Id$ + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +import org.jboss.bpm.Context; + +/** + * A general extendible artifact + * + * @author Tho...@jb... + * @since 20-Apr-2007 + */ +class ContextImpl implements Context +{ + private Map<Key, Object> attachments = new HashMap<Key, Object>(); + + public Collection<Key> getAttachments() + { + return attachments.keySet(); + } + + public <T> T getAttachment(Class<T> clazz) + { + return (T)attachments.get(new KeyImpl(clazz, null)); + } + + public <T> T getAttachment(Class<T> clazz, String name) + { + return (T)attachments.get(new KeyImpl(clazz, name)); + } + + public <T> T getAttachment(String name) + { + return (T)attachments.get(new KeyImpl(Object.class, name)); + } + + public <T> T addAttachment(Class<T> clazz, Object obj) + { + return (T)attachments.put(new KeyImpl(clazz, null), obj); + } + + public <T> T addAttachment(Class<T> clazz, String name, Object obj) + { + return (T)attachments.put(new KeyImpl(clazz, name), obj); + } + + public <T> T addAttachment(String name, Object obj) + { + return (T)attachments.put(new KeyImpl(Object.class, name), obj); + } + + public <T> T removeAttachment(Class<T> clazz) + { + return (T)attachments.remove(new KeyImpl(clazz, null)); + } + + public <T> T removeAttachment(Class<T> clazz, String name) + { + return (T)attachments.remove(new KeyImpl(clazz, name)); + } + + public <T> T removeAttachment(String name) + { + return (T)attachments.remove(new KeyImpl(Object.class, name)); + } + + static class KeyImpl implements Key + { + Class clazz; + String name; + + public KeyImpl(Class clazz, String name) + { + this.clazz = clazz; + this.name = name; + } + + public Class getClazz() + { + return clazz; + } + + public String getName() + { + return name; + } + + @Override + public boolean equals(Object obj) + { + if (!(obj instanceof Key)) + return false; + if (obj == this) + return true; + return obj.toString().equals(toString()); + } + + @Override + public int hashCode() + { + return toString().hashCode(); + } + + @Override + public String toString() + { + return "[" + clazz.getName() + "," + name + "]"; + } + } +} Property changes on: api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ContextImpl.java ___________________________________________________________________ Name: svn:keywords + Id Revision Name: svn:eol-style + LF Added: api/trunk/modules/api/src/main/java/org/jboss/bpm/client/EmbeddedBeansDeployer.java =================================================================== --- api/trunk/modules/api/src/main/java/org/jboss/bpm/client/EmbeddedBeansDeployer.java (rev 0) +++ api/trunk/modules/api/src/main/java/org/jboss/bpm/client/EmbeddedBeansDeployer.java 2008-07-03 16:25:41 UTC (rev 1499) @@ -0,0 +1,109 @@ +/* + * 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.client; + +// $Id$ + +import java.net.URL; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jboss.bpm.JBPMException; +import org.jboss.kernel.Kernel; +import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap; +import org.jboss.kernel.plugins.deployment.xml.BasicXMLDeployer; +import org.jboss.kernel.plugins.util.KernelLocator; + +/** + * Boostrap the Microcontainer + * + * @author tho...@jb... + * @since 27-Jun-2008 + */ +public class EmbeddedBeansDeployer extends BasicBootstrap +{ + // provide logging + private static final Log log = LogFactory.getLog(EmbeddedBeansDeployer.class); + + private Kernel kernel; + private BasicXMLDeployer deployer; + + public EmbeddedBeansDeployer() + { + // Get or bootstrap the kernel + kernel = KernelLocator.getKernel(); + if (kernel == null) + { + try + { + super.bootstrap(); + kernel = super.getKernel(); + log.debug("bootstrap kernel: " + kernel); + } + catch (Throwable e) + { + throw new JBPMException("Cannot bootstrap kernel", e); + } + } + deployer = new BasicXMLDeployer(kernel); + } + + /** + * Deploy MC beans from URL + */ + public void deploy(URL url) + { + log.debug("deploy: " + url); + + // Deploy the beans + try + { + deployer.deploy(url); + deployer.validate(); + + // The KernelLocator is expected to get deployed as a bean + if (KernelLocator.getKernel() == null) + throw new JBPMException("KernelLocator not deployed as MC bean"); + + } + catch (Throwable e) + { + throw new JBPMException("Cannot deploy beans from: " + url, e); + } + } + + /** + * Undeploy MC beans from URL + */ + public void undeploy(URL url) + { + log.debug("undeploy: " + url); + try + { + deployer.undeploy(url); + } + catch (Throwable e) + { + throw new JBPMException("Cannot undeploy beans from: " + url, e); + } + } +} \ No newline at end of file Property changes on: api/trunk/modules/api/src/main/java/org/jboss/bpm/client/EmbeddedBeansDeployer.java ___________________________________________________________________ Name: svn:keywords + Id Revision Name: svn:eol-style + LF Added: api/trunk/modules/api/src/main/java/org/jboss/bpm/client/Execution.java =================================================================== --- api/trunk/modules/api/src/main/java/org/jboss/bpm/client/Execution.java (rev 0) +++ api/trunk/modules/api/src/main/java/org/jboss/bpm/client/Execution.java 2008-07-03 16:25:41 UTC (rev 1499) @@ -0,0 +1,114 @@ +/* + * 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.client; + +import org.jboss.bpm.Context; +import org.jboss.bpm.def.Node; + +// $Id$ + +/** + * Represents an execution of a process instance. The name of an execution is unique in the scope of the process instance. + * + * @author tho...@jb... + * @since 18-Jun-2008 + */ +public abstract class Execution +{ + // The associated process instance + private ProcessInstance pinst; + // The execution context + private Context context = new ContextImpl(); + + // Construct the execution + protected Execution(ProcessInstance pinst) + { + if (pinst == null) + throw new IllegalArgumentException("Process instance cannot be null"); + + this.pinst = pinst; + } + + // Construct the execution from a copy + protected Execution(Execution ex) + { + this(ex.getProcessInstance()); + } + + // Call to initialize fully + protected void init(String name) + { + if (name == null) + { + name = "AnonymousExecution#" + pinst.getExecutions().size(); + setName(name); + } + } + + /** + * Get the associated process instance + */ + public ProcessInstance getProcessInstance() + { + return pinst; + } + + /** + * Get the name for the execution + */ + public abstract String getName(); + + /** + * Get the context for this execution + */ + public Context getContext() + { + return context; + } + + // Set the name for the execution + protected abstract void setName(String name); + + /** + * Get the current node for this execution + */ + public final Node getNode() + { + Node node = getNodeOverride(); + return node; + } + + // Override to get the node + protected abstract Node getNodeOverride(); + + /** + * Signal this execution + */ + public final void signal() + { + signalOverride(); + } + + // Override to implement execution signalling + protected abstract void signalOverride(); + +} \ No newline at end of file Property changes on: api/trunk/modules/api/src/main/java/org/jboss/bpm/client/Execution.java ___________________________________________________________________ Name: svn:keywords + Id Revision Name: svn:eol-style + LF Added: api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ExecutionFactory.java =================================================================== --- api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ExecutionFactory.java (rev 0) +++ api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ExecutionFactory.java 2008-07-03 16:25:41 UTC (rev 1499) @@ -0,0 +1,86 @@ +/* + * 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.client; + +// $Id$ + +import org.jboss.bpm.Context; +import org.jboss.bpm.EngineShutdownException; +import org.jboss.bpm.Context.Key; + +/** + * The execution manager is the entry point to create, find and otherwise manage process executions. + * + * @author tho...@jb... + * @since 18-Jun-2008 + */ +public abstract class ExecutionFactory +{ + // Injected through the MC + protected ProcessEngine engine; + + /** + * Get the associated process engine + */ + public ProcessEngine getProcessEngine() + { + if (engine == null) + throw new IllegalStateException("ProcessEngine not available through kernel configuration"); + + return engine; + } + + /** + * Locate the execution manager + */ + public static ExecutionFactory locateExecutionManager() + { + ProcessEngine engine = ProcessEngineLocator.locateProcessEngine(); + return engine.getExecutionFactory(); + } + + /** + * Create an execution for a given process instance. + * The process instance context is copied to the execution context. + * Note, that this is a shallow copy. Mutable objects should generally not be put into the context. + */ + public final Execution createExecution(ProcessInstance pinst) + { + // TODO: test this + if (engine.isPrepareForShutdown()) + throw new EngineShutdownException("Cannot create new Execution while engine is shutting down"); + + // Copy the instance context to the execution context + Context context = pinst.getContext(); + Execution ex = createExecutionOverride(pinst); + for (Key key : context.getAttachments()) + { + Object att = context.getAttachment(key.getClazz(), key.getName()); + ex.getContext().addAttachment(key.getClazz(), key.getName(), att); + } + + return ex; + } + + // Override to implement execution creation + protected abstract Execution createExecutionOverride(ProcessInstance pinst); +} \ No newline at end of file Property changes on: api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ExecutionFactory.java ___________________________________________________________________ Name: svn:keywords + Id Revision Name: svn:eol-style + LF Added: api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessDefinitionManager.java =================================================================== --- api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessDefinitionManager.java (rev 0) +++ api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessDefinitionManager.java 2008-07-03 16:25:41 UTC (rev 1499) @@ -0,0 +1,142 @@ +/* + * 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.client; + +// $Id$ + +import java.io.IOException; +import java.net.URL; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +import org.jboss.bpm.EngineShutdownException; +import org.jboss.bpm.def.ProcessDefinition; + +/** + * The process definition manager is the entry point to create, find and otherwise manage process definitions. + * + * @author tho...@jb... + * @since 18-Jun-2008 + */ +public abstract class ProcessDefinitionManager +{ + + // Injected through the MC + protected ProcessEngine engine; + // The set of process definitions + private Set<ProcessDefinition> pdefs = new HashSet<ProcessDefinition>(); + + /* Get the associated process engine */ + public ProcessEngine getProcessEngine() + { + if (engine == null) + throw new IllegalStateException("ProcessEngine not available through kernel configuration"); + + return engine; + } + + /* Locate the process definition manager */ + public static ProcessDefinitionManager locateProcessDefinitionManager() + { + ProcessEngine engine = ProcessEngineLocator.locateProcessEngine(); + return engine.getProcessDefinitionManager(); + } + + /* + * Create a process defintion from a XML string in one of the supported formats + */ + public final ProcessDefinition createProcessDefinition(String pdDescriptor) + { + // TODO: test this + if (engine.isPrepareForShutdown()) + throw new EngineShutdownException("Cannot create new ProcessDefinition while engine is shutting down"); + + ProcessDefinition pd = createProcessDefinitionOverride(pdDescriptor); + return pd; + } + + /* + * Override to implement process definition creation + */ + protected abstract ProcessDefinition createProcessDefinitionOverride(String pdDescriptor); + + /* + * Create a process defintion from an URL to a XML descritor in one of the supported formats + */ + public final ProcessDefinition createProcessDefinition(URL pdURL) throws IOException + { + // TODO: test this + if (engine.isPrepareForShutdown()) + throw new EngineShutdownException("Cannot create new ProcessDefinition while engine is shutting down"); + + ProcessDefinition pd = createProcessDefinitionOverride(pdURL); + return pd; + } + + /* + * Override to implement process definition creation + */ + protected abstract ProcessDefinition createProcessDefinitionOverride(URL pdURL) throws IOException; + + /* + * Get the set of registered process definitions + */ + public Set<ProcessDefinition> getProcessDefinitions() + { + return Collections.unmodifiableSet(pdefs); + } + + /* + * Find a process definition for a given name + * + * @return null if the process definition is not defined + */ + public ProcessDefinition findProcessDefinition(String name) + { + ProcessDefinition pdef = null; + for (ProcessDefinition aux : pdefs) + { + if (pdef.getName().equals(name)) + { + pdef = aux; + break; + } + } + return pdef; + } + + /* + * Remove a process definition and all its associated process instances + */ + public void removeProcessDefinition(ProcessDefinition pdef) + { + // Remove the preocess definition + pdefs.remove(pdef.getName()); + } + + // Add a process definition + protected void addProcessDefinition(ProcessDefinition pdef) + { + pdefs.add(pdef); + } +} \ No newline at end of file Property changes on: api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessDefinitionManager.java ___________________________________________________________________ Name: svn:keywords + Id Revision Name: svn:eol-style + LF Added: api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessEngine.java =================================================================== --- api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessEngine.java (rev 0) +++ api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessEngine.java 2008-07-03 16:25:41 UTC (rev 1499) @@ -0,0 +1,95 @@ +/* + * 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.client; + +// $Id$ + +/** + * The process engine is an agregator of various manger objects used by the BPM engine + * + * @author tho...@jb... + * @since 18-Jun-2008 + */ +public class ProcessEngine { + + /** The process engine bean name - jBPMEngine */ + public static final String BEAN_NAME_JBPMENGINE = "jBPMProcessEngine"; + /** The default bean config: jbpm-beans.xml */ + public static final String JBPM_ENGINE_CONFIG = "jbpm-beans.xml"; + + // Injected through the MC + protected ProcessDefinitionManager processDefinitionManager; + // Injected through the MC + protected ProcessInstanceFactory processInstanceFactory; + // Injected through the MC + protected ExecutionFactory executionFactory; + // Flag to indicate that the Engine is shutting down + private boolean prepareForShutdown; + + public void prepareForShutdown() + { + prepareForShutdown = true; + } + + public boolean isPrepareForShutdown() + { + return prepareForShutdown; + } + + public void cancelShutdown() + { + prepareForShutdown = false; + } + + /** + * Get the configured instance of the process definition manager + * @return The process definition manager + */ + public ProcessDefinitionManager getProcessDefinitionManager() { + if (processDefinitionManager == null) + throw new IllegalStateException("ProcessDefinitionManager not available through kernel configuration"); + + return processDefinitionManager; + } + + /** + * Get the configured instance of the process instance manager + * @return The process instance manager + */ + public ProcessInstanceFactory getProcessInstanceFactory() { + if (processInstanceFactory == null) + throw new IllegalStateException("ProcessInstanceManager not available through kernel configuration"); + + return processInstanceFactory; + } + + /** + * Get the configured instance of the execution manager + * @return The execution manager + */ + public ExecutionFactory getExecutionFactory() { + if (executionFactory == null) + throw new IllegalStateException("ExecutionManager not available through kernel configuration"); + + return executionFactory; + } +} \ No newline at end of file Property changes on: api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessEngine.java ___________________________________________________________________ Name: svn:keywords + Id Revision Name: svn:eol-style + LF Added: api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessEngineLocator.java =================================================================== --- api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessEngineLocator.java (rev 0) +++ api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessEngineLocator.java 2008-07-03 16:25:41 UTC (rev 1499) @@ -0,0 +1,86 @@ +/* + * 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.client; + +// $Id$ + +import java.net.URL; + +import org.jboss.bpm.JBPMException; +import org.jboss.kernel.Kernel; +import org.jboss.kernel.plugins.util.KernelLocator; +import org.jboss.kernel.spi.registry.KernelRegistryEntry; +import org.jboss.kernel.spi.registry.KernelRegistryEntryNotFoundException; + +/** + * The ProcessEngineLocator is the main entry point for all client operations. + * + * It locates the process engine instance shared by all clients. + * + * @author tho...@jb... + * @since 18-Jun-2008 + */ +public abstract class ProcessEngineLocator { + + // Hide the constructor + private ProcessEngineLocator() { + } + + /** + * Locate the ProcessEngine instance shared by all clients. + * + * @return The configured instance of a process engine + */ + public static ProcessEngine locateProcessEngine() { + + Kernel kernel = KernelLocator.getKernel(); + KernelRegistryEntry entry = null; + if (kernel == null) + { + deployEngineConfiguration(); + kernel = KernelLocator.getKernel(); + entry = kernel.getRegistry().getEntry(ProcessEngine.BEAN_NAME_JBPMENGINE); + } + else + { + try { + entry = kernel.getRegistry().getEntry(ProcessEngine.BEAN_NAME_JBPMENGINE); + } catch (KernelRegistryEntryNotFoundException ex) { + deployEngineConfiguration(); + entry = kernel.getRegistry().getEntry(ProcessEngine.BEAN_NAME_JBPMENGINE); + } + } + + ProcessEngine engine = (ProcessEngine) entry.getTarget(); + return engine; + } + + private static void deployEngineConfiguration() { + + String config = ProcessEngine.JBPM_ENGINE_CONFIG; + URL url = Thread.currentThread().getContextClassLoader().getResource(config); + if (url == null) + throw new JBPMException("Cannot find resource: " + config); + + new EmbeddedBeansDeployer().deploy(url); + } +} Property changes on: api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessEngineLocator.java ___________________________________________________________________ Name: svn:keywords + Id Revision Name: svn:eol-style + LF Added: api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessInstance.java =================================================================== --- api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessInstance.java (rev 0) +++ api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessInstance.java 2008-07-03 16:25:41 UTC (rev 1499) @@ -0,0 +1,134 @@ +/* + * 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.client; + +// $Id$ + +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +import org.jboss.bpm.Context; +import org.jboss.bpm.def.ProcessDefinition; + +/** + * Represents an instance of a BPM process. It is the combination of a process definition plus its associated instance data + * + * @author tho...@jb... + * @since 18-Jun-2008 + */ +public abstract class ProcessInstance +{ + // The process definition + private ProcessDefinition pdef; + // The name + private String name; + // The map of executions + private Set<Execution> execs = new HashSet<Execution>(); + // The pricess instance context + private Context context = new ContextImpl(); + + // Construct a process instance with a given process definition + protected ProcessInstance(ProcessDefinition pdef) + { + if (pdef == null) + throw new IllegalArgumentException("Process definition cannot be null"); + + this.pdef = pdef; + } + + // Call to initialize fully + protected void init(String name) + { + if (name == null) + { + name = "AnonymousInst#" + pdef.getProcessInstances().size(); + setName(name); + } + } + + /** + * Get the associated process definition + */ + public ProcessDefinition getProcessDefinition() + { + return pdef; + } + + /** + * Get the name of this process instance + */ + public String getName() + { + return name; + } + + private void setName(String name) + { + this.name = name; + } + + /** + * Get the context for this execution + */ + public Context getContext() + { + return context; + } + + /** + * Get the set of registered executions + */ + public Set<Execution> getExecutions() + { + return Collections.unmodifiableSet(execs); + } + + /** + * Find an execution for a given name + * + * @return null if it cannot be found + */ + public Execution findExecution(String name) + { + for (Execution ex : execs) + { + if (ex.getName() == name) + return ex; + } + return null; + } + + /** + * Remove an execution for a given name + */ + public void removeExecution(String name) + { + for (Execution ex : execs) + { + if (ex.getName() == name) + { + execs.remove(ex); + } + } + } +} \ No newline at end of file Property changes on: api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessInstance.java ___________________________________________________________________ Name: svn:keywords + Id Revision Name: svn:eol-style + LF Added: api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessInstanceFactory.java =================================================================== --- api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessInstanceFactory.java (rev 0) +++ api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessInstanceFactory.java 2008-07-03 16:25:41 UTC (rev 1499) @@ -0,0 +1,80 @@ +/* + * 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.client; + +//$Id$ + +import org.jboss.bpm.EngineShutdownException; +import org.jboss.bpm.def.ProcessDefinition; + +/** + * The process instance manager is the entry point to create, find and otherwise + * manage process instances. + * + * @author tho...@jb... + * @since 18-Jun-2008 + */ +public abstract class ProcessInstanceFactory +{ + + // Injected through the MC + protected ProcessEngine engine; + + /* Get the associated process engine */ + public ProcessEngine getProcessEngine() + { + if (engine == null) + throw new IllegalStateException("ProcessEngine not available through kernel configuration"); + + return engine; + } + + /* Locate the process instance manager */ + public static ProcessInstanceFactory locateProcessInstanceManager() + { + ProcessEngine engine = ProcessEngineLocator.locateProcessEngine(); + return engine.getProcessInstanceFactory(); + } + + /* + * Create a process instance for a given process definition + * + * @param pd The process definition + * + * @return A process instance + */ + public final ProcessInstance createProcessInstance(ProcessDefinition pdef) + { + // TODO: test this + if (engine.isPrepareForShutdown()) + throw new EngineShutdownException("Cannot create new ProcessInstance while engine is shutting down"); + + ProcessInstance pinst = createProcessInstanceOverride(pdef); + return pinst; + } + + /* + * Override to implement process instance creation + */ + protected abstract ProcessInstance createProcessInstanceOverride(ProcessDefinition pdef); + +} Property changes on: api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessInstanceFactory.java ___________________________________________________________________ Name: svn:keywords + Id Revision Name: svn:eol-style + LF Added: api/trunk/modules/api/src/main/java/org/jboss/bpm/def/EndNode.java =================================================================== --- api/trunk/modules/api/src/main/java/org/jboss/bpm/def/EndNode.java (rev 0) +++ api/trunk/modules/api/src/main/java/org/jboss/bpm/def/EndNode.java 2008-07-03 16:25:41 UTC (rev 1499) @@ -0,0 +1,39 @@ +/* + * 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.def; + + +// $Id$ + +/** + * Represents an end node in the process definition. + * + * @author tho...@jb... + * @since 18-Jun-2008 + */ +public abstract class EndNode extends Node +{ + protected EndNode(ProcessDefinition pdef) + { + super(pdef); + } +} \ No newline at end of file Property changes on: api/trunk/modules/api/src/main/java/org/jboss/bpm/def/EndNode.java ___________________________________________________________________ Name: svn:keywords + Id Revision Name: svn:eol-style + LF Added: api/trunk/modules/api/src/main/java/org/jboss/bpm/def/Node.java =================================================================== --- api/trunk/modules/api/src/main/java/org/jboss/bpm/def/Node.java (rev 0) +++ api/trunk/modules/api/src/main/java/org/jboss/bpm/def/Node.java 2008-07-03 16:25:41 UTC (rev 1499) @@ -0,0 +1,80 @@ +/* + * 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.def; + + +// $Id:$ + +/** + * Represents a node in the process definition. A node is an immutable object. The name of a node is unique in the scope of the process definition. + * + * @author tho...@jb... + * @since 18-Jun-2008 + */ +public abstract class Node +{ + // The associated process definition + private ProcessDefinition pdef; + + // Construct the node + protected Node(ProcessDefinition pdef) + { + if (pdef == null) + throw new IllegalArgumentException("Process definition cannot be null"); + + this.pdef = pdef; + } + + // Construct the node from a copy + protected Node(Node node) + { + this(node.getProcessDefinition()); + } + + // Call to initialize fully + protected void init(String name) + { + if (name == null) + { + name = "AnonymousNode#" + pdef.getNodes().size(); + setName(name); + } + } + + /** Get the associated process definition */ + public ProcessDefinition getProcessDefinition() + { + return pdef; + } + + /** Get the node name */ + public abstract String getName(); + + // Set the node name + protected abstract void setName(String name); + + /** Returns a string representation of the object. */ + public String toString() + { + return "Node[" + getName() + "]"; + } +} \ No newline at end of file Property changes on: api/trunk/modules/api/src/main/java/org/jboss/bpm/def/Node.java ___________________________________________________________________ Name: svn:keywords + Id Revision Name: svn:eol-style + LF Added: api/trunk/modules/api/src/main/java/org/jboss/bpm/def/ProcessDefinition.java =================================================================== --- api/trunk/modules/api/src/main/java/org/jboss/bpm/def/ProcessDefinition.java (rev 0) +++ api/trunk/modules/api/src/main/java/org/jboss/bpm/def/ProcessDefinition.java 2008-07-03 16:25:41 UTC (rev 1499) @@ -0,0 +1,236 @... [truncated message content] |
From: <do-...@jb...> - 2008-07-03 14:55:13
|
Author: tho...@jb... Date: 2008-07-03 10:55:06 -0400 (Thu, 03 Jul 2008) New Revision: 1498 Modified: api/trunk/pom.xml api/trunk/src/main/java/org/jboss/bpm/client/EmbeddedBeansDeployer.java api/trunk/src/test/java/org/jboss/bpm/AbstractAPITestCase.java Log: Add logging Modified: api/trunk/pom.xml =================================================================== --- api/trunk/pom.xml 2008-07-03 14:49:12 UTC (rev 1497) +++ api/trunk/pom.xml 2008-07-03 14:55:06 UTC (rev 1498) @@ -31,13 +31,20 @@ <!-- Properties --> <properties> + <commons.logging.version>1.1.1</commons.logging.version> <jboss.microcontainer.version>2.0.0.Beta15</jboss.microcontainer.version> + <jboss.jbpm3.version>3.2.4-SNAPSHOT</jboss.jbpm3.version> </properties> <!-- DependencyManagement --> <dependencyManagement> <dependencies> <dependency> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + <version>${commons.logging.version}</version> + </dependency> + <dependency> <groupId>org.jboss.microcontainer</groupId> <artifactId>jboss-kernel</artifactId> <version>${jboss.microcontainer.version}</version> @@ -53,6 +60,10 @@ <groupId>org.jboss.microcontainer</groupId> <artifactId>jboss-kernel</artifactId> </dependency> + <dependency> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </dependency> <!-- Test Dependencies --> <dependency> @@ -114,13 +125,13 @@ <dependency> <groupId>org.jboss.jbpm</groupId> <artifactId>jbpm-jpdl-core</artifactId> - <version>3.2.4-SNAPSHOT</version> + <version>${jboss.jbpm3.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>org.jboss.jbpm</groupId> <artifactId>jbpm-jpdl-core</artifactId> - <version>3.2.4-SNAPSHOT</version> + <version>${jboss.jbpm3.version}</version> <classifier>config</classifier> <scope>test</scope> </dependency> Modified: api/trunk/src/main/java/org/jboss/bpm/client/EmbeddedBeansDeployer.java =================================================================== --- api/trunk/src/main/java/org/jboss/bpm/client/EmbeddedBeansDeployer.java 2008-07-03 14:49:12 UTC (rev 1497) +++ api/trunk/src/main/java/org/jboss/bpm/client/EmbeddedBeansDeployer.java 2008-07-03 14:55:06 UTC (rev 1498) @@ -21,11 +21,12 @@ */ package org.jboss.bpm.client; -// $Id: EmbeddedBeansDeployer.java 1379 2008-06-27 10:57:02Z -// tho...@jb... $ +// $Id$ import java.net.URL; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.jboss.bpm.JBPMException; import org.jboss.kernel.Kernel; import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap; @@ -38,19 +39,28 @@ * @author tho...@jb... * @since 27-Jun-2008 */ -public class EmbeddedBeansDeployer extends BasicBootstrap { +public class EmbeddedBeansDeployer extends BasicBootstrap +{ + // provide logging + private static final Log log = LogFactory.getLog(EmbeddedBeansDeployer.class); private Kernel kernel; private BasicXMLDeployer deployer; - public EmbeddedBeansDeployer() { + public EmbeddedBeansDeployer() + { // Get or bootstrap the kernel kernel = KernelLocator.getKernel(); - if (kernel == null) { - try { + if (kernel == null) + { + try + { super.bootstrap(); kernel = super.getKernel(); - } catch (Throwable e) { + log.debug("bootstrap kernel: " + kernel); + } + catch (Throwable e) + { throw new JBPMException("Cannot bootstrap kernel", e); } } @@ -60,10 +70,13 @@ /** * Deploy MC beans from URL */ - public void deploy(URL url) { - + public void deploy(URL url) + { + log.debug("deploy: " + url); + // Deploy the beans - try { + try + { deployer.deploy(url); deployer.validate(); @@ -71,7 +84,9 @@ if (KernelLocator.getKernel() == null) throw new JBPMException("KernelLocator not deployed as MC bean"); - } catch (Throwable e) { + } + catch (Throwable e) + { throw new JBPMException("Cannot deploy beans from: " + url, e); } } @@ -79,10 +94,15 @@ /** * Undeploy MC beans from URL */ - public void undeploy(URL url) { - try { + public void undeploy(URL url) + { + log.debug("undeploy: " + url); + try + { deployer.undeploy(url); - } catch (Throwable e) { + } + catch (Throwable e) + { throw new JBPMException("Cannot undeploy beans from: " + url, e); } } Modified: api/trunk/src/test/java/org/jboss/bpm/AbstractAPITestCase.java =================================================================== --- api/trunk/src/test/java/org/jboss/bpm/AbstractAPITestCase.java 2008-07-03 14:49:12 UTC (rev 1497) +++ api/trunk/src/test/java/org/jboss/bpm/AbstractAPITestCase.java 2008-07-03 14:55:06 UTC (rev 1498) @@ -27,11 +27,15 @@ import junit.framework.TestCase; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.jboss.bpm.JBPMException; import org.jboss.bpm.client.EmbeddedBeansDeployer; public abstract class AbstractAPITestCase extends TestCase { + // provide logging + private static final Log log = LogFactory.getLog(AbstractAPITestCase.class); // Every test case has a deployer private EmbeddedBeansDeployer deployer; @@ -43,6 +47,7 @@ protected void setUp() throws Exception { super.setUp(); + log.debug("setUp: " + getName()); deployer = new EmbeddedBeansDeployer(); deployTestBeans(getBeansConfig()); } @@ -50,8 +55,9 @@ @Override protected void tearDown() throws Exception { + log.debug("tearDown: " + getName()); + undeployTestBeans(getBeansConfig()); super.tearDown(); - undeployTestBeans(getBeansConfig()); } // Deploy a beans config |
From: <do-...@jb...> - 2008-07-03 14:49:15
|
Author: tho...@jb... Date: 2008-07-03 10:49:12 -0400 (Thu, 03 Jul 2008) New Revision: 1497 Added: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/ProcessDefinitionAdapter.java Removed: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/ProcessDefinitionAdapter.java Modified: jbpm3/trunk/.classpath jbpm3/trunk/modules/jpdl/core/pom.xml jbpm3/trunk/modules/jpdl/core/scripts/assembly-config.xml jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ExecutionManagerImpl.java jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ProcessDefinitionManagerImpl.java jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/ProcessDefinitionImpl.java Log: Restore PDM impl Modified: jbpm3/trunk/.classpath =================================================================== --- jbpm3/trunk/.classpath 2008-07-03 14:09:05 UTC (rev 1496) +++ jbpm3/trunk/.classpath 2008-07-03 14:49:12 UTC (rev 1497) @@ -1,8 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="modules/jpdl/core/src/main/java"/> - <classpathentry kind="src" path="modules/jpdl/integration/src/test/java"/> - <classpathentry kind="src" path="modules/jpdl/integration/src/main/java"/> <classpathentry kind="src" path="modules/jpdl/core/src/test/java"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/> Modified: jbpm3/trunk/modules/jpdl/core/pom.xml =================================================================== --- jbpm3/trunk/modules/jpdl/core/pom.xml 2008-07-03 14:09:05 UTC (rev 1496) +++ jbpm3/trunk/modules/jpdl/core/pom.xml 2008-07-03 14:49:12 UTC (rev 1497) @@ -144,6 +144,7 @@ <exclude>hibernate.cfg.xml</exclude> <exclude>jbpm.cfg.xml</exclude> <exclude>jbpm.mail.templates.xml</exclude> + <exclude>jbpm-beans.xml</exclude> </excludes> </configuration> </plugin> Modified: jbpm3/trunk/modules/jpdl/core/scripts/assembly-config.xml =================================================================== --- jbpm3/trunk/modules/jpdl/core/scripts/assembly-config.xml 2008-07-03 14:09:05 UTC (rev 1496) +++ jbpm3/trunk/modules/jpdl/core/scripts/assembly-config.xml 2008-07-03 14:49:12 UTC (rev 1497) @@ -13,6 +13,7 @@ <include>hibernate.cfg.xml</include> <include>jbpm.cfg.xml</include> <include>jbpm.mail.templates.xml</include> + <include>jbpm-beans.xml</include> </includes> </fileSet> <fileSet> Modified: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ExecutionManagerImpl.java =================================================================== --- jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ExecutionManagerImpl.java 2008-07-03 14:09:05 UTC (rev 1496) +++ jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ExecutionManagerImpl.java 2008-07-03 14:49:12 UTC (rev 1497) @@ -27,6 +27,7 @@ import org.jboss.bpm.client.ExecutionFactory; import org.jboss.bpm.client.ProcessEngine; import org.jboss.bpm.client.ProcessInstance; +import org.jbpm.integration.def.ProcessDefinitionImpl; /** * TODO Modified: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ProcessDefinitionManagerImpl.java =================================================================== --- jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ProcessDefinitionManagerImpl.java 2008-07-03 14:09:05 UTC (rev 1496) +++ jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ProcessDefinitionManagerImpl.java 2008-07-03 14:49:12 UTC (rev 1497) @@ -30,6 +30,7 @@ import org.jboss.bpm.client.ProcessDefinitionManager; import org.jboss.bpm.client.ProcessEngine; import org.jboss.bpm.def.ProcessDefinition; +import org.jbpm.integration.def.ProcessDefinitionAdapter; import org.jbpm.jpdl.JpdlException; /** Deleted: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/ProcessDefinitionAdapter.java =================================================================== --- jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/ProcessDefinitionAdapter.java 2008-07-03 14:09:05 UTC (rev 1496) +++ jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/ProcessDefinitionAdapter.java 2008-07-03 14:49:12 UTC (rev 1497) @@ -1,86 +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.jbpm.integration.def; - -// $Id$ - -import java.util.List; - -import org.jboss.bpm.def.Node; -import org.jboss.bpm.def.ProcessDefinition; -import org.jbpm.graph.node.EndState; -import org.jbpm.graph.node.StartState; - -/** - * Adapts on jBPM3 ProcessDefinition to an API ProcessDefinition - * - * @author tho...@jb... - * @since 18-Jun-2008 - */ -class ProcessDefinitionAdapter -{ - - static ProcessDefinition buildProcessDefinition(org.jbpm.graph.def.ProcessDefinition oldPD) - { - ProcessDefinitionImpl apiPD = new ProcessDefinitionImpl(oldPD); - List<org.jbpm.graph.def.Node> oldNodes = oldPD.getNodes(); - for (org.jbpm.graph.def.Node oldNode : oldNodes) - { - Node apiNode = NodeAdapter.adaptNode(apiPD, oldNode); - apiPD.addNode(apiNode); - } - - // validate - validateProcessDefinition(apiPD); - - return apiPD; - } - - private static void validateProcessDefinition(ProcessDefinitionImpl apiPD) - { - // These methods are expected to throw exceptions if there are no such states - apiPD.getStartNode(); - apiPD.getEndNodes(); - } - - static class NodeAdapter - { - - static Node adaptNode(ProcessDefinition pDef, org.jbpm.graph.def.Node oldNode) - { - Node apiNode; - if (oldNode instanceof StartState) - { - apiNode = new StartNodeImpl(pDef, oldNode); - } - else if (oldNode instanceof EndState) - { - apiNode = new EndNodeImpl(pDef, oldNode); - } - else - { - apiNode = new NodeImpl(pDef, oldNode); - } - return apiNode; - } - } -} Added: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/ProcessDefinitionAdapter.java =================================================================== --- jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/ProcessDefinitionAdapter.java (rev 0) +++ jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/ProcessDefinitionAdapter.java 2008-07-03 14:49:12 UTC (rev 1497) @@ -0,0 +1,89 @@ +/* + * 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.integration.def; + +// $Id$ + +import java.util.List; + +import org.jboss.bpm.def.Node; +import org.jboss.bpm.def.ProcessDefinition; +import org.jbpm.graph.node.EndState; +import org.jbpm.graph.node.StartState; +import org.jbpm.integration.def.EndNodeImpl; +import org.jbpm.integration.def.ProcessDefinitionImpl; +import org.jbpm.integration.def.StartNodeImpl; + +/** + * Adapts on jBPM3 ProcessDefinition to an API ProcessDefinition + * + * @author tho...@jb... + * @since 18-Jun-2008 + */ +public class ProcessDefinitionAdapter +{ + + public static ProcessDefinition buildProcessDefinition(org.jbpm.graph.def.ProcessDefinition oldPD) + { + ProcessDefinitionImpl apiPD = new ProcessDefinitionImpl(oldPD); + List<org.jbpm.graph.def.Node> oldNodes = oldPD.getNodes(); + for (org.jbpm.graph.def.Node oldNode : oldNodes) + { + Node apiNode = NodeAdapter.adaptNode(apiPD, oldNode); + apiPD.addNode(apiNode); + } + + // validate + validateProcessDefinition(apiPD); + + return apiPD; + } + + private static void validateProcessDefinition(ProcessDefinitionImpl apiPD) + { + // These methods are expected to throw exceptions if there are no such states + apiPD.getStartNode(); + apiPD.getEndNodes(); + } + + static class NodeAdapter + { + + static Node adaptNode(ProcessDefinition pDef, org.jbpm.graph.def.Node oldNode) + { + Node apiNode; + if (oldNode instanceof StartState) + { + apiNode = new StartNodeImpl(pDef, oldNode); + } + else if (oldNode instanceof EndState) + { + apiNode = new EndNodeImpl(pDef, oldNode); + } + else + { + apiNode = new NodeImpl(pDef, oldNode); + } + return apiNode; + } + } +} Modified: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/ProcessDefinitionImpl.java =================================================================== --- jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/ProcessDefinitionImpl.java 2008-07-03 14:09:05 UTC (rev 1496) +++ jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/ProcessDefinitionImpl.java 2008-07-03 14:49:12 UTC (rev 1497) @@ -34,9 +34,9 @@ */ public class ProcessDefinitionImpl extends ProcessDefinition { - org.jbpm.graph.def.ProcessDefinition oldPD; + public org.jbpm.graph.def.ProcessDefinition oldPD; - ProcessDefinitionImpl(org.jbpm.graph.def.ProcessDefinition oldPD) + public ProcessDefinitionImpl(org.jbpm.graph.def.ProcessDefinition oldPD) { this.oldPD = oldPD; init(oldPD.getName()); |
From: <do-...@jb...> - 2008-07-03 14:09:07
|
Author: tho...@jb... Date: 2008-07-03 10:09:05 -0400 (Thu, 03 Jul 2008) New Revision: 1496 Modified: api/trunk/.classpath api/trunk/src/test/java/org/jboss/bpm/samples/activity/BasicActivityTest.java api/trunk/src/test/java/org/jboss/bpm/samples/activity/MyActivity.java Log: Disable Activity test Modified: api/trunk/.classpath =================================================================== --- api/trunk/.classpath 2008-07-03 13:34:00 UTC (rev 1495) +++ api/trunk/.classpath 2008-07-03 14:09:05 UTC (rev 1496) @@ -4,7 +4,5 @@ <classpathentry kind="src" path="src/test/java"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/> - <classpathentry kind="lib" path="/jbpm/modules/jpdl/core/target/classes"/> - <classpathentry kind="lib" path="/jbpm/modules/jpdl/integration/target/classes"/> <classpathentry kind="output" path="target/eclipse-classes"/> </classpath> Modified: api/trunk/src/test/java/org/jboss/bpm/samples/activity/BasicActivityTest.java =================================================================== --- api/trunk/src/test/java/org/jboss/bpm/samples/activity/BasicActivityTest.java 2008-07-03 13:34:00 UTC (rev 1495) +++ api/trunk/src/test/java/org/jboss/bpm/samples/activity/BasicActivityTest.java 2008-07-03 14:09:05 UTC (rev 1496) @@ -62,13 +62,10 @@ // Signal the execution ex.signal(); - - // Verify the nodes assertEquals(pd.findNode("stateA"), ex.getNode()); // Signal the execution ex.signal(); - assertEquals(pd.findNode("end"), ex.getNode()); } } Modified: api/trunk/src/test/java/org/jboss/bpm/samples/activity/MyActivity.java =================================================================== --- api/trunk/src/test/java/org/jboss/bpm/samples/activity/MyActivity.java 2008-07-03 13:34:00 UTC (rev 1495) +++ api/trunk/src/test/java/org/jboss/bpm/samples/activity/MyActivity.java 2008-07-03 14:09:05 UTC (rev 1496) @@ -31,7 +31,7 @@ { public void execute(Node node, Context ctx) { - String name = node.getName(); - ctx.addAttachment(String.class, "Activity on: " + name); + //String name = node.getName(); + //ctx.addAttachment(String.class, "Activity on: " + name); } } |
From: <do-...@jb...> - 2008-07-03 13:34:08
|
Author: tho...@jb... Date: 2008-07-03 09:34:00 -0400 (Thu, 03 Jul 2008) New Revision: 1495 Added: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/ jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/EndNodeImpl.java jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/NodeImpl.java jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/ProcessDefinitionAdapter.java jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/ProcessDefinitionImpl.java jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/StartNodeImpl.java Log: Update API to introduce Activity Added: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/EndNodeImpl.java =================================================================== --- jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/EndNodeImpl.java (rev 0) +++ jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/EndNodeImpl.java 2008-07-03 13:34:00 UTC (rev 1495) @@ -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.jbpm.integration.def; + +// $Id$ + +import org.jboss.bpm.def.EndNode; +import org.jboss.bpm.def.ProcessDefinition; + +/** + * TODO + * + * @author tho...@jb... + * @since 18-Jun-2008 + */ +public class EndNodeImpl extends EndNode +{ + private org.jbpm.graph.def.Node oldNode; + + EndNodeImpl(ProcessDefinition def, org.jbpm.graph.def.Node oldNode) + { + super(def); + this.oldNode = oldNode; + init(oldNode.getName()); + } + + @Override + public String getName() + { + return oldNode.getName(); + } + + @Override + protected void setName(String name) + { + oldNode.setName(name); + } +} Property changes on: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/EndNodeImpl.java ___________________________________________________________________ Name: svn:keywords + Id Revision Name: svn:eol-style + LF Added: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/NodeImpl.java =================================================================== --- jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/NodeImpl.java (rev 0) +++ jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/NodeImpl.java 2008-07-03 13:34:00 UTC (rev 1495) @@ -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.jbpm.integration.def; + +//$Id$ + +import org.jboss.bpm.def.Node; +import org.jboss.bpm.def.ProcessDefinition; + +/** + * TODO + * + * @author tho...@jb... + * @since 18-Jun-2008 + */ +public class NodeImpl extends Node +{ + private org.jbpm.graph.def.Node oldNode; + + NodeImpl(ProcessDefinition def, org.jbpm.graph.def.Node oldNode) + { + super(def); + this.oldNode = oldNode; + init(oldNode.getName()); + } + + @Override + public String getName() + { + return oldNode.getName(); + } + + @Override + protected void setName(String name) + { + oldNode.setName(name); + } +} Property changes on: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/NodeImpl.java ___________________________________________________________________ Name: svn:keywords + Id Revision Name: svn:eol-style + LF Added: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/ProcessDefinitionAdapter.java =================================================================== --- jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/ProcessDefinitionAdapter.java (rev 0) +++ jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/ProcessDefinitionAdapter.java 2008-07-03 13:34:00 UTC (rev 1495) @@ -0,0 +1,86 @@ +/* + * 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.integration.def; + +// $Id$ + +import java.util.List; + +import org.jboss.bpm.def.Node; +import org.jboss.bpm.def.ProcessDefinition; +import org.jbpm.graph.node.EndState; +import org.jbpm.graph.node.StartState; + +/** + * Adapts on jBPM3 ProcessDefinition to an API ProcessDefinition + * + * @author tho...@jb... + * @since 18-Jun-2008 + */ +class ProcessDefinitionAdapter +{ + + static ProcessDefinition buildProcessDefinition(org.jbpm.graph.def.ProcessDefinition oldPD) + { + ProcessDefinitionImpl apiPD = new ProcessDefinitionImpl(oldPD); + List<org.jbpm.graph.def.Node> oldNodes = oldPD.getNodes(); + for (org.jbpm.graph.def.Node oldNode : oldNodes) + { + Node apiNode = NodeAdapter.adaptNode(apiPD, oldNode); + apiPD.addNode(apiNode); + } + + // validate + validateProcessDefinition(apiPD); + + return apiPD; + } + + private static void validateProcessDefinition(ProcessDefinitionImpl apiPD) + { + // These methods are expected to throw exceptions if there are no such states + apiPD.getStartNode(); + apiPD.getEndNodes(); + } + + static class NodeAdapter + { + + static Node adaptNode(ProcessDefinition pDef, org.jbpm.graph.def.Node oldNode) + { + Node apiNode; + if (oldNode instanceof StartState) + { + apiNode = new StartNodeImpl(pDef, oldNode); + } + else if (oldNode instanceof EndState) + { + apiNode = new EndNodeImpl(pDef, oldNode); + } + else + { + apiNode = new NodeImpl(pDef, oldNode); + } + return apiNode; + } + } +} Property changes on: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/ProcessDefinitionAdapter.java ___________________________________________________________________ Name: svn:keywords + Id Revision Name: svn:eol-style + LF Added: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/ProcessDefinitionImpl.java =================================================================== --- jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/ProcessDefinitionImpl.java (rev 0) +++ jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/ProcessDefinitionImpl.java 2008-07-03 13:34:00 UTC (rev 1495) @@ -0,0 +1,62 @@ +/* + * 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.integration.def; + +//$Id$ + +import org.jboss.bpm.def.Node; +import org.jboss.bpm.def.ProcessDefinition; + +/** + * A jBPM3 implementation of a process definition + * + * @author tho...@jb... + * @since 18-Jun-2008 + */ +public class ProcessDefinitionImpl extends ProcessDefinition +{ + org.jbpm.graph.def.ProcessDefinition oldPD; + + ProcessDefinitionImpl(org.jbpm.graph.def.ProcessDefinition oldPD) + { + this.oldPD = oldPD; + init(oldPD.getName()); + } + + // Add a node + public void addNode(Node apiNode) + { + super.addNode(apiNode); + } + + @Override + public String getName() + { + return oldPD.getName(); + } + + @Override + protected void setName(String name) + { + oldPD.setName(name); + } +} Property changes on: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/ProcessDefinitionImpl.java ___________________________________________________________________ Name: svn:keywords + Id Revision Name: svn:eol-style + LF Added: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/StartNodeImpl.java =================================================================== --- jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/StartNodeImpl.java (rev 0) +++ jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/StartNodeImpl.java 2008-07-03 13:34:00 UTC (rev 1495) @@ -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.jbpm.integration.def; + +//$Id$ + +import org.jboss.bpm.def.ProcessDefinition; +import org.jboss.bpm.def.StartNode; + +/** + * TODO + * + * @author tho...@jb... + * @since 18-Jun-2008 + */ +public class StartNodeImpl extends StartNode +{ + private org.jbpm.graph.def.Node oldNode; + + StartNodeImpl(ProcessDefinition def, org.jbpm.graph.def.Node oldNode) + { + super(def); + this.oldNode = oldNode; + init(oldNode.getName()); + } + + @Override + public String getName() + { + return oldNode.getName(); + } + + @Override + protected void setName(String name) + { + oldNode.setName(name); + } +} Property changes on: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/def/StartNodeImpl.java ___________________________________________________________________ Name: svn:keywords + Id Revision Name: svn:eol-style + LF |
From: <do-...@jb...> - 2008-07-03 13:27:46
|
Author: tho...@jb... Date: 2008-07-03 09:27:44 -0400 (Thu, 03 Jul 2008) New Revision: 1494 Added: api/trunk/src/main/java/org/jboss/bpm/def/ api/trunk/src/main/java/org/jboss/bpm/def/EndNode.java api/trunk/src/main/java/org/jboss/bpm/def/Node.java api/trunk/src/main/java/org/jboss/bpm/def/ProcessDefinition.java api/trunk/src/main/java/org/jboss/bpm/def/StartNode.java api/trunk/src/main/java/org/jboss/bpm/runtime/ api/trunk/src/main/java/org/jboss/bpm/runtime/Activity.java api/trunk/src/main/java/org/jboss/bpm/runtime/RuntimeExecution.java api/trunk/src/main/java/org/jboss/bpm/runtime/RuntimeNode.java api/trunk/src/main/java/org/jboss/bpm/runtime/Transition.java api/trunk/src/main/java/org/jboss/bpm/runtime/TransitionRouter.java api/trunk/src/test/java/org/jboss/bpm/samples/activity/ api/trunk/src/test/java/org/jboss/bpm/samples/activity/BasicActivityTest.java api/trunk/src/test/java/org/jboss/bpm/samples/activity/MyActivity.java Removed: api/trunk/src/main/java/org/jboss/bpm/client/EndNode.java api/trunk/src/main/java/org/jboss/bpm/client/Node.java api/trunk/src/main/java/org/jboss/bpm/client/ProcessDefinition.java api/trunk/src/main/java/org/jboss/bpm/client/StartNode.java Modified: api/trunk/docs/VioletUML/ClientView.class.violet api/trunk/pom.xml api/trunk/src/main/java/org/jboss/bpm/Context.java api/trunk/src/main/java/org/jboss/bpm/client/ContextImpl.java api/trunk/src/main/java/org/jboss/bpm/client/Execution.java api/trunk/src/main/java/org/jboss/bpm/client/ExecutionFactory.java api/trunk/src/main/java/org/jboss/bpm/client/ProcessDefinitionManager.java api/trunk/src/main/java/org/jboss/bpm/client/ProcessEngine.java api/trunk/src/main/java/org/jboss/bpm/client/ProcessInstance.java api/trunk/src/main/java/org/jboss/bpm/client/ProcessInstanceFactory.java api/trunk/src/test/java/org/jboss/bpm/client/MockProcessEngine.java api/trunk/src/test/java/org/jboss/bpm/client/ProcessDefinitionTest.java api/trunk/src/test/java/org/jboss/bpm/samples/basic/BasicSequenceTest.java Log: Update API to introduce Activity Modified: api/trunk/docs/VioletUML/ClientView.class.violet =================================================================== --- api/trunk/docs/VioletUML/ClientView.class.violet 2008-07-03 13:27:22 UTC (rev 1493) +++ api/trunk/docs/VioletUML/ClientView.class.violet 2008-07-03 13:27:44 UTC (rev 1494) @@ -84,8 +84,7 @@ <object id="ClassNode4" class="com.horstmann.violet.ClassNode"> <void property="attributes"> <void property="text"> - <string>name -metadata</string> + <string>name</string> </void> </void> <void property="methods"> @@ -134,27 +133,6 @@ </object> </void> <void method="addNode"> - <object id="ClassNode6" class="com.horstmann.violet.ClassNode"> - <void property="attributes"> - <void property="text"> - <string>attachments -</string> - </void> - </void> - <void property="name"> - <void property="text"> - <string>ProcessState</string> - </void> - </void> - </object> - <object class="java.awt.geom.Point2D$Double"> - <void method="setLocation"> - <double>611.0</double> - <double>365.0</double> - </void> - </object> - </void> - <void method="addNode"> <object class="com.horstmann.violet.PackageNode"> <void property="contents"> <void property="text"> @@ -173,7 +151,7 @@ </object> </void> <void method="addNode"> - <object id="ClassNode7" class="com.horstmann.violet.ClassNode"> + <object id="ClassNode6" class="com.horstmann.violet.ClassNode"> <void property="name"> <void property="text"> <string>ProcessNode</string> @@ -204,6 +182,48 @@ </void> </object> </void> + <void method="addNode"> + <object id="ClassNode7" class="com.horstmann.violet.ClassNode"> + <void property="attributes"> + <void property="text"> + <string>attachments +properties</string> + </void> + </void> + <void property="name"> + <void property="text"> + <string>Context</string> + </void> + </void> + </object> + <object class="java.awt.geom.Point2D$Double"> + <void method="setLocation"> + <double>607.0</double> + <double>358.0</double> + </void> + </object> + </void> + <void method="addNode"> + <object id="ClassNode8" class="com.horstmann.violet.ClassNode"> + <void property="attributes"> + <void property="text"> + <string>attachments +properties</string> + </void> + </void> + <void property="name"> + <void property="text"> + <string>Context</string> + </void> + </void> + </object> + <object class="java.awt.geom.Point2D$Double"> + <void method="setLocation"> + <double>48.0</double> + <double>363.0</double> + </void> + </object> + </void> <void method="connect"> <object class="com.horstmann.violet.ClassRelationshipEdge"> <void property="bentStyle"> @@ -261,25 +281,13 @@ <void method="connect"> <object class="com.horstmann.violet.ClassRelationshipEdge"> <void property="bentStyle"> - <object class="com.horstmann.violet.BentStyle" field="HVH"/> - </void> - <void property="startArrowHead"> - <object class="com.horstmann.violet.ArrowHead" field="DIAMOND"/> - </void> - </object> - <object idref="ClassNode5"/> - <object idref="ClassNode6"/> - </void> - <void method="connect"> - <object class="com.horstmann.violet.ClassRelationshipEdge"> - <void property="bentStyle"> <object class="com.horstmann.violet.BentStyle" field="VHV"/> </void> <void property="endArrowHead"> <object class="com.horstmann.violet.ArrowHead" field="TRIANGLE"/> </void> </object> - <object idref="ClassNode7"/> + <object idref="ClassNode6"/> <object idref="ClassNode1"/> </void> <void method="connect"> @@ -291,7 +299,7 @@ <object class="com.horstmann.violet.ArrowHead" field="V"/> </void> </object> - <object idref="ClassNode7"/> + <object idref="ClassNode6"/> <object idref="ClassNode0"/> </void> <void method="connect"> @@ -329,5 +337,35 @@ <object idref="ClassNode5"/> <object idref="NoteNode0"/> </void> + <void method="connect"> + <object class="com.horstmann.violet.ClassRelationshipEdge"> + <void property="bentStyle"> + <object class="com.horstmann.violet.BentStyle" field="VHV"/> + </void> + <void property="endArrowHead"> + <object class="com.horstmann.violet.ArrowHead" field="TRIANGLE"/> + </void> + <void property="lineStyle"> + <object class="com.horstmann.violet.LineStyle" field="DOTTED"/> + </void> + </object> + <object idref="ClassNode5"/> + <object idref="ClassNode7"/> + </void> + <void method="connect"> + <object class="com.horstmann.violet.ClassRelationshipEdge"> + <void property="bentStyle"> + <object class="com.horstmann.violet.BentStyle" field="VHV"/> + </void> + <void property="endArrowHead"> + <object class="com.horstmann.violet.ArrowHead" field="TRIANGLE"/> + </void> + <void property="lineStyle"> + <object class="com.horstmann.violet.LineStyle" field="DOTTED"/> + </void> + </object> + <object idref="ClassNode4"/> + <object idref="ClassNode8"/> + </void> </object> </java> Modified: api/trunk/pom.xml =================================================================== --- api/trunk/pom.xml 2008-07-03 13:27:22 UTC (rev 1493) +++ api/trunk/pom.xml 2008-07-03 13:27:44 UTC (rev 1494) @@ -113,10 +113,17 @@ <dependencies> <dependency> <groupId>org.jboss.jbpm</groupId> - <artifactId>jbpm-jpdl-integration</artifactId> + <artifactId>jbpm-jpdl-core</artifactId> <version>3.2.4-SNAPSHOT</version> <scope>test</scope> </dependency> + <dependency> + <groupId>org.jboss.jbpm</groupId> + <artifactId>jbpm-jpdl-core</artifactId> + <version>3.2.4-SNAPSHOT</version> + <classifier>config</classifier> + <scope>test</scope> + </dependency> </dependencies> </profile> <!-- Modified: api/trunk/src/main/java/org/jboss/bpm/Context.java =================================================================== --- api/trunk/src/main/java/org/jboss/bpm/Context.java 2008-07-03 13:27:22 UTC (rev 1493) +++ api/trunk/src/main/java/org/jboss/bpm/Context.java 2008-07-03 13:27:44 UTC (rev 1494) @@ -24,41 +24,48 @@ //$Id$ import java.util.Collection; -import java.util.Map; -import java.util.Set; /** - * A general extendible artifact + * A general extendible artifact * * @author Tho...@jb... - * @since 20-Apr-2007 + * @since 20-Apr-2007 */ public interface Context { - /** Add arbitrary attachments */ - <T> T addAttachment(Class<T> key, Object value); - - /** Get arbitrary attachments */ - <T> Collection<T> getAttachments(); - - /** Get an arbitrary attachment */ - <T> T getAttachment(Class<T> key); - - /** Remove arbitrary attachments */ - <T> T removeAttachment(Class<T> key); + /** Get arbitrary attachments */ + Collection<Key> getAttachments(); - /** Get an property */ - Object getProperty(String key); - - /** Set a property */ - void setProperty(String key, Object value); - - /** Remove a property */ - void removeProperty(String key); - - /** Get the set of property names */ - Set<String> getProperties(); - - /** Set a map of properties */ - void setProperties(Map<String, Object> props); + /** Add arbitrary attachment */ + <T> T addAttachment(Class<T> clazz, Object value); + + /** Add arbitrary attachment with name */ + <T> T addAttachment(Class<T> clazz, String name, Object value); + + /** Add arbitrary attachment with name */ + <T> T addAttachment(String name, Object value); + + /** Get an arbitrary attachment */ + <T> T getAttachment(Class<T> clazz); + + /** Get an arbitrary attachment */ + <T> T getAttachment(Class<T> clazz, String name); + + /** Get an arbitrary attachment */ + <T> T getAttachment(String name); + + /** Remove arbitrary attachments */ + <T> T removeAttachment(Class<T> clazz); + + /** Remove arbitrary attachments */ + <T> T removeAttachment(Class<T> clazz, String name); + + /** Remove arbitrary attachments */ + <T> T removeAttachment(String name); + + interface Key + { + Class getClazz(); + String getName(); + } } \ No newline at end of file Modified: api/trunk/src/main/java/org/jboss/bpm/client/ContextImpl.java =================================================================== --- api/trunk/src/main/java/org/jboss/bpm/client/ContextImpl.java 2008-07-03 13:27:22 UTC (rev 1493) +++ api/trunk/src/main/java/org/jboss/bpm/client/ContextImpl.java 2008-07-03 13:27:44 UTC (rev 1494) @@ -26,63 +26,110 @@ import java.util.Collection; import java.util.HashMap; import java.util.Map; -import java.util.Set; import org.jboss.bpm.Context; /** - * A general extendible artifact + * A general extendible artifact * * @author Tho...@jb... - * @since 20-Apr-2007 + * @since 20-Apr-2007 */ class ContextImpl implements Context { - private Map<Class, Object> attachments = new HashMap<Class, Object>(); - private Map<String, Object> properties = new HashMap<String, Object>(); - - public Collection<Object> getAttachments() - { - return attachments.values(); - } - - public <T> T getAttachment(Class<T> clazz) - { - return (T)attachments.get(clazz); - } - - public <T> T addAttachment(Class<T> clazz, Object obj) - { - return (T)attachments.put(clazz, obj); - } + private Map<Key, Object> attachments = new HashMap<Key, Object>(); - public <T> T removeAttachment(Class<T> key) - { - return (T)attachments.remove(key); - } - - public Set<String> getProperties() - { - return properties.keySet(); - } + public Collection<Key> getAttachments() + { + return attachments.keySet(); + } - public Object getProperty(String key) - { - return properties.get(key); - } + public <T> T getAttachment(Class<T> clazz) + { + return (T)attachments.get(new KeyImpl(clazz, null)); + } - public void removeProperty(String key) - { - properties.remove(key); - } + public <T> T getAttachment(Class<T> clazz, String name) + { + return (T)attachments.get(new KeyImpl(clazz, name)); + } - public void setProperty(String key, Object value) - { - properties.put(key, value); - } + public <T> T getAttachment(String name) + { + return (T)attachments.get(new KeyImpl(Object.class, name)); + } - public void setProperties(Map<String, Object> props) - { - properties.putAll(props); - } + public <T> T addAttachment(Class<T> clazz, Object obj) + { + return (T)attachments.put(new KeyImpl(clazz, null), obj); + } + + public <T> T addAttachment(Class<T> clazz, String name, Object obj) + { + return (T)attachments.put(new KeyImpl(clazz, name), obj); + } + + public <T> T addAttachment(String name, Object obj) + { + return (T)attachments.put(new KeyImpl(Object.class, name), obj); + } + + public <T> T removeAttachment(Class<T> clazz) + { + return (T)attachments.remove(new KeyImpl(clazz, null)); + } + + public <T> T removeAttachment(Class<T> clazz, String name) + { + return (T)attachments.remove(new KeyImpl(clazz, name)); + } + + public <T> T removeAttachment(String name) + { + return (T)attachments.remove(new KeyImpl(Object.class, name)); + } + + static class KeyImpl implements Key + { + Class clazz; + String name; + + public KeyImpl(Class clazz, String name) + { + this.clazz = clazz; + this.name = name; + } + + public Class getClazz() + { + return clazz; + } + + public String getName() + { + return name; + } + + @Override + public boolean equals(Object obj) + { + if (!(obj instanceof Key)) + return false; + if (obj == this) + return true; + return obj.toString().equals(toString()); + } + + @Override + public int hashCode() + { + return toString().hashCode(); + } + + @Override + public String toString() + { + return "[" + clazz.getName() + "," + name + "]"; + } + } } Deleted: api/trunk/src/main/java/org/jboss/bpm/client/EndNode.java =================================================================== --- api/trunk/src/main/java/org/jboss/bpm/client/EndNode.java 2008-07-03 13:27:22 UTC (rev 1493) +++ api/trunk/src/main/java/org/jboss/bpm/client/EndNode.java 2008-07-03 13:27:44 UTC (rev 1494) @@ -1,38 +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.client; - -// $Id$ - -/** - * Represents an end node in the process definition. - * - * @author tho...@jb... - * @since 18-Jun-2008 - */ -public abstract class EndNode extends Node -{ - protected EndNode(ProcessDefinition pdef) - { - super(pdef); - } -} \ No newline at end of file Modified: api/trunk/src/main/java/org/jboss/bpm/client/Execution.java =================================================================== --- api/trunk/src/main/java/org/jboss/bpm/client/Execution.java 2008-07-03 13:27:22 UTC (rev 1493) +++ api/trunk/src/main/java/org/jboss/bpm/client/Execution.java 2008-07-03 13:27:44 UTC (rev 1494) @@ -21,13 +21,14 @@ */ package org.jboss.bpm.client; +import org.jboss.bpm.Context; +import org.jboss.bpm.def.Node; + // $Id: $ /** - * Represents an execution of a process instance. + * Represents an execution of a process instance. The name of an execution is unique in the scope of the process instance. * - * The name of an execution is unique in the scope of the process instance. - * * @author tho...@jb... * @since 18-Jun-2008 */ @@ -35,6 +36,8 @@ { // The associated process instance private ProcessInstance pinst; + // The execution context + private Context context = new ContextImpl(); // Construct the execution protected Execution(ProcessInstance pinst) @@ -45,6 +48,12 @@ this.pinst = pinst; } + // Construct the execution from a copy + protected Execution(Execution ex) + { + this(ex.getProcessInstance()); + } + // Call to initialize fully protected void init(String name) { @@ -54,8 +63,10 @@ setName(name); } } - - /* Get the associated process instance */ + + /** + * Get the associated process instance + */ public ProcessInstance getProcessInstance() { return pinst; @@ -66,10 +77,18 @@ */ public abstract String getName(); - // Set the name for the execution + /** + * Get the context for this execution + */ + public Context getContext() + { + return context; + } + + // Set the name for the execution protected abstract void setName(String name); - /* + /** * Get the current node for this execution */ public final Node getNode() @@ -77,13 +96,11 @@ Node node = getNodeOverride(); return node; } - - /* - * Get the current node for this execution - */ + + // Override to get the node protected abstract Node getNodeOverride(); - /* + /** * Signal this execution */ public final void signal() @@ -91,9 +108,7 @@ signalOverride(); } - /* - * Signal this execution - */ + // Override to implement execution signalling protected abstract void signalOverride(); } \ No newline at end of file Modified: api/trunk/src/main/java/org/jboss/bpm/client/ExecutionFactory.java =================================================================== --- api/trunk/src/main/java/org/jboss/bpm/client/ExecutionFactory.java 2008-07-03 13:27:22 UTC (rev 1493) +++ api/trunk/src/main/java/org/jboss/bpm/client/ExecutionFactory.java 2008-07-03 13:27:44 UTC (rev 1494) @@ -23,7 +23,9 @@ // $Id: $ +import org.jboss.bpm.Context; import org.jboss.bpm.EngineShutdownException; +import org.jboss.bpm.Context.Key; /** * The execution manager is the entry point to create, find and otherwise manage process executions. @@ -53,11 +55,13 @@ public static ExecutionFactory locateExecutionManager() { ProcessEngine engine = ProcessEngineLocator.locateProcessEngine(); - return engine.getExecutionManager(); + return engine.getExecutionFactory(); } /** - * Create an execution for a given process instance + * Create an execution for a given process instance. + * The process instance context is copied to the execution context. + * Note, that this is a shallow copy. Mutable objects should generally not be put into the context. */ public final Execution createExecution(ProcessInstance pinst) { @@ -65,7 +69,15 @@ if (engine.isPrepareForShutdown()) throw new EngineShutdownException("Cannot create new Execution while engine is shutting down"); + // Copy the instance context to the execution context + Context context = pinst.getContext(); Execution ex = createExecutionOverride(pinst); + for (Key key : context.getAttachments()) + { + Object att = context.getAttachment(key.getClazz(), key.getName()); + ex.getContext().addAttachment(key.getClazz(), key.getName(), att); + } + return ex; } Deleted: api/trunk/src/main/java/org/jboss/bpm/client/Node.java =================================================================== --- api/trunk/src/main/java/org/jboss/bpm/client/Node.java 2008-07-03 13:27:22 UTC (rev 1493) +++ api/trunk/src/main/java/org/jboss/bpm/client/Node.java 2008-07-03 13:27:44 UTC (rev 1494) @@ -1,73 +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.client; - -// $Id:$ - -/** - * Represents a node in the process definition. A node is an immutable object. The name of a node is unique in the scope of the process definition. - * - * @author tho...@jb... - * @since 18-Jun-2008 - */ -public abstract class Node -{ - // The associated process definition - private ProcessDefinition pdef; - - // Construct the node - protected Node(ProcessDefinition pdef) - { - if (pdef == null) - throw new IllegalArgumentException("Process definition cannot be null"); - - this.pdef = pdef; - } - - // Call to initialize fully - protected void init(String name) - { - if (name == null) - { - name = "AnonymousNode#" + pdef.getNodes().size(); - setName(name); - } - } - - /** Get the associated process definition */ - public ProcessDefinition getProcessDefinition() - { - return pdef; - } - - /** Get the node name */ - public abstract String getName(); - - // Set the node name - protected abstract void setName(String name); - - /** Returns a string representation of the object. */ - public String toString() - { - return "Node[" + getName() + "]"; - } -} \ No newline at end of file Deleted: api/trunk/src/main/java/org/jboss/bpm/client/ProcessDefinition.java =================================================================== --- api/trunk/src/main/java/org/jboss/bpm/client/ProcessDefinition.java 2008-07-03 13:27:22 UTC (rev 1493) +++ api/trunk/src/main/java/org/jboss/bpm/client/ProcessDefinition.java 2008-07-03 13:27:44 UTC (rev 1494) @@ -1,229 +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.client; - -// $Id: $ - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.jboss.bpm.InvalidProcessDefinitionException; -import org.jboss.bpm.NameNotUniqueException; - -/** - * Represents the structural definition of a BPM process - * - * @author tho...@jb... - * @since 18-Jun-2008 - */ -public abstract class ProcessDefinition -{ - // The list of nodes - private List<Node> nodes = new ArrayList<Node>(); - // The set of process instances - private Set<ProcessInstance> pinstSet = new HashSet<ProcessInstance>(); - - // Construct the process definition - protected ProcessDefinition() - { - } - - // Call to initialize fully - protected void init(String name) - { - if (name == null) - { - ProcessDefinitionManager pdm = ProcessDefinitionManager.locateProcessDefinitionManager(); - name = "AnonymousDef#" + pdm.getProcessDefinitions().size(); - setName(name); - } - } - - /** - * Get the name - */ - public abstract String getName(); - - // Set the name - protected abstract void setName(String name); - - /** - * Get an unmutable list of node objects - */ - public List<Node> getNodes() - { - return Collections.unmodifiableList(nodes); - } - - /** - * Find a node for a given name - * - * @return null if the node is not defined - */ - public Node findNode(String name) - { - return findNodeInternal(name); - } - - /** - * Get the start node for this process definition - * - * @return The start node - * - * @throws InvalidProcessDefinitionException if there is no start node - */ - public StartNode getStartNode() - { - Node rootNode = getStartNodeInternal(); - if (rootNode == null) - throw new InvalidProcessDefinitionException("Process definition does not have a start node"); - - return (StartNode)rootNode; - } - - /** - * Get the set of end nodes - * - * @return an emty set if - */ - public Set<EndNode> getEndNodes() - { - Set<EndNode> endNodes = new HashSet<EndNode>(); - for (Node aux : nodes) - { - if (aux instanceof EndNode) - { - endNodes.add((EndNode)aux); - } - } - if (endNodes.size() == 0) - throw new InvalidProcessDefinitionException("Process definition does not have end nodes"); - - return endNodes; - } - - // Add a node - protected void addNode(Node apiNode) - { - if (apiNode instanceof StartNode && getStartNodeInternal() != null) - throw new InvalidProcessDefinitionException("Process definition cannot have multiple start nodes: " + apiNode); - - String name = apiNode.getName(); - if (findNodeInternal(name) != null) - throw new NameNotUniqueException("Node: " + name); - - nodes.add(apiNode); - } - - /** - * Create an instance of this process definition. - */ - public ProcessInstance createProcessInstance() - { - ProcessEngine engine = ProcessEngineLocator.locateProcessEngine(); - ProcessInstanceFactory pim = engine.getProcessInstanceManager(); - ProcessInstance pinst = pim.createProcessInstance(this); - return pinst; - } - - /** - * Get the set of registered process instances - */ - public Set<ProcessInstance> getProcessInstances() - { - return Collections.unmodifiableSet(pinstSet); - } - - /** - * Find a ProcessInstance for a given name - * @return null if it cannot be found - */ - public ProcessInstance findProcessInstance(String name) - { - for (ProcessInstance pinst : pinstSet) - { - if (pinst.getName() == name) - return pinst; - } - return null; - } - - /** - * Remove a ProcessInstance for a given name - */ - public void removeProcessInstance(String name) - { - for (ProcessInstance pinst : pinstSet) - { - if (pinst.getName() == name) - { - pinstSet.remove(pinst); - break; - } - } - } - - /* - * Create an execution for this process definition. Note, that this will automatically create a new process instance. - */ - public Execution createExecution() - { - ProcessEngine engine = ProcessEngineLocator.locateProcessEngine(); - ProcessInstanceFactory pim = engine.getProcessInstanceManager(); - ProcessInstance pinst = pim.createProcessInstance(this); - ExecutionFactory pem = engine.getExecutionManager(); - return pem.createExecution(pinst); - } - - // private - - private StartNode getStartNodeInternal() - { - Node rootNode = null; - for (Node aux : nodes) - { - if (aux instanceof StartNode) - { - rootNode = aux; - break; - } - } - return (StartNode)rootNode; - } - - private Node findNodeInternal(String name) - { - Node apiNode = null; - for (Node aux : nodes) - { - if (aux.getName().equals(name)) - { - apiNode = aux; - break; - } - } - return apiNode; - } -} \ No newline at end of file Modified: api/trunk/src/main/java/org/jboss/bpm/client/ProcessDefinitionManager.java =================================================================== --- api/trunk/src/main/java/org/jboss/bpm/client/ProcessDefinitionManager.java 2008-07-03 13:27:22 UTC (rev 1493) +++ api/trunk/src/main/java/org/jboss/bpm/client/ProcessDefinitionManager.java 2008-07-03 13:27:44 UTC (rev 1494) @@ -30,6 +30,7 @@ import java.util.Set; import org.jboss.bpm.EngineShutdownException; +import org.jboss.bpm.def.ProcessDefinition; /** * The process definition manager is the entry point to create, find and otherwise manage process definitions. Modified: api/trunk/src/main/java/org/jboss/bpm/client/ProcessEngine.java =================================================================== --- api/trunk/src/main/java/org/jboss/bpm/client/ProcessEngine.java 2008-07-03 13:27:22 UTC (rev 1493) +++ api/trunk/src/main/java/org/jboss/bpm/client/ProcessEngine.java 2008-07-03 13:27:44 UTC (rev 1494) @@ -39,9 +39,9 @@ // Injected through the MC protected ProcessDefinitionManager processDefinitionManager; // Injected through the MC - protected ProcessInstanceFactory processInstanceManager; + protected ProcessInstanceFactory processInstanceFactory; // Injected through the MC - protected ExecutionFactory executionManager; + protected ExecutionFactory executionFactory; // Flag to indicate that the Engine is shutting down private boolean prepareForShutdown; @@ -75,21 +75,21 @@ * Get the configured instance of the process instance manager * @return The process instance manager */ - public ProcessInstanceFactory getProcessInstanceManager() { - if (processInstanceManager == null) + public ProcessInstanceFactory getProcessInstanceFactory() { + if (processInstanceFactory == null) throw new IllegalStateException("ProcessInstanceManager not available through kernel configuration"); - return processInstanceManager; + return processInstanceFactory; } /** * Get the configured instance of the execution manager * @return The execution manager */ - public ExecutionFactory getExecutionManager() { - if (executionManager == null) + public ExecutionFactory getExecutionFactory() { + if (executionFactory == null) throw new IllegalStateException("ExecutionManager not available through kernel configuration"); - return executionManager; + return executionFactory; } } \ No newline at end of file Modified: api/trunk/src/main/java/org/jboss/bpm/client/ProcessInstance.java =================================================================== --- api/trunk/src/main/java/org/jboss/bpm/client/ProcessInstance.java 2008-07-03 13:27:22 UTC (rev 1493) +++ api/trunk/src/main/java/org/jboss/bpm/client/ProcessInstance.java 2008-07-03 13:27:44 UTC (rev 1494) @@ -27,6 +27,9 @@ import java.util.HashSet; import java.util.Set; +import org.jboss.bpm.Context; +import org.jboss.bpm.def.ProcessDefinition; + /** * Represents an instance of a BPM process. It is the combination of a process definition plus its associated instance data * @@ -41,6 +44,8 @@ private String name; // The map of executions private Set<Execution> execs = new HashSet<Execution>(); + // The pricess instance context + private Context context = new ContextImpl(); // Construct a process instance with a given process definition protected ProcessInstance(ProcessDefinition pdef) @@ -83,6 +88,14 @@ } /** + * Get the context for this execution + */ + public Context getContext() + { + return context; + } + + /** * Get the set of registered executions */ public Set<Execution> getExecutions() Modified: api/trunk/src/main/java/org/jboss/bpm/client/ProcessInstanceFactory.java =================================================================== --- api/trunk/src/main/java/org/jboss/bpm/client/ProcessInstanceFactory.java 2008-07-03 13:27:22 UTC (rev 1493) +++ api/trunk/src/main/java/org/jboss/bpm/client/ProcessInstanceFactory.java 2008-07-03 13:27:44 UTC (rev 1494) @@ -24,6 +24,7 @@ //$Id: $ import org.jboss.bpm.EngineShutdownException; +import org.jboss.bpm.def.ProcessDefinition; /** * The process instance manager is the entry point to create, find and otherwise @@ -51,7 +52,7 @@ public static ProcessInstanceFactory locateProcessInstanceManager() { ProcessEngine engine = ProcessEngineLocator.locateProcessEngine(); - return engine.getProcessInstanceManager(); + return engine.getProcessInstanceFactory(); } /* Deleted: api/trunk/src/main/java/org/jboss/bpm/client/StartNode.java =================================================================== --- api/trunk/src/main/java/org/jboss/bpm/client/StartNode.java 2008-07-03 13:27:22 UTC (rev 1493) +++ api/trunk/src/main/java/org/jboss/bpm/client/StartNode.java 2008-07-03 13:27:44 UTC (rev 1494) @@ -1,38 +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.client; - -// $Id$ - -/** - * Represents the root node in the process definition. - * - * @author tho...@jb... - * @since 18-Jun-2008 - */ -public abstract class StartNode extends Node -{ - protected StartNode(ProcessDefinition pdef) - { - super(pdef); - } -} \ No newline at end of file Copied: api/trunk/src/main/java/org/jboss/bpm/def/EndNode.java (from rev 1488, api/trunk/src/main/java/org/jboss/bpm/client/EndNode.java) =================================================================== --- api/trunk/src/main/java/org/jboss/bpm/def/EndNode.java (rev 0) +++ api/trunk/src/main/java/org/jboss/bpm/def/EndNode.java 2008-07-03 13:27:44 UTC (rev 1494) @@ -0,0 +1,39 @@ +/* + * 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.def; + + +// $Id$ + +/** + * Represents an end node in the process definition. + * + * @author tho...@jb... + * @since 18-Jun-2008 + */ +public abstract class EndNode extends Node +{ + protected EndNode(ProcessDefinition pdef) + { + super(pdef); + } +} \ No newline at end of file Copied: api/trunk/src/main/java/org/jboss/bpm/def/Node.java (from rev 1488, api/trunk/src/main/java/org/jboss/bpm/client/Node.java) =================================================================== --- api/trunk/src/main/java/org/jboss/bpm/def/Node.java (rev 0) +++ api/trunk/src/main/java/org/jboss/bpm/def/Node.java 2008-07-03 13:27:44 UTC (rev 1494) @@ -0,0 +1,80 @@ +/* + * 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.def; + + +// $Id:$ + +/** + * Represents a node in the process definition. A node is an immutable object. The name of a node is unique in the scope of the process definition. + * + * @author tho...@jb... + * @since 18-Jun-2008 + */ +public abstract class Node +{ + // The associated process definition + private ProcessDefinition pdef; + + // Construct the node + protected Node(ProcessDefinition pdef) + { + if (pdef == null) + throw new IllegalArgumentException("Process definition cannot be null"); + + this.pdef = pdef; + } + + // Construct the node from a copy + protected Node(Node node) + { + this(node.getProcessDefinition()); + } + + // Call to initialize fully + protected void init(String name) + { + if (name == null) + { + name = "AnonymousNode#" + pdef.getNodes().size(); + setName(name); + } + } + + /** Get the associated process definition */ + public ProcessDefinition getProcessDefinition() + { + return pdef; + } + + /** Get the node name */ + public abstract String getName(); + + // Set the node name + protected abstract void setName(String name); + + /** Returns a string representation of the object. */ + public String toString() + { + return "Node[" + getName() + "]"; + } +} \ No newline at end of file Copied: api/trunk/src/main/java/org/jboss/bpm/def/ProcessDefinition.java (from rev 1488, api/trunk/src/main/java/org/jboss/bpm/client/ProcessDefinition.java) =================================================================== --- api/trunk/src/main/java/org/jboss/bpm/def/ProcessDefinition.java (rev 0) +++ api/trunk/src/main/java/org/jboss/bpm/def/ProcessDefinition.java 2008-07-03 13:27:44 UTC (rev 1494) @@ -0,0 +1,236 @@ +/* + * 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.def; + +// $Id: $ + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.jboss.bpm.InvalidProcessDefinitionException; +import org.jboss.bpm.NameNotUniqueException; +import org.jboss.bpm.client.Execution; +import org.jboss.bpm.client.ExecutionFactory; +import org.jboss.bpm.client.ProcessDefinitionManager; +import org.jboss.bpm.client.ProcessEngine; +import org.jboss.bpm.client.ProcessEngineLocator; +import org.jboss.bpm.client.ProcessInstance; +import org.jboss.bpm.client.ProcessInstanceFactory; + +/** + * Represents the structural definition of a BPM process + * + * @author tho...@jb... + * @since 18-Jun-2008 + */ +public abstract class ProcessDefinition +{ + // The list of nodes + private List<Node> nodes = new ArrayList<Node>(); + // The set of process instances + private Set<ProcessInstance> pinstSet = new HashSet<ProcessInstance>(); + + // Construct the process definition + protected ProcessDefinition() + { + } + + // Call to initialize fully + protected void init(String name) + { + if (name == null) + { + ProcessDefinitionManager pdm = ProcessDefinitionManager.locateProcessDefinitionManager(); + name = "AnonymousDef#" + pdm.getProcessDefinitions().size(); + setName(name); + } + } + + /** + * Get the name + */ + public abstract String getName(); + + // Set the name + protected abstract void setName(String name); + + /** + * Get an unmutable list of node objects + */ + public List<Node> getNodes() + { + return Collections.unmodifiableList(nodes); + } + + /** + * Find a node for a given name + * + * @return null if the node is not defined + */ + public Node findNode(String name) + { + return findNodeInternal(name); + } + + /** + * Get the start node for this process definition + * + * @return The start node + * + * @throws InvalidProcessDefinitionException if there is no start node + */ + public StartNode getStartNode() + { + Node rootNode = getStartNodeInternal(); + if (rootNode == null) + throw new InvalidProcessDefinitionException("Process definition does not have a start node"); + + return (StartNode)rootNode; + } + + /** + * Get the set of end nodes + * + * @return an emty set if + */ + public Set<EndNode> getEndNodes() + { + Set<EndNode> endNodes = new HashSet<EndNode>(); + for (Node aux : nodes) + { + if (aux instanceof EndNode) + { + endNodes.add((EndNode)aux); + } + } + if (endNodes.size() == 0) + throw new InvalidProcessDefinitionException("Process definition does not have end nodes"); + + return endNodes; + } + + // Add a node + protected void addNode(Node apiNode) + { + if (apiNode instanceof StartNode && getStartNodeInternal() != null) + throw new InvalidProcessDefinitionException("Process definition cannot have multiple start nodes: " + apiNode); + + String name = apiNode.getName(); + if (findNodeInternal(name) != null) + throw new NameNotUniqueException("Node: " + name); + + nodes.add(apiNode); + } + + /** + * Create an instance of this process definition. + */ + public ProcessInstance createProcessInstance() + { + ProcessEngine engine = ProcessEngineLocator.locateProcessEngine(); + ProcessInstanceFactory pim = engine.getProcessInstanceFactory(); + ProcessInstance pinst = pim.createProcessInstance(this); + return pinst; + } + + /** + * Get the set of registered process instances + */ + public Set<ProcessInstance> getProcessInstances() + { + return Collections.unmodifiableSet(pinstSet); + } + + /** + * Find a ProcessInstance for a given name + * @return null if it cannot be found + */ + public ProcessInstance findProcessInstance(String name) + { + for (ProcessInstance pinst : pinstSet) + { + if (pinst.getName() == name) + return pinst; + } + return null; + } + + /** + * Remove a ProcessInstance for a given name + */ + public void removeProcessInstance(String name) + { + for (ProcessInstance pinst : pinstSet) + { + if (pinst.getName() == name) + { + pinstSet.remove(pinst); + break; + } + } + } + + /* + * Create an execution for this process definition. Note, that this will automatically create a new process instance. + */ + public Execution createExecution() + { + ProcessEngine engine = ProcessEngineLocator.locateProcessEngine(); + ProcessInstanceFactory pim = engine.getProcessInstanceFactory(); + ProcessInstance pinst = pim.createProcessInstance(this); + ExecutionFactory pem = engine.getExecutionFactory(); + return pem.createExecution(pinst); + } + + // private + + private StartNode getStartNodeInternal() + { + Node rootNode = null; + for (Node aux : nodes) + { + if (aux instanceof StartNode) + { + rootNode = aux; + break; + } + } + return (StartNode)rootNode; + } + + private Node findNodeInternal(String name) + { + Node apiNode = null; + for (Node aux : nodes) + { + if (aux.getName().equals(name)) + { + apiNode = aux; + break; + } + } + return apiNode; + } +} \ No newline at end of file Copied: api/trunk/src/main/java/org/jboss/bpm/def/StartNode.java (from rev 1488, api/trunk/src/main/java/org/jboss/bpm/client/StartNode.java) =================================================================== --- api/trunk/src/main/java/org/jboss/bpm/def/StartNode.java (rev 0) +++ api/trunk/src/main/java/org/jboss/bpm/def/StartNode.java 2008-07-03 13:27:44 UTC (rev 1494) @@ -0,0 +1,39 @@ +/* + * 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.def; + + +// $Id$ + +/** + * Represents the root node in the process definition. + * + * @author tho...@jb... + * @since 18-Jun-2008 + */ +public abstract class StartNode extends Node +{ + protected StartNode(ProcessDefinition pdef) + { + super(pdef); + } +} \ No newline at end of file Added: api/trunk/src/main/java/org/jboss/bpm/runtime/Activity.java =================================================================== --- api/trunk/src/main/java/org/jboss/bpm/runtime/Activity.java (rev 0) +++ api/trunk/src/main/java/org/jboss/bpm/runtime/Activity.java 2008-07-03 13:27:44 UTC (rev 1494) @@ -0,0 +1,46 @@ +/* + * 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.runtime; + +//$Id$ + +import org.jboss.bpm.Context; +import org.jboss.bpm.def.Node; + +/** + * An Activity is associated with a node to execute arbitrary business logic. + * + * It does not effect the execution of the process graph. Instead it reads/writes + * values from/to the execution context and leaves it to the Engine + * to proceed to the next node. + * + * @author Tho...@jb... + * @since 03-Jul-2008 + */ +public interface Activity +{ + /** + * Execute business logic associated with a Node + * @param ctx The execution context + */ + void execute(Node node, Context ctx); +} \ No newline at end of file Property changes on: api/trunk/src/main/java/org/jboss/bpm/runtime/Activity.java ___________________________________________________________________ Name: svn:keywords + Id Revision Name: svn:eol-style + LF Added: api/trunk/src/main/java/org/jboss/bpm/runtime/RuntimeExecution.java =================================================================== --- api/trunk/src/main/java/org/jboss/bpm/runtime/RuntimeExecution.java (rev 0) +++ api/trunk/src/main/java/org/jboss/bpm/runtime/RuntimeExecution.java 2008-07-03 13:27:44 UTC (rev 1494) @@ -0,0 +1,52 @@ +/* + * 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.runtime; + +//$Id:$ + +import org.jboss.bpm.client.Execution; + +/** + * Represents a runtime execution in the process definition. A runtime node gives access to its leaving transitions. + * + * @author tho...@jb... + * @since 03-Jul-2008 + */ +public abstract class RuntimeExecution extends Execution +{ + // Contruct the runtime execution for a copy + protected RuntimeExecution(Execution ex) + { + super(ex); + } + + /** + * Signal this execution with a names transition + */ + public final void signal(String name) + { + signalOverride(name); + } + + // Override to implement execution signalling + protected abstract void signalOverride(String name); +} \ No newline at end of file Property changes on: api/trunk/src/main/java/org/jboss/bpm/runtime/RuntimeExecution.java ___________________________________________________________________ Name: svn:keywords + Id Revision Name: svn:eol-style + LF Added: api/trunk/src/main/java/org/jboss/bpm/runtime/RuntimeNode.java =================================================================== --- api/trunk/src/main/java/org/jboss/bpm/runtime/RuntimeNode.java (rev 0) +++ api/trunk/src/main/java/org/jboss/bpm/runtime/RuntimeNode.java 2008-07-03 13:27:44 UTC (rev 1494) @@ -0,0 +1,59 @@ +/* + * 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.runtime; + +//$Id:$ + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.jboss.bpm.def.Node; + +/** + * Represents a runtime node in the process definition. + * + * A runtime node gives access to its leaving transitions. + * + * @author tho...@jb... + * @since 03-Jul-2008 + */ +public abstract class RuntimeNode extends Node +{ + private List<Transition> leavingTransitions = new ArrayList<Transition>(); + + // Contruct the runtime node for a copy + protected RuntimeNode(Node node) + { + super(node); + } + + /** + * Get the unmodifieable list of leaving transitions + * @return an empty list if there are none + */ + public List<Transition> getLeavingTransitions() + { + return Collections.unmodifiableList(leavingTransitions); + } + +} \ No newline at end of file Property changes on: api/trunk/src/main/java/org/jboss/bpm/runtime/RuntimeNode.java ___________________________________________________________________ Name: svn:keywords + Id Revision Name: svn:eol-style + LF Added: api/trunk/src/main/java/org/jboss/bpm/runtime/Transition.java =================================================================== --- api/trunk/src/main/java/org/jboss/bpm/runtime/Transition.java (rev 0) +++ api/trunk/src/main/java/org/jboss/bpm/runtime/Transition.java 2008-07-03 13:27:44 UTC (rev 1494) @@ -0,0 +1,38 @@ +/* + * 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.runtime; + +//$Id$ + +/** + * Represents the named connection between two nodes + * + * @author Tho...@jb... + * @since 03-Jul-2008 + */ +public abstract class Transition +{ + /** + * Get the name for this transition + */ + public abstract String getName(); +} \ No newline at end of file Property changes on: api/trunk/src/main/java/org/jboss/bpm/runtime/Transition.java ___________________________________________________________________ Name: svn:keywords + Id Revision Name: svn:eol-style + LF Added: api/trunk/src/main/java/org/jboss/bpm/runtime/TransitionRouter.java =================================================================== --- api/trunk/src/main/java/org/jboss/bpm/runtime/TransitionRouter.java (rev 0) +++ api/trunk/src/main/java/org/jboss/bpm/runtime/TransitionRouter.java 2008-07-03 13:27:44 UTC (rev 1494) @@ -0,0 +1,37 @@ +/* + * 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.runtime; + +// $Id$ + +import org.jboss.bpm.client.Execution; + +/** + * A TransitionRouter is responsible for moving + * + * @author Tho...@jb... + * @since 03-Jul-2008 + */ +public interface TransitionRouter +{ + void choosePath(RuntimeNode node, RuntimeExecution ex); +} \ No newline at end of file Property changes on: api/trunk/src/main/java/org/jboss/bpm/runtime/TransitionRouter.java ___________________________________________________________________ Name: svn:keywords + Id Revision Name: svn:eol-style + LF Modified: api/trunk/src/test/java/org/jboss/bpm/client/MockProcessEngine.java =================================================================== --- api/trunk/src/test/java/org/jboss/bpm/client/MockProcessEngine.java 2008-07-03 13:27:22 UTC (rev 1493) +++ api/trunk/src/test/java/org/jboss/bpm/client/MockProcessEngine.java 2008-07-03 13:27:44 UTC (rev 1494) @@ -41,10 +41,10 @@ } public void setProcessInstanceManager(ProcessInstanceFactory processInstanceManager) { - this.processInstanceManager = processInstanceManager; + this.processInstanceFactory = processInstanceManager; } public void setExecutionManager(ExecutionFactory executionManager) { - this.executionManager = executionManager; + this.executionFactor... [truncated message content] |
From: <do-...@jb...> - 2008-07-03 13:27:24
|
Author: tho...@jb... Date: 2008-07-03 09:27:22 -0400 (Thu, 03 Jul 2008) New Revision: 1493 Added: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/ jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ExecutionImpl.java jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ExecutionManagerImpl.java jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/NodeImpl.java jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ProcessDefinitionManagerImpl.java jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ProcessEngineImpl.java jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ProcessInstanceImpl.java jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ProcessInstanceManagerImpl.java jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/runtime/ jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/runtime/ActivityWrapper.java jbpm3/trunk/modules/jpdl/core/src/main/resources/jbpm-beans.xml Removed: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/EndNodeImpl.java jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ExecutionImpl.java jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ExecutionManagerImpl.java jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/NodeImpl.java jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ProcessDefinitionAdapter.java jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ProcessDefinitionImpl.java jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ProcessDefinitionManagerImpl.java jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ProcessEngineImpl.java jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ProcessInstanceImpl.java jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ProcessInstanceManagerImpl.java jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/StartNodeImpl.java jbpm3/trunk/modules/jpdl/integration/src/main/ Modified: jbpm3/trunk/.classpath jbpm3/trunk/modules/jpdl/core/pom.xml jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/graph/def/Action.java jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/graph/def/GraphElement.java jbpm3/trunk/pom.xml Log: Update API to introduce Activity Modified: jbpm3/trunk/.classpath =================================================================== --- jbpm3/trunk/.classpath 2008-07-03 11:35:51 UTC (rev 1492) +++ jbpm3/trunk/.classpath 2008-07-03 13:27:22 UTC (rev 1493) @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="modules/jpdl/core/src/main/java"/> + <classpathentry kind="src" path="modules/jpdl/integration/src/test/java"/> <classpathentry kind="src" path="modules/jpdl/integration/src/main/java"/> <classpathentry kind="src" path="modules/jpdl/core/src/test/java"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> Modified: jbpm3/trunk/modules/jpdl/core/pom.xml =================================================================== --- jbpm3/trunk/modules/jpdl/core/pom.xml 2008-07-03 11:35:51 UTC (rev 1492) +++ jbpm3/trunk/modules/jpdl/core/pom.xml 2008-07-03 13:27:22 UTC (rev 1493) @@ -30,11 +30,10 @@ <!-- Dependencies --> <dependencies> <!-- jBPM Dependencies --> - <!-- dependency> + <dependency> <groupId>org.jboss.jbpm</groupId> <artifactId>jbpm-api</artifactId> - <version>${version}</version> - </dependency--> + </dependency> <!-- Compile Dependencies --> <dependency> Modified: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/graph/def/Action.java =================================================================== --- jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/graph/def/Action.java 2008-07-03 11:35:51 UTC (rev 1492) +++ jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/graph/def/Action.java 2008-07-03 13:27:22 UTC (rev 1493) @@ -25,112 +25,155 @@ import java.util.Map; import org.dom4j.Element; +import org.jboss.bpm.runtime.Activity; import org.jbpm.graph.exe.ExecutionContext; import org.jbpm.instantiation.Delegation; +import org.jbpm.integration.runtime.ActivityWrapper; import org.jbpm.jpdl.el.impl.JbpmExpressionEvaluator; import org.jbpm.jpdl.xml.JpdlXmlReader; import org.jbpm.jpdl.xml.Parsable; import org.jbpm.util.EqualsUtil; -public class Action implements ActionHandler, Parsable, Serializable { +public class Action implements ActionHandler, Parsable, Serializable +{ private static final long serialVersionUID = 1L; - + long id = 0; protected String name = null; protected boolean isPropagationAllowed = true; protected boolean isAsync = false; protected boolean isAsyncExclusive = false; protected Action referencedAction = null; - protected Delegation actionDelegation = null; + protected Delegation actionDelegation = null; protected String actionExpression = null; protected Event event = null; protected ProcessDefinition processDefinition = null; - public Action() { + public Action() + { } - public Action(Delegation actionDelegate) { + public Action(Delegation actionDelegate) + { this.actionDelegation = actionDelegate; } - - public String toString() { + + public String toString() + { String toString = null; - if (name!=null) { - toString = "action["+name+"]"; - } else if (actionExpression!=null) { - toString = "action["+actionExpression+"]"; - } else { - String className = getClass().getName(); - className = className.substring(className.lastIndexOf('.')+1); - if (name!=null) { - toString = className+"("+name+")"; - } else { - toString = className+"("+Integer.toHexString(System.identityHashCode(this))+")"; + if (name != null) + { + toString = "action[" + name + "]"; + } + else if (actionExpression != null) + { + toString = "action[" + actionExpression + "]"; + } + else + { + String className = getClass().getName(); + className = className.substring(className.lastIndexOf('.') + 1); + if (name != null) + { + toString = className + "(" + name + ")"; } + else + { + toString = className + "(" + Integer.toHexString(System.identityHashCode(this)) + ")"; + } } return toString; } - public void read(Element actionElement, JpdlXmlReader jpdlReader) { + public void read(Element actionElement, JpdlXmlReader jpdlReader) + { String expression = actionElement.attributeValue("expression"); - if (expression!=null) { + if (expression != null) + { actionExpression = expression; - } else if (actionElement.attribute("ref-name")!=null) { + } + else if (actionElement.attribute("ref-name") != null) + { jpdlReader.addUnresolvedActionReference(actionElement, this); - } else if (actionElement.attribute("class")!=null) { + } + else if (actionElement.attribute("class") != null) + { actionDelegation = new Delegation(); actionDelegation.read(actionElement, jpdlReader); - - } else { - jpdlReader.addWarning("action does not have class nor ref-name attribute "+actionElement.asXML()); + } + else + { + jpdlReader.addWarning("action does not have class nor ref-name attribute " + actionElement.asXML()); + } String acceptPropagatedEvents = actionElement.attributeValue("accept-propagated-events"); - if ("false".equalsIgnoreCase(acceptPropagatedEvents) - || "no".equalsIgnoreCase(acceptPropagatedEvents) - || "off".equalsIgnoreCase(acceptPropagatedEvents)) { + if ("false".equalsIgnoreCase(acceptPropagatedEvents) || "no".equalsIgnoreCase(acceptPropagatedEvents) || "off".equalsIgnoreCase(acceptPropagatedEvents)) + { isPropagationAllowed = false; } String asyncText = actionElement.attributeValue("async"); - if ("true".equalsIgnoreCase(asyncText)) { + if ("true".equalsIgnoreCase(asyncText)) + { isAsync = true; - } else if ("exclusive".equalsIgnoreCase(asyncText)) { + } + else if ("exclusive".equalsIgnoreCase(asyncText)) + { isAsync = true; isAsyncExclusive = true; } } - public void write(Element actionElement) { - if (actionDelegation!=null) { + public void write(Element actionElement) + { + if (actionDelegation != null) + { actionDelegation.write(actionElement); } } - public void execute(ExecutionContext executionContext) throws Exception { - if (referencedAction!=null) { + public void execute(ExecutionContext executionContext) throws Exception + { + if (referencedAction != null) + { referencedAction.execute(executionContext); - } else if (actionExpression!=null) { + } + else if (actionExpression != null) + { JbpmExpressionEvaluator.evaluate(actionExpression, executionContext); - } else if (actionDelegation!=null) { - ActionHandler actionHandler = (ActionHandler)actionDelegation.getInstance(); + } + else if (actionDelegation != null) + { + ActionHandler actionHandler; + Object obj = actionDelegation.getInstance(); + if (obj instanceof Activity) + { + actionHandler = new ActivityWrapper(this, (Activity)obj); + } + else + { + actionHandler = (ActionHandler)obj; + } actionHandler.execute(executionContext); } } - public void setName(String name) { + public void setName(String name) + { // if the process definition is already set - if (processDefinition!=null) { + if (processDefinition != null) + { // update the process definition action map Map actionMap = processDefinition.getActions(); - // the != string comparison is to avoid null pointer checks. it is no problem if the body is executed a few times too much :-) - if ( (this.name != name) - && (actionMap!=null) ) { + // the != string comparison is to avoid null pointer checks. it is no problem if the body is executed a few times too much :-) + if ((this.name != name) && (actionMap != null)) + { actionMap.remove(this.name); actionMap.put(name, this); } @@ -139,70 +182,104 @@ // then update the name this.name = name; } - + // equals /////////////////////////////////////////////////////////////////// // hack to support comparing hibernate proxies against the real objects // since this always falls back to ==, we don't need to overwrite the hashcode - public boolean equals(Object o) { + public boolean equals(Object o) + { return EqualsUtil.equals(this, o); } - + // getters and setters ////////////////////////////////////////////////////// - public boolean acceptsPropagatedEvents() { + public boolean acceptsPropagatedEvents() + { return isPropagationAllowed; } - public boolean isPropagationAllowed() { + public boolean isPropagationAllowed() + { return isPropagationAllowed; } - public void setPropagationAllowed(boolean isPropagationAllowed) { + + public void setPropagationAllowed(boolean isPropagationAllowed) + { this.isPropagationAllowed = isPropagationAllowed; } - public long getId() { + public long getId() + { return id; } - public String getName() { + + public String getName() + { return name; } - public Event getEvent() { + + public Event getEvent() + { return event; } - public ProcessDefinition getProcessDefinition() { + + public ProcessDefinition getProcessDefinition() + { return processDefinition; } - public void setProcessDefinition(ProcessDefinition processDefinition) { + + public void setProcessDefinition(ProcessDefinition processDefinition) + { this.processDefinition = processDefinition; } - public Delegation getActionDelegation() { + + public Delegation getActionDelegation() + { return actionDelegation; } - public void setActionDelegation(Delegation instantiatableDelegate) { + + public void setActionDelegation(Delegation instantiatableDelegate) + { this.actionDelegation = instantiatableDelegate; } - public Action getReferencedAction() { + + public Action getReferencedAction() + { return referencedAction; } - public void setReferencedAction(Action referencedAction) { + + public void setReferencedAction(Action referencedAction) + { this.referencedAction = referencedAction; } - public boolean isAsync() { + + public boolean isAsync() + { return isAsync; } - public boolean isAsyncExclusive() { + + public boolean isAsyncExclusive() + { return isAsyncExclusive; } - public String getActionExpression() { + + public String getActionExpression() + { return actionExpression; } - public void setActionExpression(String actionExpression) { + + public void setActionExpression(String actionExpression) + { this.actionExpression = actionExpression; } - public void setEvent(Event event) { + + public void setEvent(Event event) + { this.event = event; } - public void setAsync(boolean isAsync) { + + public void setAsync(boolean isAsync) + { this.isAsync = isAsync; } } Modified: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/graph/def/GraphElement.java =================================================================== --- jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/graph/def/GraphElement.java 2008-07-03 11:35:51 UTC (rev 1492) +++ jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/graph/def/GraphElement.java 2008-07-03 13:27:22 UTC (rev 1493) @@ -42,8 +42,9 @@ import org.jbpm.svc.Services; import org.jbpm.util.EqualsUtil; -public abstract class GraphElement implements Serializable { - +public abstract class GraphElement implements Serializable +{ + private static final long serialVersionUID = 1L; long id = 0; @@ -53,67 +54,81 @@ protected Map events = null; protected List exceptionHandlers = null; - public GraphElement() { + public GraphElement() + { } - - public GraphElement( String name ) { - setName( name ); + + public GraphElement(String name) + { + setName(name); } // events /////////////////////////////////////////////////////////////////// /** - * indicative set of event types supported by this graph element. - * this is currently only used by the process designer to know which - * event types to show on a given graph element. in process definitions - * and at runtime, there are no contstraints on the event-types. + * indicative set of event types supported by this graph element. this is currently only used by the process designer to know which event types to show on a given + * graph element. in process definitions and at runtime, there are no contstraints on the event-types. */ public abstract String[] getSupportedEventTypes(); /** * gets the events, keyd by eventType (java.lang.String). */ - public Map getEvents() { + public Map getEvents() + { return events; } - public boolean hasEvents() { - return ( (events!=null) - && (events.size()>0) ); + public boolean hasEvents() + { + return ((events != null) && (events.size() > 0)); } - public Event getEvent(String eventType) { + public Event getEvent(String eventType) + { Event event = null; - if (events!=null) { - event = (Event) events.get(eventType); + if (events != null) + { + event = (Event)events.get(eventType); } return event; } - - public boolean hasEvent(String eventType) { + + public boolean hasEvent(String eventType) + { boolean hasEvent = false; - if (events!=null) { + if (events != null) + { hasEvent = events.containsKey(eventType); } return hasEvent; } - - public Event addEvent(Event event) { - if (event == null) throw new IllegalArgumentException("can't add a null event to a graph element"); - if (event.getEventType() == null) throw new IllegalArgumentException("can't add an event without an eventType to a graph element"); - if (events == null) events = new HashMap(); + + public Event addEvent(Event event) + { + if (event == null) + throw new IllegalArgumentException("can't add a null event to a graph element"); + if (event.getEventType() == null) + throw new IllegalArgumentException("can't add an event without an eventType to a graph element"); + if (events == null) + events = new HashMap(); events.put(event.getEventType(), event); event.graphElement = this; return event; } - - public Event removeEvent(Event event) { + + public Event removeEvent(Event event) + { Event removedEvent = null; - if (event == null) throw new IllegalArgumentException("can't remove a null event from a graph element"); - if (event.getEventType() == null) throw new IllegalArgumentException("can't remove an event without an eventType from a graph element"); - if (events != null) { - removedEvent = (Event) events.remove(event.getEventType()); - if (removedEvent!=null) { + if (event == null) + throw new IllegalArgumentException("can't remove a null event from a graph element"); + if (event.getEventType() == null) + throw new IllegalArgumentException("can't remove an event without an eventType from a graph element"); + if (events != null) + { + removedEvent = (Event)events.remove(event.getEventType()); + if (removedEvent != null) + { event.graphElement = null; } } @@ -125,101 +140,125 @@ /** * is the list of exception handlers associated to this graph element. */ - public List getExceptionHandlers() { + public List getExceptionHandlers() + { return exceptionHandlers; } - - public ExceptionHandler addExceptionHandler(ExceptionHandler exceptionHandler) { - if (exceptionHandler == null) throw new IllegalArgumentException("can't add a null exceptionHandler to a graph element"); - if (exceptionHandlers == null) exceptionHandlers = new ArrayList(); + + public ExceptionHandler addExceptionHandler(ExceptionHandler exceptionHandler) + { + if (exceptionHandler == null) + throw new IllegalArgumentException("can't add a null exceptionHandler to a graph element"); + if (exceptionHandlers == null) + exceptionHandlers = new ArrayList(); exceptionHandlers.add(exceptionHandler); exceptionHandler.graphElement = this; return exceptionHandler; } - - public void removeExceptionHandler(ExceptionHandler exceptionHandler) { - if (exceptionHandler == null) throw new IllegalArgumentException("can't remove a null exceptionHandler from an graph element"); - if (exceptionHandlers != null) { - if (exceptionHandlers.remove(exceptionHandler)) { + + public void removeExceptionHandler(ExceptionHandler exceptionHandler) + { + if (exceptionHandler == null) + throw new IllegalArgumentException("can't remove a null exceptionHandler from an graph element"); + if (exceptionHandlers != null) + { + if (exceptionHandlers.remove(exceptionHandler)) + { exceptionHandler.graphElement = null; } } } - public void reorderExceptionHandler(int oldIndex, int newIndex) { - if ( (exceptionHandlers!=null) - && (Math.min(oldIndex, newIndex)>=0) - && (Math.max(oldIndex, newIndex)<exceptionHandlers.size()) ) { + public void reorderExceptionHandler(int oldIndex, int newIndex) + { + if ((exceptionHandlers != null) && (Math.min(oldIndex, newIndex) >= 0) && (Math.max(oldIndex, newIndex) < exceptionHandlers.size())) + { Object o = exceptionHandlers.remove(oldIndex); exceptionHandlers.add(newIndex, o); - } else { - throw new IndexOutOfBoundsException("couldn't reorder element from index '"+oldIndex+"' to index '"+newIndex+"' in exceptionHandler-list '"+exceptionHandlers+"'"); } + else + { + throw new IndexOutOfBoundsException("couldn't reorder element from index '" + oldIndex + "' to index '" + newIndex + "' in exceptionHandler-list '" + + exceptionHandlers + "'"); + } } // event handling /////////////////////////////////////////////////////////// - public void fireEvent(String eventType, ExecutionContext executionContext) { + public void fireEvent(String eventType, ExecutionContext executionContext) + { Token token = executionContext.getToken(); - log.debug( "event '"+eventType+"' on '"+this+"' for '"+token+"'" ); + log.debug("event '" + eventType + "' on '" + this + "' for '" + token + "'"); - try { + try + { executionContext.setEventSource(this); fireAndPropagateEvent(eventType, executionContext); - } finally { + } + finally + { executionContext.setEventSource(null); } } - public void fireAndPropagateEvent(String eventType, ExecutionContext executionContext) { + public void fireAndPropagateEvent(String eventType, ExecutionContext executionContext) + { // calculate if the event was fired on this element or if it was a propagated event boolean isPropagated = !(this.equals(executionContext.getEventSource())); - - // execute static actions + + // execute static actions Event event = getEvent(eventType); - if (event!=null) { + if (event != null) + { // update the context executionContext.setEvent(event); // execute the static actions specified in the process definition executeActions(event.getActions(), executionContext, isPropagated); } - + // execute the runtime actions List runtimeActions = getRuntimeActionsForEvent(executionContext, eventType); executeActions(runtimeActions, executionContext, isPropagated); // remove the event from the context executionContext.setEvent(null); - + // propagate the event to the parent element GraphElement parent = getParent(); - if (parent!=null) { + if (parent != null) + { parent.fireAndPropagateEvent(eventType, executionContext); } } - void executeActions(List actions, ExecutionContext executionContext, boolean isPropagated) { - if (actions!=null) { + void executeActions(List actions, ExecutionContext executionContext, boolean isPropagated) + { + if (actions != null) + { Iterator iter = actions.iterator(); - while (iter.hasNext()) { - Action action = (Action) iter.next(); - if ( action.acceptsPropagatedEvents() - || (!isPropagated) - ) { - if (action.isAsync()) { + while (iter.hasNext()) + { + Action action = (Action)iter.next(); + if (action.acceptsPropagatedEvents() || (!isPropagated)) + { + if (action.isAsync()) + { ExecuteActionJob job = createAsyncActionExecutionJob(executionContext.getToken(), action); - MessageService messageService = (MessageService) Services.getCurrentService(Services.SERVICENAME_MESSAGE); + MessageService messageService = (MessageService)Services.getCurrentService(Services.SERVICENAME_MESSAGE); messageService.send(job); - } else { + } + else + { executeAction(action, executionContext); } } } } } - - protected ExecuteActionJob createAsyncActionExecutionJob(Token token, Action action) { + + protected ExecuteActionJob createAsyncActionExecutionJob(Token token, Action action) + { ExecuteActionJob job = new ExecuteActionJob(token); job.setAction(action); job.setDueDate(new Date()); @@ -227,73 +266,89 @@ return job; } - public void executeAction(Action action, ExecutionContext executionContext) { + public void executeAction(Action action, ExecutionContext executionContext) + { Token token = executionContext.getToken(); // create action log ActionLog actionLog = new ActionLog(action); token.startCompositeLog(actionLog); - // if this is an action being executed in an event, - // the token needs to be locked. if this is an action - // being executed as the node behaviour or if the token + // if this is an action being executed in an event, + // the token needs to be locked. if this is an action + // being executed as the node behaviour or if the token // is already locked, the token doesn't need to be locked. - boolean actionMustBeLocked = (executionContext.getEvent()!=null) - && (!token.isLocked()); + boolean actionMustBeLocked = (executionContext.getEvent() != null) && (!token.isLocked()); - try { + try + { // update the execution context executionContext.setAction(action); // execute the action - log.debug("executing action '"+action+"'"); - String lockOwnerId = "token["+token.getId()+"]"; - try { - if (actionMustBeLocked) { + log.debug("executing action '" + action + "'"); + String lockOwnerId = "token[" + token.getId() + "]"; + try + { + if (actionMustBeLocked) + { token.lock(lockOwnerId); } - - if (UserCodeInterceptorConfig.userCodeInterceptor!=null) { + + if (UserCodeInterceptorConfig.userCodeInterceptor != null) + { UserCodeInterceptorConfig.userCodeInterceptor.executeAction(action, executionContext); - } else { + } + else + { action.execute(executionContext); } - } finally { - if (actionMustBeLocked) { + } + finally + { + if (actionMustBeLocked) + { token.unlock(lockOwnerId); } } - - } catch (Exception exception) { + + } + catch (Exception exception) + { // NOTE that Error's are not caught because that might halt the JVM and mask the original Error. - log.error("action threw exception: "+exception.getMessage(), exception); - - // log the action exception + log.error("action threw exception: " + exception.getMessage(), exception); + + // log the action exception actionLog.setException(exception); - + // if an exception handler is available raiseException(exception, executionContext); - - } finally { + + } + finally + { executionContext.setAction(null); token.endCompositeLog(); } } - List getRuntimeActionsForEvent(ExecutionContext executionContext, String eventType) { + List getRuntimeActionsForEvent(ExecutionContext executionContext, String eventType) + { List runtimeActionsForEvent = null; List runtimeActions = executionContext.getProcessInstance().getRuntimeActions(); - if (runtimeActions!=null) { + if (runtimeActions != null) + { Iterator iter = runtimeActions.iterator(); - while (iter.hasNext()) { - RuntimeAction runtimeAction = (RuntimeAction) iter.next(); + while (iter.hasNext()) + { + RuntimeAction runtimeAction = (RuntimeAction)iter.next(); // if the runtime-action action is registered on this element and this eventType - if ( (this.equals(runtimeAction.getGraphElement())) - && (eventType.equals(runtimeAction.getEventType())) - ) { - // ... add its action to the list of runtime actions - if (runtimeActionsForEvent==null) runtimeActionsForEvent = new ArrayList(); + if ((this.equals(runtimeAction.getGraphElement())) && (eventType.equals(runtimeAction.getEventType()))) + { + // ... add its action to the list of runtime actions + if (runtimeActionsForEvent == null) + runtimeActionsForEvent = new ArrayList(); runtimeActionsForEvent.add(runtimeAction.getAction()); } } @@ -301,117 +356,104 @@ return runtimeActionsForEvent; } -/* - // the next instruction merges the actions specified in the process definition with the runtime actions - List actions = event.collectActions(executionContext); - - // loop over all actions of this event - Iterator iter = actions.iterator(); - while (iter.hasNext()) { - Action action = (Action) iter.next(); - executionContext.setAction(action); - - if ( (!isPropagated) - || (action.acceptsPropagatedEvents() ) ) { - - // create action log - ActionLog actionLog = new ActionLog(action); - executionContext.getToken().startCompositeLog(actionLog); - - try { - // execute the action - action.execute(executionContext); - - } catch (Exception exception) { - // NOTE that Error's are not caught because that might halt the JVM and mask the original Error. - Event.log.error("action threw exception: "+exception.getMessage(), exception); - - // log the action exception - actionLog.setException(exception); - - // if an exception handler is available - event.graphElement.raiseException(exception, executionContext); - } finally { - executionContext.getToken().endCompositeLog(); - } - } - } - } -*/ + /* + * // the next instruction merges the actions specified in the process definition with the runtime actions List actions = event.collectActions(executionContext); // + * loop over all actions of this event Iterator iter = actions.iterator(); while (iter.hasNext()) { Action action = (Action) iter.next(); + * executionContext.setAction(action); if ( (!isPropagated) || (action.acceptsPropagatedEvents() ) ) { // create action log ActionLog actionLog = new + * ActionLog(action); executionContext.getToken().startCompositeLog(actionLog); try { // execute the action action.execute(executionContext); } catch (Exception + * exception) { // NOTE that Error's are not caught because that might halt the JVM and mask the original Error. + * Event.log.error("action threw exception: "+exception.getMessage(), exception); // log the action exception actionLog.setException(exception); // if an exception + * handler is available event.graphElement.raiseException(exception, executionContext); } finally { executionContext.getToken().endCompositeLog(); } } } } + */ /** - * throws an ActionException if no applicable exception handler is found. - * An ExceptionHandler is searched for in this graph element and then recursively up the - * parent hierarchy. - * If an exception handler is found, it is applied. If the exception handler does not - * throw an exception, the exception is considered handled. Otherwise the search for - * an applicable exception handler continues where it left of with the newly thrown - * exception. + * throws an ActionException if no applicable exception handler is found. An ExceptionHandler is searched for in this graph element and then recursively up the parent + * hierarchy. If an exception handler is found, it is applied. If the exception handler does not throw an exception, the exception is considered handled. Otherwise + * the search for an applicable exception handler continues where it left of with the newly thrown exception. */ - public void raiseException(Throwable exception, ExecutionContext executionContext) throws DelegationException { + public void raiseException(Throwable exception, ExecutionContext executionContext) throws DelegationException + { boolean isHandled = false; - if (exceptionHandlers!=null) { - try { + if (exceptionHandlers != null) + { + try + { ExceptionHandler exceptionHandler = findExceptionHandler(exception); - if (exceptionHandler!=null) { + if (exceptionHandler != null) + { executionContext.setException(exception); exceptionHandler.handleException(this, executionContext); isHandled = true; } - } catch (Exception e) { + } + catch (Exception e) + { // NOTE that Error's are not caught because that might halt the JVM and mask the original Error. exception = e; } } - if (!isHandled) { + if (!isHandled) + { GraphElement parent = getParent(); // if this graph element has a parent - if ( (parent!=null) - && (parent!=this) ){ + if ((parent != null) && (parent != this)) + { // action to the parent parent.raiseException(exception, executionContext); - } else { + } + else + { // rollback the actions // rollbackActions(executionContext); - + // if there is no parent we need to throw an action exception to the client - if (exception instanceof JbpmException) { - throw (JbpmException) exception; - } else { + if (exception instanceof JbpmException) + { + throw (JbpmException)exception; + } + else + { throw new DelegationException(exception, executionContext); } } } } - protected ExceptionHandler findExceptionHandler(Throwable exception) { + protected ExceptionHandler findExceptionHandler(Throwable exception) + { ExceptionHandler exceptionHandler = null; - - if (exceptionHandlers!=null) { + + if (exceptionHandlers != null) + { Iterator iter = exceptionHandlers.iterator(); - while (iter.hasNext() && (exceptionHandler==null)) { - ExceptionHandler candidate = (ExceptionHandler) iter.next(); - if (candidate.matches(exception)) { + while (iter.hasNext() && (exceptionHandler == null)) + { + ExceptionHandler candidate = (ExceptionHandler)iter.next(); + if (candidate.matches(exception)) + { exceptionHandler = candidate; } } } - + return exceptionHandler; } - public GraphElement getParent() { + public GraphElement getParent() + { return processDefinition; } /** * @return all the parents of this graph element ordered by age. */ - public List getParents() { + public List getParents() + { List parents = new ArrayList(); - GraphElement parent = getParent(); - if (parent!=null) { + GraphElement parent = getParent(); + if (parent != null) + { parent.addParentChain(parents); } return parents; @@ -420,62 +462,83 @@ /** * @return this graph element plus all the parents ordered by age. */ - public List getParentChain() { + public List getParentChain() + { List parents = new ArrayList(); this.addParentChain(parents); return parents; } - void addParentChain(List parentChain) { + void addParentChain(List parentChain) + { parentChain.add(this); GraphElement parent = getParent(); - if (parent!=null) { + if (parent != null) + { parent.addParentChain(parentChain); } } - - public String toString() { - String className = getClass().getName(); - className = className.substring(className.lastIndexOf('.')+1); - if (name!=null) { - className = className+"("+name+")"; - } else { - className = className+"("+Integer.toHexString(System.identityHashCode(this))+")"; + + public String toString() + { + String className = getClass().getName(); + className = className.substring(className.lastIndexOf('.') + 1); + if (name != null) + { + className = className + "(" + name + ")"; } + else + { + className = className + "(" + Integer.toHexString(System.identityHashCode(this)) + ")"; + } return className; } // equals /////////////////////////////////////////////////////////////////// // hack to support comparing hibernate proxies against the real objects // since this always falls back to ==, we don't need to overwrite the hashcode - public boolean equals(Object o) { + public boolean equals(Object o) + { return EqualsUtil.equals(this, o); } - + // getters and setters ////////////////////////////////////////////////////// - - public long getId() { + + public long getId() + { return id; } - public String getName() { + + public String getName() + { return name; } - public void setName( String name ) { + + public void setName(String name) + { this.name = name; } - public String getDescription() { + + public String getDescription() + { return description; } - public void setDescription(String description) { + + public void setDescription(String description) + { this.description = description; } - public ProcessDefinition getProcessDefinition() { + + public ProcessDefinition getProcessDefinition() + { return processDefinition; } - public void setProcessDefinition(ProcessDefinition processDefinition) { + + public void setProcessDefinition(ProcessDefinition processDefinition) + { this.processDefinition = processDefinition; } - + // logger /////////////////////////////////////////////////////////////////// private static final Log log = LogFactory.getLog(GraphElement.class); } Copied: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client (from rev 1487, jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client) Deleted: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/EndNodeImpl.java =================================================================== --- jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/EndNodeImpl.java 2008-07-03 10:03:39 UTC (rev 1487) +++ jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/EndNodeImpl.java 2008-07-03 13:27:22 UTC (rev 1493) @@ -1,57 +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.jbpm.integration.client; - -// $Id$ - -import org.jbpm.api.client.EndNode; -import org.jbpm.api.client.ProcessDefinition; - -/** - * TODO - * - * @author tho...@jb... - * @since 18-Jun-2008 - */ -public class EndNodeImpl extends EndNode -{ - private org.jbpm.graph.def.Node oldNode; - - EndNodeImpl(ProcessDefinition def, org.jbpm.graph.def.Node oldNode) - { - super(def); - this.oldNode = oldNode; - init(oldNode.getName()); - } - - @Override - public String getName() - { - return oldNode.getName(); - } - - @Override - protected void setName(String name) - { - oldNode.setName(name); - } -} Deleted: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ExecutionImpl.java =================================================================== --- jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ExecutionImpl.java 2008-07-03 10:03:39 UTC (rev 1487) +++ jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ExecutionImpl.java 2008-07-03 13:27:22 UTC (rev 1493) @@ -1,75 +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.jbpm.integration.client; - -//$Id$ - -import org.jbpm.api.client.Execution; -import org.jbpm.api.client.Node; -import org.jbpm.api.client.ProcessInstance; - -/** - * TODO - * - * @author tho...@jb... - * @since 18-Jun-2008 - */ -public class ExecutionImpl extends Execution -{ - - org.jbpm.graph.exe.Execution oldEx; - private ProcessInstance pinst; - - ExecutionImpl(ProcessInstance pi, org.jbpm.graph.exe.Execution oldEx) - { - super(pi); - this.pinst = pi; - this.oldEx = oldEx; - init(oldEx.getKey()); - } - - @Override - protected Node getNodeOverride() - { - org.jbpm.graph.def.Node oldNode = oldEx.getRootToken().getNode(); - Node apiNode = pinst.getProcessDefinition().findNode(oldNode.getName()); - return apiNode; - } - - @Override - protected void signalOverride() - { - oldEx.signal(); - } - - @Override - public String getName() - { - return oldEx.getKey(); - } - - @Override - protected void setName(String name) - { - oldEx.setKey(name); - } -} Copied: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ExecutionImpl.java (from rev 1492, jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ExecutionImpl.java) =================================================================== --- jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ExecutionImpl.java (rev 0) +++ jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ExecutionImpl.java 2008-07-03 13:27:22 UTC (rev 1493) @@ -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.jbpm.integration.client; + +//$Id$ + +import org.jboss.bpm.client.Execution; +import org.jboss.bpm.client.ProcessInstance; +import org.jboss.bpm.def.Node; + +/** + * TODO + * + * @author tho...@jb... + * @since 18-Jun-2008 + */ +public class ExecutionImpl extends Execution +{ + org.jbpm.graph.exe.Execution oldEx; + + ExecutionImpl(ProcessInstance pi, org.jbpm.graph.exe.Execution oldEx) + { + super(pi); + this.oldEx = oldEx; + init(oldEx.getKey()); + } + + @Override + protected Node getNodeOverride() + { + org.jbpm.graph.def.Node oldNode = oldEx.getRootToken().getNode(); + Node apiNode = getProcessInstance().getProcessDefinition().findNode(oldNode.getName()); + return apiNode; + } + + @Override + protected void signalOverride() + { + oldEx.getContextInstance().setTransientVariable(Execution.class.getName(), this); + oldEx.signal(); + } + + @Override + public String getName() + { + return oldEx.getKey(); + } + + @Override + protected void setName(String name) + { + oldEx.setKey(name); + } +} Deleted: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ExecutionManagerImpl.java =================================================================== --- jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ExecutionManagerImpl.java 2008-07-03 10:03:39 UTC (rev 1487) +++ jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ExecutionManagerImpl.java 2008-07-03 13:27:22 UTC (rev 1493) @@ -1,53 +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.jbpm.integration.client; - -// $Id$ - -import org.jbpm.api.client.Execution; -import org.jbpm.api.client.ExecutionFactory; -import org.jbpm.api.client.ProcessEngine; -import org.jbpm.api.client.ProcessInstance; - -/** - * TODO - * - * @author tho...@jb... - * @since 18-Jun-2008 - */ -public class ExecutionManagerImpl extends ExecutionFactory -{ - - public void setProcessEngine(ProcessEngine engine) - { - this.engine = engine; - } - - @Override - protected Execution createExecutionOverride(ProcessInstance pi) - { - ProcessDefinitionImpl apiPD = (ProcessDefinitionImpl)pi.getProcessDefinition(); - org.jbpm.graph.exe.Execution oldEx = new org.jbpm.graph.exe.Execution(apiPD.oldPD); - ExecutionImpl ex = new ExecutionImpl(pi, oldEx); - return ex; - } -} Copied: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ExecutionManagerImpl.java (from rev 1492, jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ExecutionManagerImpl.java) =================================================================== --- jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ExecutionManagerImpl.java (rev 0) +++ jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ExecutionManagerImpl.java 2008-07-03 13:27:22 UTC (rev 1493) @@ -0,0 +1,53 @@ +/* + * 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.integration.client; + +// $Id$ + +import org.jboss.bpm.client.Execution; +import org.jboss.bpm.client.ExecutionFactory; +import org.jboss.bpm.client.ProcessEngine; +import org.jboss.bpm.client.ProcessInstance; + +/** + * TODO + * + * @author tho...@jb... + * @since 18-Jun-2008 + */ +public class ExecutionManagerImpl extends ExecutionFactory +{ + + public void setProcessEngine(ProcessEngine engine) + { + this.engine = engine; + } + + @Override + protected Execution createExecutionOverride(ProcessInstance pi) + { + ProcessDefinitionImpl apiPD = (ProcessDefinitionImpl)pi.getProcessDefinition(); + org.jbpm.graph.exe.Execution oldEx = new org.jbpm.graph.exe.Execution(apiPD.oldPD); + ExecutionImpl ex = new ExecutionImpl(pi, oldEx); + return ex; + } +} Deleted: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/NodeImpl.java =================================================================== --- jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/NodeImpl.java 2008-07-03 10:03:39 UTC (rev 1487) +++ jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/NodeImpl.java 2008-07-03 13:27:22 UTC (rev 1493) @@ -1,57 +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.jbpm.integration.client; - -//$Id$ - -import org.jbpm.api.client.Node; -import org.jbpm.api.client.ProcessDefinition; - -/** - * TODO - * - * @author tho...@jb... - * @since 18-Jun-2008 - */ -public class NodeImpl extends Node -{ - private org.jbpm.graph.def.Node oldNode; - - NodeImpl(ProcessDefinition def, org.jbpm.graph.def.Node oldNode) - { - super(def); - this.oldNode = oldNode; - init(oldNode.getName()); - } - - @Override - public String getName() - { - return oldNode.getName(); - } - - @Override - protected void setName(String name) - { - oldNode.setName(name); - } -} Copied: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/NodeImpl.java (from rev 1492, jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/NodeImpl.java) =================================================================== --- jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/NodeImpl.java (rev 0) +++ jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/NodeImpl.java 2008-07-03 13:27:22 UTC (rev 1493) @@ -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.jbpm.integration.client; + +//$Id$ + +import org.jboss.bpm.def.Node; +import org.jboss.bpm.def.ProcessDefinition; + +/** + * TODO + * + * @author tho...@jb... + * @since 18-Jun-2008 + */ +public class NodeImpl extends Node +{ + private org.jbpm.graph.def.Node oldNode; + + NodeImpl(ProcessDefinition def, org.jbpm.graph.def.Node oldNode) + { + super(def); + this.oldNode = oldNode; + init(oldNode.getName()); + } + + @Override + public String getName() + { + return oldNode.getName(); + } + + @Override + protected void setName(String name) + { + oldNode.setName(name); + } +} Deleted: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ProcessDefinitionAdapter.java =================================================================== --- jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessDefinitionAdapter.java 2008-07-03 10:03:39 UTC (rev 1487) +++ jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ProcessDefinitionAdapter.java 2008-07-03 13:27:22 UTC (rev 1493) @@ -1,86 +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.jbpm.integration.client; - -// $Id$ - -import java.util.List; - -import org.jbpm.api.client.Node; -import org.jbpm.api.client.ProcessDefinition; -import org.jbpm.graph.node.EndState; -import org.jbpm.graph.node.StartState; - -/** - * Adapts on jBPM3 ProcessDefinition to an API ProcessDefinition - * - * @author tho...@jb... - * @since 18-Jun-2008 - */ -class ProcessDefinitionAdapter -{ - - static ProcessDefinition buildProcessDefinition(org.jbpm.graph.def.ProcessDefinition oldPD) - { - ProcessDefinitionImpl apiPD = new ProcessDefinitionImpl(oldPD); - List<org.jbpm.graph.def.Node> oldNodes = oldPD.getNodes(); - for (org.jbpm.graph.def.Node oldNode : oldNodes) - { - Node apiNode = NodeAdapter.adaptNode(apiPD, oldNode); - apiPD.addNode(apiNode); - } - - // validate - validateProcessDefinition(apiPD); - - return apiPD; - } - - private static void validateProcessDefinition(ProcessDefinitionImpl apiPD) - { - // These methods are expected to throw exceptions if there are no such states - apiPD.getStartNode(); - apiPD.getEndNodes(); - } - - static class NodeAdapter - { - - static Node adaptNode(ProcessDefinition pDef, org.jbpm.graph.def.Node oldNode) - { - Node apiNode; - if (oldNode instanceof StartState) - { - apiNode = new StartNodeImpl(pDef, oldNode); - } - else if (oldNode instanceof EndState) - { - apiNode = new EndNodeImpl(pDef, oldNode); - } - else - { - apiNode = new NodeImpl(pDef, oldNode); - } - return apiNode; - } - } -} Deleted: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ProcessDefinitionImpl.java =================================================================== --- jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessDefinitionImpl.java 2008-07-03 10:03:39 UTC (rev 1487) +++ jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ProcessDefinitionImpl.java 2008-07-03 13:27:22 UTC (rev 1493) @@ -1,62 +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.jbpm.integration.client; - -//$Id$ - -import org.jbpm.api.client.Node; -import org.jbpm.api.client.ProcessDefinition; - -/** - * A jBPM3 implementation of a process definition - * - * @author tho...@jb... - * @since 18-Jun-2008 - */ -public class ProcessDefinitionImpl extends ProcessDefinition -{ - org.jbpm.graph.def.ProcessDefinition oldPD; - - ProcessDefinitionImpl(org.jbpm.graph.def.ProcessDefinition oldPD) - { - this.oldPD = oldPD; - init(oldPD.getName()); - } - - // Add a node - public void addNode(Node apiNode) - { - super.addNode(apiNode); - } - - @Override - public String getName() - { - return oldPD.getName(); - } - - @Override - protected void setName(String name) - { - oldPD.setName(name); - } -} Deleted: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ProcessDefinitionManagerImpl.java =================================================================== --- jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessDefinitionManagerImpl.java 2008-07-03 10:03:39 UTC (rev 1487) +++ jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/integration/client/ProcessDefinitionManagerImpl.java 2008-07-03 13:27:22 UTC (rev 1493) @@ -1,82 +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... [truncated message content] |
From: <do-...@jb...> - 2008-07-03 11:35:58
|
Author: ale...@jb... Date: 2008-07-03 07:35:51 -0400 (Thu, 03 Jul 2008) New Revision: 1492 Modified: jbpm3/trunk/modules/enterprise/src/main/java/org/jbpm/scheduler/ejbtimer/ExecuteTimerCommand.java Log: made enterprise scheduler service delete executed timer from db: JBPM-1092 Modified: jbpm3/trunk/modules/enterprise/src/main/java/org/jbpm/scheduler/ejbtimer/ExecuteTimerCommand.java =================================================================== --- jbpm3/trunk/modules/enterprise/src/main/java/org/jbpm/scheduler/ejbtimer/ExecuteTimerCommand.java 2008-07-03 11:33:16 UTC (rev 1491) +++ jbpm3/trunk/modules/enterprise/src/main/java/org/jbpm/scheduler/ejbtimer/ExecuteTimerCommand.java 2008-07-03 11:35:51 UTC (rev 1492) @@ -4,25 +4,30 @@ import org.apache.commons.logging.LogFactory; import org.jbpm.JbpmContext; import org.jbpm.command.Command; -import org.jbpm.job.Timer; +import org.jbpm.db.JobSession; +import org.jbpm.job.Job; public class ExecuteTimerCommand implements Command { private static final long serialVersionUID = 1L; - long timerId; + final long timerId; public ExecuteTimerCommand(long timerId) { this.timerId = timerId; } public Object execute(JbpmContext jbpmContext) throws Exception { - Timer timer = (Timer) jbpmContext.getJobSession().getJob(timerId); + JobSession jobSession = jbpmContext.getJobSession(); + Job timer = jobSession.getJob(timerId); if (timer!=null) { log.debug("executing timer "+timerId); - timer.execute(jbpmContext); + if (timer.execute(jbpmContext)) { + log.debug("deleting timer "+timerId); + jobSession.deleteJob(timer); + } } else { - log.info("execution of timer "+timerId+" was skipped cause the timer was deleted from the database"); + log.info("timer "+timerId+" was deleted, cannot execute it"); } return timer; } |
From: <do-...@jb...> - 2008-07-03 11:33:24
|
Author: ale...@jb... Date: 2008-07-03 07:33:16 -0400 (Thu, 03 Jul 2008) New Revision: 1491 Modified: jbpm3/trunk/modules/jpdl/core/src/test/java/org/jbpm/msg/command/AsyncExecutionDbTest.java Log: removed useless output to stderr Modified: jbpm3/trunk/modules/jpdl/core/src/test/java/org/jbpm/msg/command/AsyncExecutionDbTest.java =================================================================== --- jbpm3/trunk/modules/jpdl/core/src/test/java/org/jbpm/msg/command/AsyncExecutionDbTest.java 2008-07-03 11:32:08 UTC (rev 1490) +++ jbpm3/trunk/modules/jpdl/core/src/test/java/org/jbpm/msg/command/AsyncExecutionDbTest.java 2008-07-03 11:33:16 UTC (rev 1491) @@ -105,7 +105,6 @@ private static final long serialVersionUID = 1L; String nbr; public void execute(ExecutionContext executionContext) throws Exception { - System.err.println("################################"); recordedActionNumbers.add(nbr); } } |
From: <do-...@jb...> - 2008-07-03 11:32:11
|
Author: ale...@jb... Date: 2008-07-03 07:32:08 -0400 (Thu, 03 Jul 2008) New Revision: 1490 Modified: jbpm3/trunk/modules/jpdl/core/src/test/java/org/jbpm/job/executor/MultiJobExecutorTest.java Log: added the ability to create more than one job, fixed synchronization issues which caused sporadic failures Modified: jbpm3/trunk/modules/jpdl/core/src/test/java/org/jbpm/job/executor/MultiJobExecutorTest.java =================================================================== --- jbpm3/trunk/modules/jpdl/core/src/test/java/org/jbpm/job/executor/MultiJobExecutorTest.java 2008-07-03 10:10:07 UTC (rev 1489) +++ jbpm3/trunk/modules/jpdl/core/src/test/java/org/jbpm/job/executor/MultiJobExecutorTest.java 2008-07-03 11:32:08 UTC (rev 1490) @@ -8,14 +8,15 @@ import org.apache.commons.logging.LogFactory; import org.jbpm.JbpmConfiguration; import org.jbpm.JbpmContext; +import org.jbpm.command.Command; import org.jbpm.command.CommandService; -import org.jbpm.command.SignalCommand; +import org.jbpm.command.DeployProcessCommand; import org.jbpm.command.StartProcessInstanceCommand; import org.jbpm.command.impl.CommandServiceImpl; +import org.jbpm.configuration.ObjectFactory; import org.jbpm.graph.def.ActionHandler; -import org.jbpm.graph.def.ProcessDefinition; import org.jbpm.graph.exe.ExecutionContext; -import org.jbpm.graph.exe.ProcessInstance; +import org.jbpm.graph.exe.Token; /** * Test case for JBPM-1072. @@ -24,118 +25,145 @@ */ public class MultiJobExecutorTest extends TestCase { - private static final int EXECUTOR_COUNT = 20; - public static final String PROCESS_NAME = "TestProcess"; + private static final int EXECUTOR_COUNT = 16; + private static final int JOB_COUNT = 1; + private static final int IDLE_INTERVAL = 1000; + private static final String PROCESS_NAME = "TestProcess"; - private JobExecutor[] executors = new JobExecutor[EXECUTOR_COUNT]; - private static JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance(); - private static CommandService commandService = new CommandServiceImpl(jbpmConfiguration); + private static CommandService commandService = new CommandRetryService(new CommandServiceImpl(jbpmConfiguration), 3); private static final Log log = LogFactory.getLog(MultiJobExecutorTest.class); - public static final String PROCESS_DEFINITION = "<?xml version='1.0' encoding='UTF-8'?>" - + "<process-definition xmlns='' name='TestProcess'>" + private static final String PROCESS_DEFINITION = "<process-definition name='" + + PROCESS_NAME + + "'>" + "<event type='process-end'>" + "<action name='endAction' class='" + EndAction.class.getName() - + "' />" + + "'/>" + "</event>" - + "<start-state name='start-state1'>" - + "<transition to='Service 1'></transition>" + + "<start-state name='start'>" + + "<transition to='fork'/>" + "</start-state>" - + "<node name='Service 1'>" - + "<action name='esbAction' " - + "class='" - + SimpleAction.class.getName() - + "'>" - + "</action>" - + "<transition to='Service 2'></transition>" + + "<node name='fork'>" + + "<action class='" + + MultiFork.class.getName() + + "'/>" + + "<transition to='async'/>" + "</node>" - + "<node name='Service 2' async='true'>" - + "<action name='esbAction' " - + "class='" - + SimpleAction2.class.getName() - + "'>" - + "</action>" - + "<transition to='end-state1'></transition>" + + "<node name='async' async='true'>" + + "<action class='" + + AsyncAction.class.getName() + + "'/>" + + "<transition to='join'/>" + "</node>" - + "<end-state name='end-state1'></end-state>" + + "<join name='join'>" + + "<transition to='end'/>" + + "</join>" + + "<end-state name='end'/>" + "</process-definition>"; protected void setUp() throws SQLException { jbpmConfiguration.createSchema(); + commandService.execute(new DeployProcessCommand(PROCESS_DEFINITION)); + } - // deploy process definition + public void testMultipleExecutors() { + // create job executors + JobExecutor[] jobExecutors = new JobExecutor[EXECUTOR_COUNT]; + // jobExecutors[0] = jbpmConfiguration.getJobExecutor(); + JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext(); try { - jbpmContext.deployProcessDefinition(ProcessDefinition.parseXmlString(PROCESS_DEFINITION)); - log.info("Isolation " + jbpmContext.getConnection().getTransactionIsolation()); + ObjectFactory objectFactory = jbpmContext.getObjectFactory(); + for (int i = 0; i < jobExecutors.length; i++) { + JobExecutor jobExecutor = (JobExecutor) objectFactory.createObject("jbpm.job.executor"); + jobExecutor.setName(jobExecutor.getName() + '-' + i); + jobExecutor.setIdleInterval(IDLE_INTERVAL); + jobExecutors[i] = jobExecutor; + } } finally { jbpmContext.close(); } - } - public void testMultipleExecutors() { // start job executors - for (int i = 0; i < executors.length; i++) { - JobExecutor jobExecutor = (JobExecutor) JbpmConfiguration.Configs.getObjectFactory().createObject( - "jbpm.job.executor"); - jobExecutor.setName("JbpmJobExecutor/" + (i + 1)); - jobExecutor.start(); - executors[i] = jobExecutor; + for (int i = 0; i < jobExecutors.length; i++) { + jobExecutors[i].start(); } // kick off process instance StartProcessInstanceCommand startCommand = new StartProcessInstanceCommand(); startCommand.setProcessName(PROCESS_NAME); - ProcessInstance pi = (ProcessInstance) commandService.execute(startCommand); - - // signal service 1 - SignalCommand signalCommand = new SignalCommand(); - signalCommand.setTokenId(pi.getRootToken().getId()); - commandService.execute(signalCommand); - - // wait for process end - EndAction.waitFor(); - + commandService.execute(startCommand); + + // wait till process instance ends + EndAction.waitFor(IDLE_INTERVAL); + // stop job executors - for (int i = executors.length - 1; i >= 0; i--) { + for (int i = jobExecutors.length - 1; i >= 0; i--) { try { - executors[i].stopAndJoin(); + jobExecutors[i].stopAndJoin(); } catch (InterruptedException e) { // continue to next executor } } - - assertEquals(1, SimpleAction2.getCount()); + + assertEquals(JOB_COUNT, AsyncAction.getCount()); } protected void tearDown() { jbpmConfiguration.dropSchema(); } - public static class SimpleAction implements ActionHandler { + static class CommandRetryService implements CommandService { + + private final CommandService commandService; + private final int retryCount; - private static final long serialVersionUID = -9065054081909009083L; + CommandRetryService(CommandService commandService, int retryCount) { + this.commandService = commandService; + this.retryCount = retryCount; + } + public Object execute(Command command) { + for (int i = 1;; i++) { + try { + return commandService.execute(command); + } + catch (RuntimeException e) { + log.error("attempt " + i + " to execute command failed", e); + if (i == retryCount) + throw e; + } + } + } + } + + public static class MultiFork implements ActionHandler { + + private static final long serialVersionUID = 1L; + public void execute(ExecutionContext ctx) throws Exception { - log.info("Action 1"); + Token parentToken = ctx.getToken(); + for (int i = 0; i < JOB_COUNT; i++) { + Token childToken = new Token(parentToken, Integer.toString(i)); + new ExecutionContext(childToken).leaveNode(); + } } - } - public static class SimpleAction2 implements ActionHandler { + public static class AsyncAction implements ActionHandler { private static volatile int count = 0; - private static final long serialVersionUID = -9065054081909009083L; + private static final long serialVersionUID = 1L; - public void execute(ExecutionContext ctx) throws Exception { - log.info("Action 2: " + incrementCount()); - ctx.getNode().leave(ctx); + public void execute(ExecutionContext exeContext) throws Exception { + log.info("execution count: " + incrementCount()); + exeContext.leaveNode(); } private static synchronized int incrementCount() { @@ -149,24 +177,33 @@ public static class EndAction implements ActionHandler { - private static final Object monitor = new Object(); + private static final Object lock = new Object(); + private static volatile boolean ended; private static final long serialVersionUID = 1L; - public void execute(ExecutionContext executionContext) throws Exception { - synchronized (monitor) { - monitor.notify(); + public void execute(ExecutionContext exeContext) throws Exception { + ended = true; + log.debug("process-end event fired, notifying"); + synchronized (lock) { + lock.notify(); } } - public static void waitFor() { - try { - synchronized (monitor) { - monitor.wait(60000); + public static void waitFor(long timeout) { + while (!ended) { + log.debug("process not ended, waiting"); + try { + synchronized (lock) { + lock.wait(timeout); + } } + catch (InterruptedException e) { + // check condition again + } + log.debug("checking whether process has ended"); } - catch (InterruptedException e) { - } + log.debug("process ended, proceeding"); } } } |
From: <do-...@jb...> - 2008-07-03 10:10:09
|
Author: tho...@jb... Date: 2008-07-03 06:10:07 -0400 (Thu, 03 Jul 2008) New Revision: 1489 Modified: jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/EndNodeImpl.java jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ExecutionImpl.java jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ExecutionManagerImpl.java jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/NodeImpl.java jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessDefinitionAdapter.java jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessDefinitionImpl.java jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessDefinitionManagerImpl.java jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessEngineImpl.java jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessInstanceImpl.java jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessInstanceManagerImpl.java jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/StartNodeImpl.java Log: Move API to org.jboss.bpm Modified: jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/EndNodeImpl.java =================================================================== --- jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/EndNodeImpl.java 2008-07-03 10:09:55 UTC (rev 1488) +++ jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/EndNodeImpl.java 2008-07-03 10:10:07 UTC (rev 1489) @@ -23,8 +23,8 @@ // $Id$ -import org.jbpm.api.client.EndNode; -import org.jbpm.api.client.ProcessDefinition; +import org.jboss.bpm.client.EndNode; +import org.jboss.bpm.client.ProcessDefinition; /** * TODO Modified: jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ExecutionImpl.java =================================================================== --- jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ExecutionImpl.java 2008-07-03 10:09:55 UTC (rev 1488) +++ jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ExecutionImpl.java 2008-07-03 10:10:07 UTC (rev 1489) @@ -23,9 +23,9 @@ //$Id$ -import org.jbpm.api.client.Execution; -import org.jbpm.api.client.Node; -import org.jbpm.api.client.ProcessInstance; +import org.jboss.bpm.client.Execution; +import org.jboss.bpm.client.Node; +import org.jboss.bpm.client.ProcessInstance; /** * TODO Modified: jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ExecutionManagerImpl.java =================================================================== --- jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ExecutionManagerImpl.java 2008-07-03 10:09:55 UTC (rev 1488) +++ jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ExecutionManagerImpl.java 2008-07-03 10:10:07 UTC (rev 1489) @@ -23,10 +23,10 @@ // $Id$ -import org.jbpm.api.client.Execution; -import org.jbpm.api.client.ExecutionFactory; -import org.jbpm.api.client.ProcessEngine; -import org.jbpm.api.client.ProcessInstance; +import org.jboss.bpm.client.Execution; +import org.jboss.bpm.client.ExecutionFactory; +import org.jboss.bpm.client.ProcessEngine; +import org.jboss.bpm.client.ProcessInstance; /** * TODO Modified: jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/NodeImpl.java =================================================================== --- jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/NodeImpl.java 2008-07-03 10:09:55 UTC (rev 1488) +++ jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/NodeImpl.java 2008-07-03 10:10:07 UTC (rev 1489) @@ -23,8 +23,8 @@ //$Id$ -import org.jbpm.api.client.Node; -import org.jbpm.api.client.ProcessDefinition; +import org.jboss.bpm.client.Node; +import org.jboss.bpm.client.ProcessDefinition; /** * TODO Modified: jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessDefinitionAdapter.java =================================================================== --- jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessDefinitionAdapter.java 2008-07-03 10:09:55 UTC (rev 1488) +++ jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessDefinitionAdapter.java 2008-07-03 10:10:07 UTC (rev 1489) @@ -25,8 +25,8 @@ import java.util.List; -import org.jbpm.api.client.Node; -import org.jbpm.api.client.ProcessDefinition; +import org.jboss.bpm.client.Node; +import org.jboss.bpm.client.ProcessDefinition; import org.jbpm.graph.node.EndState; import org.jbpm.graph.node.StartState; Modified: jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessDefinitionImpl.java =================================================================== --- jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessDefinitionImpl.java 2008-07-03 10:09:55 UTC (rev 1488) +++ jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessDefinitionImpl.java 2008-07-03 10:10:07 UTC (rev 1489) @@ -23,8 +23,8 @@ //$Id$ -import org.jbpm.api.client.Node; -import org.jbpm.api.client.ProcessDefinition; +import org.jboss.bpm.client.Node; +import org.jboss.bpm.client.ProcessDefinition; /** * A jBPM3 implementation of a process definition Modified: jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessDefinitionManagerImpl.java =================================================================== --- jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessDefinitionManagerImpl.java 2008-07-03 10:09:55 UTC (rev 1488) +++ jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessDefinitionManagerImpl.java 2008-07-03 10:10:07 UTC (rev 1489) @@ -26,10 +26,10 @@ import java.io.IOException; import java.net.URL; -import org.jbpm.api.InvalidProcessDefinitionException; -import org.jbpm.api.client.ProcessDefinition; -import org.jbpm.api.client.ProcessDefinitionManager; -import org.jbpm.api.client.ProcessEngine; +import org.jboss.bpm.InvalidProcessDefinitionException; +import org.jboss.bpm.client.ProcessDefinition; +import org.jboss.bpm.client.ProcessDefinitionManager; +import org.jboss.bpm.client.ProcessEngine; import org.jbpm.jpdl.JpdlException; /** Modified: jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessEngineImpl.java =================================================================== --- jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessEngineImpl.java 2008-07-03 10:09:55 UTC (rev 1488) +++ jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessEngineImpl.java 2008-07-03 10:10:07 UTC (rev 1489) @@ -23,10 +23,10 @@ //$Id$ -import org.jbpm.api.client.ExecutionFactory; -import org.jbpm.api.client.ProcessDefinitionManager; -import org.jbpm.api.client.ProcessEngine; -import org.jbpm.api.client.ProcessInstanceFactory; +import org.jboss.bpm.client.ExecutionFactory; +import org.jboss.bpm.client.ProcessDefinitionManager; +import org.jboss.bpm.client.ProcessEngine; +import org.jboss.bpm.client.ProcessInstanceFactory; /** * A process engine with public access Modified: jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessInstanceImpl.java =================================================================== --- jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessInstanceImpl.java 2008-07-03 10:09:55 UTC (rev 1488) +++ jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessInstanceImpl.java 2008-07-03 10:10:07 UTC (rev 1489) @@ -23,8 +23,8 @@ //$Id$ -import org.jbpm.api.client.ProcessDefinition; -import org.jbpm.api.client.ProcessInstance; +import org.jboss.bpm.client.ProcessDefinition; +import org.jboss.bpm.client.ProcessInstance; /** * TODO Modified: jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessInstanceManagerImpl.java =================================================================== --- jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessInstanceManagerImpl.java 2008-07-03 10:09:55 UTC (rev 1488) +++ jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessInstanceManagerImpl.java 2008-07-03 10:10:07 UTC (rev 1489) @@ -23,10 +23,10 @@ // $Id$ -import org.jbpm.api.client.ProcessDefinition; -import org.jbpm.api.client.ProcessEngine; -import org.jbpm.api.client.ProcessInstance; -import org.jbpm.api.client.ProcessInstanceFactory; +import org.jboss.bpm.client.ProcessDefinition; +import org.jboss.bpm.client.ProcessEngine; +import org.jboss.bpm.client.ProcessInstance; +import org.jboss.bpm.client.ProcessInstanceFactory; /** * TODO Modified: jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/StartNodeImpl.java =================================================================== --- jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/StartNodeImpl.java 2008-07-03 10:09:55 UTC (rev 1488) +++ jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/StartNodeImpl.java 2008-07-03 10:10:07 UTC (rev 1489) @@ -23,8 +23,8 @@ //$Id$ -import org.jbpm.api.client.ProcessDefinition; -import org.jbpm.api.client.StartNode; +import org.jboss.bpm.client.ProcessDefinition; +import org.jboss.bpm.client.StartNode; /** * TODO |
From: <do-...@jb...> - 2008-07-03 10:10:04
|
Author: tho...@jb... Date: 2008-07-03 06:09:55 -0400 (Thu, 03 Jul 2008) New Revision: 1488 Added: api/trunk/src/main/java/org/jboss/ api/trunk/src/main/java/org/jboss/bpm/ api/trunk/src/main/java/org/jboss/bpm/Context.java api/trunk/src/main/java/org/jboss/bpm/EngineShutdownException.java api/trunk/src/main/java/org/jboss/bpm/InvalidProcessDefinitionException.java api/trunk/src/main/java/org/jboss/bpm/JBPMException.java api/trunk/src/main/java/org/jboss/bpm/NameNotUniqueException.java api/trunk/src/main/java/org/jboss/bpm/NotImplementedException.java api/trunk/src/main/java/org/jboss/bpm/client/ api/trunk/src/main/java/org/jboss/bpm/client/ContextImpl.java api/trunk/src/main/java/org/jboss/bpm/client/EmbeddedBeansDeployer.java api/trunk/src/main/java/org/jboss/bpm/client/EndNode.java api/trunk/src/main/java/org/jboss/bpm/client/Execution.java api/trunk/src/main/java/org/jboss/bpm/client/ExecutionFactory.java api/trunk/src/main/java/org/jboss/bpm/client/Node.java api/trunk/src/main/java/org/jboss/bpm/client/ProcessDefinition.java api/trunk/src/main/java/org/jboss/bpm/client/ProcessDefinitionManager.java api/trunk/src/main/java/org/jboss/bpm/client/ProcessEngine.java api/trunk/src/main/java/org/jboss/bpm/client/ProcessEngineLocator.java api/trunk/src/main/java/org/jboss/bpm/client/ProcessInstance.java api/trunk/src/main/java/org/jboss/bpm/client/ProcessInstanceFactory.java api/trunk/src/main/java/org/jboss/bpm/client/StartNode.java api/trunk/src/test/java/org/jboss/ api/trunk/src/test/java/org/jboss/bpm/ api/trunk/src/test/java/org/jboss/bpm/AbstractAPITestCase.java api/trunk/src/test/java/org/jboss/bpm/AbstractMockEngineTestCase.java api/trunk/src/test/java/org/jboss/bpm/DefaultEngineTestCase.java api/trunk/src/test/java/org/jboss/bpm/client/ api/trunk/src/test/java/org/jboss/bpm/client/MockProcessEngine.java api/trunk/src/test/java/org/jboss/bpm/client/ProcessDefinitionTest.java api/trunk/src/test/java/org/jboss/bpm/client/ProcessEngineLocatorTest.java api/trunk/src/test/java/org/jboss/bpm/samples/ api/trunk/src/test/java/org/jboss/bpm/samples/basic/ api/trunk/src/test/java/org/jboss/bpm/samples/basic/BasicSequenceTest.java Removed: api/trunk/src/main/java/org/jboss/bpm/client/EmbeddedBeansDeployer.java api/trunk/src/main/java/org/jboss/bpm/client/EndNode.java api/trunk/src/main/java/org/jboss/bpm/client/Execution.java api/trunk/src/main/java/org/jboss/bpm/client/ExecutionManager.java api/trunk/src/main/java/org/jboss/bpm/client/Node.java api/trunk/src/main/java/org/jboss/bpm/client/ProcessDefinition.java api/trunk/src/main/java/org/jboss/bpm/client/ProcessDefinitionManager.java api/trunk/src/main/java/org/jboss/bpm/client/ProcessEngine.java api/trunk/src/main/java/org/jboss/bpm/client/ProcessEngineLocator.java api/trunk/src/main/java/org/jboss/bpm/client/ProcessInstance.java api/trunk/src/main/java/org/jboss/bpm/client/ProcessInstanceManager.java api/trunk/src/main/java/org/jboss/bpm/client/StartNode.java api/trunk/src/main/java/org/jbpm/ api/trunk/src/test/java/org/jboss/bpm/client/MockProcessEngine.java api/trunk/src/test/java/org/jboss/bpm/client/ProcessDefinitionTest.java api/trunk/src/test/java/org/jboss/bpm/client/ProcessEngineLocatorTest.java api/trunk/src/test/java/org/jboss/bpm/samples/basic/BasicSequenceTest.java api/trunk/src/test/java/org/jbpm/ Modified: api/trunk/src/test/resources/jbpm-mock-beans.xml Log: Move API to org.jboss.bpm Copied: api/trunk/src/main/java/org/jboss/bpm/Context.java (from rev 1483, api/trunk/src/main/java/org/jbpm/api/Context.java) =================================================================== --- api/trunk/src/main/java/org/jboss/bpm/Context.java (rev 0) +++ api/trunk/src/main/java/org/jboss/bpm/Context.java 2008-07-03 10:09:55 UTC (rev 1488) @@ -0,0 +1,64 @@ +/* + * 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; + +//$Id$ + +import java.util.Collection; +import java.util.Map; +import java.util.Set; + +/** + * A general extendible artifact + * + * @author Tho...@jb... + * @since 20-Apr-2007 + */ +public interface Context +{ + /** Add arbitrary attachments */ + <T> T addAttachment(Class<T> key, Object value); + + /** Get arbitrary attachments */ + <T> Collection<T> getAttachments(); + + /** Get an arbitrary attachment */ + <T> T getAttachment(Class<T> key); + + /** Remove arbitrary attachments */ + <T> T removeAttachment(Class<T> key); + + /** Get an property */ + Object getProperty(String key); + + /** Set a property */ + void setProperty(String key, Object value); + + /** Remove a property */ + void removeProperty(String key); + + /** Get the set of property names */ + Set<String> getProperties(); + + /** Set a map of properties */ + void setProperties(Map<String, Object> props); +} \ No newline at end of file Copied: api/trunk/src/main/java/org/jboss/bpm/EngineShutdownException.java (from rev 1486, api/trunk/src/main/java/org/jbpm/api/EngineShutdownException.java) =================================================================== --- api/trunk/src/main/java/org/jboss/bpm/EngineShutdownException.java (rev 0) +++ api/trunk/src/main/java/org/jboss/bpm/EngineShutdownException.java 2008-07-03 10:09:55 UTC (rev 1488) @@ -0,0 +1,42 @@ +/* + * 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; + +// $Id$ + +/** + * A JBPMException that is thrown when an invalid operation is invoked on + * engine shutdown. + * + * @author tho...@jb... + * @since 18-Jun-2008 + */ +public class EngineShutdownException extends JBPMException { + + public EngineShutdownException() { + super(); + } + + public EngineShutdownException(String message) { + super(message); + } +} Copied: api/trunk/src/main/java/org/jboss/bpm/InvalidProcessDefinitionException.java (from rev 1483, api/trunk/src/main/java/org/jbpm/api/InvalidProcessDefinitionException.java) =================================================================== --- api/trunk/src/main/java/org/jboss/bpm/InvalidProcessDefinitionException.java (rev 0) +++ api/trunk/src/main/java/org/jboss/bpm/InvalidProcessDefinitionException.java 2008-07-03 10:09:55 UTC (rev 1488) @@ -0,0 +1,54 @@ +/* + * 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; + + +// $Id$ + +/** + * A RuntimeException that is thrown for invalid process definitions + * + * @author tho...@jb... + * @since 18-Jun-2008 + */ +public class InvalidProcessDefinitionException extends JBPMException +{ + public InvalidProcessDefinitionException() + { + super(); + } + + public InvalidProcessDefinitionException(String message) + { + super(message); + } + + public InvalidProcessDefinitionException(String message, Throwable cause) + { + super(message, cause); + } + + public InvalidProcessDefinitionException(Throwable cause) + { + super(cause); + } +} Copied: api/trunk/src/main/java/org/jboss/bpm/JBPMException.java (from rev 1483, api/trunk/src/main/java/org/jbpm/api/JBPMException.java) =================================================================== --- api/trunk/src/main/java/org/jboss/bpm/JBPMException.java (rev 0) +++ api/trunk/src/main/java/org/jboss/bpm/JBPMException.java 2008-07-03 10:09:55 UTC (rev 1488) @@ -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; + +// $Id$ + +/** + * A RuntimeException that can be thrown for unrecoverable API errors + * + * @author tho...@jb... + * @since 18-Jun-2008 + */ +public class JBPMException extends RuntimeException { + + public JBPMException() { + super(); + } + + public JBPMException(String message, Throwable cause) { + super(message, cause); + } + + public JBPMException(String message) { + super(message); + } + + public JBPMException(Throwable cause) { + super(cause); + } + +} Copied: api/trunk/src/main/java/org/jboss/bpm/NameNotUniqueException.java (from rev 1483, api/trunk/src/main/java/org/jbpm/api/NameNotUniqueException.java) =================================================================== --- api/trunk/src/main/java/org/jboss/bpm/NameNotUniqueException.java (rev 0) +++ api/trunk/src/main/java/org/jboss/bpm/NameNotUniqueException.java 2008-07-03 10:09:55 UTC (rev 1488) @@ -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.jboss.bpm; + +// $Id$ + +/** + * A JBPMException that is thrown when an element name is not unique. + * + * @author tho...@jb... + * @since 18-Jun-2008 + */ +public class NameNotUniqueException extends JBPMException { + + public NameNotUniqueException() { + super(); + } + + public NameNotUniqueException(String message) { + super(message); + } +} Copied: api/trunk/src/main/java/org/jboss/bpm/NotImplementedException.java (from rev 1483, api/trunk/src/main/java/org/jbpm/api/NotImplementedException.java) =================================================================== --- api/trunk/src/main/java/org/jboss/bpm/NotImplementedException.java (rev 0) +++ api/trunk/src/main/java/org/jboss/bpm/NotImplementedException.java 2008-07-03 10:09:55 UTC (rev 1488) @@ -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.jboss.bpm; + +// $Id: $ + +/** + * A RuntimeException that should be thrown for unimplemented features + * + * @author tho...@jb... + * @since 18-Jun-2008 + */ +public class NotImplementedException extends RuntimeException { + + public NotImplementedException() { + super(); + } + + public NotImplementedException(String message) { + super(message); + } +} Copied: api/trunk/src/main/java/org/jboss/bpm/client (from rev 1483, api/trunk/src/main/java/org/jbpm/api/client) Copied: api/trunk/src/main/java/org/jboss/bpm/client/ContextImpl.java (from rev 1487, api/trunk/src/main/java/org/jbpm/api/client/ContextImpl.java) =================================================================== --- api/trunk/src/main/java/org/jboss/bpm/client/ContextImpl.java (rev 0) +++ api/trunk/src/main/java/org/jboss/bpm/client/ContextImpl.java 2008-07-03 10:09:55 UTC (rev 1488) @@ -0,0 +1,88 @@ +/* + * 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.client; + +//$Id$ + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import org.jboss.bpm.Context; + +/** + * A general extendible artifact + * + * @author Tho...@jb... + * @since 20-Apr-2007 + */ +class ContextImpl implements Context +{ + private Map<Class, Object> attachments = new HashMap<Class, Object>(); + private Map<String, Object> properties = new HashMap<String, Object>(); + + public Collection<Object> getAttachments() + { + return attachments.values(); + } + + public <T> T getAttachment(Class<T> clazz) + { + return (T)attachments.get(clazz); + } + + public <T> T addAttachment(Class<T> clazz, Object obj) + { + return (T)attachments.put(clazz, obj); + } + + public <T> T removeAttachment(Class<T> key) + { + return (T)attachments.remove(key); + } + + public Set<String> getProperties() + { + return properties.keySet(); + } + + public Object getProperty(String key) + { + return properties.get(key); + } + + public void removeProperty(String key) + { + properties.remove(key); + } + + public void setProperty(String key, Object value) + { + properties.put(key, value); + } + + public void setProperties(Map<String, Object> props) + { + properties.putAll(props); + } +} Deleted: api/trunk/src/main/java/org/jboss/bpm/client/EmbeddedBeansDeployer.java =================================================================== --- api/trunk/src/main/java/org/jbpm/api/client/EmbeddedBeansDeployer.java 2008-07-03 06:55:23 UTC (rev 1483) +++ api/trunk/src/main/java/org/jboss/bpm/client/EmbeddedBeansDeployer.java 2008-07-03 10:09:55 UTC (rev 1488) @@ -1,89 +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.jbpm.api.client; - -// $Id: EmbeddedBeansDeployer.java 1379 2008-06-27 10:57:02Z -// tho...@jb... $ - -import java.net.URL; - -import org.jboss.kernel.Kernel; -import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap; -import org.jboss.kernel.plugins.deployment.xml.BasicXMLDeployer; -import org.jboss.kernel.plugins.util.KernelLocator; -import org.jbpm.api.JBPMException; - -/** - * Boostrap the Microcontainer - * - * @author tho...@jb... - * @since 27-Jun-2008 - */ -public class EmbeddedBeansDeployer extends BasicBootstrap { - - private Kernel kernel; - private BasicXMLDeployer deployer; - - public EmbeddedBeansDeployer() { - // Get or bootstrap the kernel - kernel = KernelLocator.getKernel(); - if (kernel == null) { - try { - super.bootstrap(); - kernel = super.getKernel(); - } catch (Throwable e) { - throw new JBPMException("Cannot bootstrap kernel", e); - } - } - deployer = new BasicXMLDeployer(kernel); - } - - /** - * Deploy MC beans from URL - */ - public void deploy(URL url) { - - // Deploy the beans - try { - deployer.deploy(url); - deployer.validate(); - - // The KernelLocator is expected to get deployed as a bean - if (KernelLocator.getKernel() == null) - throw new JBPMException("KernelLocator not deployed as MC bean"); - - } catch (Throwable e) { - throw new JBPMException("Cannot deploy beans from: " + url, e); - } - } - - /** - * Undeploy MC beans from URL - */ - public void undeploy(URL url) { - try { - deployer.undeploy(url); - } catch (Throwable e) { - throw new JBPMException("Cannot undeploy beans from: " + url, e); - } - } -} \ No newline at end of file Copied: api/trunk/src/main/java/org/jboss/bpm/client/EmbeddedBeansDeployer.java (from rev 1487, api/trunk/src/main/java/org/jbpm/api/client/EmbeddedBeansDeployer.java) =================================================================== --- api/trunk/src/main/java/org/jboss/bpm/client/EmbeddedBeansDeployer.java (rev 0) +++ api/trunk/src/main/java/org/jboss/bpm/client/EmbeddedBeansDeployer.java 2008-07-03 10:09:55 UTC (rev 1488) @@ -0,0 +1,89 @@ +/* + * 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.client; + +// $Id: EmbeddedBeansDeployer.java 1379 2008-06-27 10:57:02Z +// tho...@jb... $ + +import java.net.URL; + +import org.jboss.bpm.JBPMException; +import org.jboss.kernel.Kernel; +import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap; +import org.jboss.kernel.plugins.deployment.xml.BasicXMLDeployer; +import org.jboss.kernel.plugins.util.KernelLocator; + +/** + * Boostrap the Microcontainer + * + * @author tho...@jb... + * @since 27-Jun-2008 + */ +public class EmbeddedBeansDeployer extends BasicBootstrap { + + private Kernel kernel; + private BasicXMLDeployer deployer; + + public EmbeddedBeansDeployer() { + // Get or bootstrap the kernel + kernel = KernelLocator.getKernel(); + if (kernel == null) { + try { + super.bootstrap(); + kernel = super.getKernel(); + } catch (Throwable e) { + throw new JBPMException("Cannot bootstrap kernel", e); + } + } + deployer = new BasicXMLDeployer(kernel); + } + + /** + * Deploy MC beans from URL + */ + public void deploy(URL url) { + + // Deploy the beans + try { + deployer.deploy(url); + deployer.validate(); + + // The KernelLocator is expected to get deployed as a bean + if (KernelLocator.getKernel() == null) + throw new JBPMException("KernelLocator not deployed as MC bean"); + + } catch (Throwable e) { + throw new JBPMException("Cannot deploy beans from: " + url, e); + } + } + + /** + * Undeploy MC beans from URL + */ + public void undeploy(URL url) { + try { + deployer.undeploy(url); + } catch (Throwable e) { + throw new JBPMException("Cannot undeploy beans from: " + url, e); + } + } +} \ No newline at end of file Deleted: api/trunk/src/main/java/org/jboss/bpm/client/EndNode.java =================================================================== --- api/trunk/src/main/java/org/jbpm/api/client/EndNode.java 2008-07-03 06:55:23 UTC (rev 1483) +++ api/trunk/src/main/java/org/jboss/bpm/client/EndNode.java 2008-07-03 10:09:55 UTC (rev 1488) @@ -1,40 +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.jbpm.api.client; - -// $Id$ - -/** - * Represents an end node in the process definition. - * - * @author tho...@jb... - * @since 18-Jun-2008 - */ -public abstract class EndNode extends Node -{ - - protected EndNode(ProcessDefinition pdef, String name) - { - super(pdef, name); - } - -} \ No newline at end of file Copied: api/trunk/src/main/java/org/jboss/bpm/client/EndNode.java (from rev 1487, api/trunk/src/main/java/org/jbpm/api/client/EndNode.java) =================================================================== --- api/trunk/src/main/java/org/jboss/bpm/client/EndNode.java (rev 0) +++ api/trunk/src/main/java/org/jboss/bpm/client/EndNode.java 2008-07-03 10:09:55 UTC (rev 1488) @@ -0,0 +1,38 @@ +/* + * 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.client; + +// $Id$ + +/** + * Represents an end node in the process definition. + * + * @author tho...@jb... + * @since 18-Jun-2008 + */ +public abstract class EndNode extends Node +{ + protected EndNode(ProcessDefinition pdef) + { + super(pdef); + } +} \ No newline at end of file Deleted: api/trunk/src/main/java/org/jboss/bpm/client/Execution.java =================================================================== --- api/trunk/src/main/java/org/jbpm/api/client/Execution.java 2008-07-03 06:55:23 UTC (rev 1483) +++ api/trunk/src/main/java/org/jboss/bpm/client/Execution.java 2008-07-03 10:09:55 UTC (rev 1488) @@ -1,72 +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.jbpm.api.client; - -// $Id: $ - -/** - * Represents an execution of a process instance. - * - * The name of an execution is unique in the scope of the process instance. - * - * @author tho...@jb... - * @since 18-Jun-2008 - */ -public abstract class Execution { - - private String name; - private ProcessInstance pinst; - - protected Execution(ProcessInstance pinst, String name) { - - if (pinst == null) - throw new IllegalArgumentException("Process instance cannot be null"); - - if (name == null) - name = "AnonymousExecution#" + pinst.getExecutions().size(); - - this.pinst = pinst; - this.name = name; - } - - /** Get the associated process instance */ - public ProcessInstance getProcessInstance() { - return pinst; - } - - /** Get the name for this execution */ - public String getName() { - return name; - } - - /** - * Get the current node for this execution - */ - public abstract Node getNode(); - - - /** - * Signal this execution - */ - public abstract void signal(); - -} \ No newline at end of file Copied: api/trunk/src/main/java/org/jboss/bpm/client/Execution.java (from rev 1487, api/trunk/src/main/java/org/jbpm/api/client/Execution.java) =================================================================== --- api/trunk/src/main/java/org/jboss/bpm/client/Execution.java (rev 0) +++ api/trunk/src/main/java/org/jboss/bpm/client/Execution.java 2008-07-03 10:09:55 UTC (rev 1488) @@ -0,0 +1,99 @@ +/* + * 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.client; + +// $Id: $ + +/** + * Represents an execution of a process instance. + * + * The name of an execution is unique in the scope of the process instance. + * + * @author tho...@jb... + * @since 18-Jun-2008 + */ +public abstract class Execution +{ + // The associated process instance + private ProcessInstance pinst; + + // Construct the execution + protected Execution(ProcessInstance pinst) + { + if (pinst == null) + throw new IllegalArgumentException("Process instance cannot be null"); + + this.pinst = pinst; + } + + // Call to initialize fully + protected void init(String name) + { + if (name == null) + { + name = "AnonymousExecution#" + pinst.getExecutions().size(); + setName(name); + } + } + + /* Get the associated process instance */ + public ProcessInstance getProcessInstance() + { + return pinst; + } + + /** + * Get the name for the execution + */ + public abstract String getName(); + + // Set the name for the execution + protected abstract void setName(String name); + + /* + * Get the current node for this execution + */ + public final Node getNode() + { + Node node = getNodeOverride(); + return node; + } + + /* + * Get the current node for this execution + */ + protected abstract Node getNodeOverride(); + + /* + * Signal this execution + */ + public final void signal() + { + signalOverride(); + } + + /* + * Signal this execution + */ + protected abstract void signalOverride(); + +} \ No newline at end of file Copied: api/trunk/src/main/java/org/jboss/bpm/client/ExecutionFactory.java (from rev 1487, api/trunk/src/main/java/org/jbpm/api/client/ExecutionFactory.java) =================================================================== --- api/trunk/src/main/java/org/jboss/bpm/client/ExecutionFactory.java (rev 0) +++ api/trunk/src/main/java/org/jboss/bpm/client/ExecutionFactory.java 2008-07-03 10:09:55 UTC (rev 1488) @@ -0,0 +1,74 @@ +/* + * 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.client; + +// $Id: $ + +import org.jboss.bpm.EngineShutdownException; + +/** + * The execution manager is the entry point to create, find and otherwise manage process executions. + * + * @author tho...@jb... + * @since 18-Jun-2008 + */ +public abstract class ExecutionFactory +{ + // Injected through the MC + protected ProcessEngine engine; + + /** + * Get the associated process engine + */ + public ProcessEngine getProcessEngine() + { + if (engine == null) + throw new IllegalStateException("ProcessEngine not available through kernel configuration"); + + return engine; + } + + /** + * Locate the execution manager + */ + public static ExecutionFactory locateExecutionManager() + { + ProcessEngine engine = ProcessEngineLocator.locateProcessEngine(); + return engine.getExecutionManager(); + } + + /** + * Create an execution for a given process instance + */ + public final Execution createExecution(ProcessInstance pinst) + { + // TODO: test this + if (engine.isPrepareForShutdown()) + throw new EngineShutdownException("Cannot create new Execution while engine is shutting down"); + + Execution ex = createExecutionOverride(pinst); + return ex; + } + + // Override to implement execution creation + protected abstract Execution createExecutionOverride(ProcessInstance pinst); +} \ No newline at end of file Deleted: api/trunk/src/main/java/org/jboss/bpm/client/ExecutionManager.java =================================================================== --- api/trunk/src/main/java/org/jbpm/api/client/ExecutionManager.java 2008-07-03 06:55:23 UTC (rev 1483) +++ api/trunk/src/main/java/org/jboss/bpm/client/ExecutionManager.java 2008-07-03 10:09:55 UTC (rev 1488) @@ -1,112 +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.jbpm.api.client; - -// $Id: $ - -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import org.jbpm.api.NameNotUniqueException; - -/** - * The execution manager is the entry point to create, find and otherwise - * manage process executions. - * - * @author tho...@jb... - * @since 18-Jun-2008 - */ -public abstract class ExecutionManager { - - // Injected through the MC - protected ProcessEngine engine; - - // The map of executions - private Map<String, Execution> execs = new HashMap<String, Execution>(); - - /** Get the associated process engine */ - public ProcessEngine getProcessEngine() { - if (engine == null) - throw new IllegalStateException("ProcessEngine not available through kernel configuration"); - - return engine; - } - - /** Locate the execution manager */ - public static ExecutionManager locateExecutionManager() { - ProcessEngine engine = ProcessEngineLocator.locateProcessEngine(); - return engine.getExecutionManager(); - } - - /** - * Create an execution for a given process instance - */ - public abstract Execution createExecution(ProcessInstance pinst); - - /** - * Get the set of registered executions - */ - public Set<Execution> getExecutions() { - return Collections.unmodifiableSet((Set<Execution>) execs.values()); - } - - /** - * Find executions for a given process instance - */ - public Set<Execution> findExecutions(ProcessInstance pinst) { - Set<Execution> subset = new HashSet<Execution>(); - for (Execution ex : execs.values()) - { - if (ex.getProcessInstance() == pinst) - subset.add(ex); - } - return subset; - } - - /** - * Find an execution for a given name - * @return null if the execution is not defined - */ - public Execution findExecution(String name) { - return execs.get(name); - } - - /** - * Remove an execution - */ - public void removeExecution(Execution ex) { - execs.remove(ex.getName()); - } - - // Add an execution - protected void addExecution(Execution ex) { - - String name = ex.getName(); - if (execs.get(name) != null) - throw new NameNotUniqueException("Execution: " + name); - - execs.put(ex.getName(), ex); - } -} \ No newline at end of file Deleted: api/trunk/src/main/java/org/jboss/bpm/client/Node.java =================================================================== --- api/trunk/src/main/java/org/jbpm/api/client/Node.java 2008-07-03 06:55:23 UTC (rev 1483) +++ api/trunk/src/main/java/org/jboss/bpm/client/Node.java 2008-07-03 10:09:55 UTC (rev 1488) @@ -1,66 +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.jbpm.api.client; - -// $Id:$ - -/** - * Represents a node in the process definition. - * - * A node is an immutable object. - * The name of a node is unique in the scope of the process definition. - * - * @author tho...@jb... - * @since 18-Jun-2008 - */ -public abstract class Node { - - private ProcessDefinition pdef; - private String name; - - protected Node(ProcessDefinition pdef, String name) { - - if (pdef == null) - throw new IllegalArgumentException("Process definition cannot be null"); - - if (name == null) - name = "AnonymousNode#" + pdef.getNodes().size(); - - this.pdef = pdef; - this.name = name; - } - - /** Get the associated process definition */ - public ProcessDefinition getProcessDefinition() { - return pdef; - } - - /** Get the node name */ - public String getName() { - return name; - } - - /** Returns a string representation of the object. */ - public String toString() { - return "Node[" + name + "]"; - } -} \ No newline at end of file Copied: api/trunk/src/main/java/org/jboss/bpm/client/Node.java (from rev 1487, api/trunk/src/main/java/org/jbpm/api/client/Node.java) =================================================================== --- api/trunk/src/main/java/org/jboss/bpm/client/Node.java (rev 0) +++ api/trunk/src/main/java/org/jboss/bpm/client/Node.java 2008-07-03 10:09:55 UTC (rev 1488) @@ -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.client; + +// $Id:$ + +/** + * Represents a node in the process definition. A node is an immutable object. The name of a node is unique in the scope of the process definition. + * + * @author tho...@jb... + * @since 18-Jun-2008 + */ +public abstract class Node +{ + // The associated process definition + private ProcessDefinition pdef; + + // Construct the node + protected Node(ProcessDefinition pdef) + { + if (pdef == null) + throw new IllegalArgumentException("Process definition cannot be null"); + + this.pdef = pdef; + } + + // Call to initialize fully + protected void init(String name) + { + if (name == null) + { + name = "AnonymousNode#" + pdef.getNodes().size(); + setName(name); + } + } + + /** Get the associated process definition */ + public ProcessDefinition getProcessDefinition() + { + return pdef; + } + + /** Get the node name */ + public abstract String getName(); + + // Set the node name + protected abstract void setName(String name); + + /** Returns a string representation of the object. */ + public String toString() + { + return "Node[" + getName() + "]"; + } +} \ No newline at end of file Deleted: api/trunk/src/main/java/org/jboss/bpm/client/ProcessDefinition.java =================================================================== --- api/trunk/src/main/java/org/jbpm/api/client/ProcessDefinition.java 2008-07-03 06:55:23 UTC (rev 1483) +++ api/trunk/src/main/java/org/jboss/bpm/client/ProcessDefinition.java 2008-07-03 10:09:55 UTC (rev 1488) @@ -1,199 +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.jbpm.api.client; - -// $Id: $ - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.jbpm.api.InvalidProcessDefinitionException; -import org.jbpm.api.NameNotUniqueException; - -/** - * Represents the structural definition of a BPM process - * - * @author tho...@jb... - * @since 18-Jun-2008 - */ -public class ProcessDefinition -{ - - /** The protected name */ - private String name; - /** The protected list of nodes */ - private List<Node> nodes = new ArrayList<Node>(); - - /** - * Construct the process definition with a given name - */ - protected ProcessDefinition(String name) - { - if (name == null) - { - ProcessDefinitionManager pdm = ProcessDefinitionManager.locateProcessDefinitionManager(); - name = "AnonymousDef#" + pdm.getProcessDefinitions().size(); - } - - this.name = name; - } - - /** - * Get the name of this process definition - */ - public String getName() - { - return name; - } - - /** Get an unmutable list of node objects */ - public List<Node> getNodes() - { - return Collections.unmodifiableList(nodes); - } - - /** - * Find a node for a given name - * - * @return null if the node is not defined - */ - public Node findNode(String name) - { - return findNodeInternal(name); - } - - /** - * Get the start node for this process definition - * - * @return The start node - * @throws InvalidProcessDefinitionException if there is no start node - */ - public StartNode getStartNode() - { - Node rootNode = getStartNodeInternal(); - if (rootNode == null) - throw new InvalidProcessDefinitionException("Process definition does not have a start node"); - - return (StartNode)rootNode; - } - - /** - * Get the set of end nodes - * - * @return an emty set if - */ - public Set<EndNode> getEndNodes() - { - Set<EndNode> endNodes = new HashSet<EndNode>(); - for (Node aux : nodes) - { - if (aux instanceof EndNode) - { - endNodes.add((EndNode)aux); - } - } - if (endNodes.size() == 0) - throw new InvalidProcessDefinitionException("Process definition does not have end nodes"); - - return endNodes; - } - - // Add a node - protected void addNode(Node apiNode) - { - if (apiNode instanceof StartNode && getStartNodeInternal() != null) - throw new InvalidProcessDefinitionException("Process definition cannot have multiple start nodes: " + apiNode); - - String name = apiNode.getName(); - if (findNodeInternal(name) != null) - throw new NameNotUniqueException("Node: " + name); - - nodes.add(apiNode); - } - - /** - * Create an instance of this process definition. - */ - public ProcessInstance createProcessInstance() - { - ProcessEngine engine = ProcessEngineLocator.locateProcessEngine(); - ProcessInstanceManager pim = engine.getProcessInstanceManager(); - ProcessInstance pinst = pim.createProcessInstance(this); - return pinst; - } - - /** - * Create an execution for this process definition. - * Note, that this will automatically create a new process instance. - */ - public Execution createExecution() - { - ProcessEngine engine = ProcessEngineLocator.locateProcessEngine(); - ProcessInstanceManager pim = engine.getProcessInstanceManager(); - ProcessInstance pinst = pim.createProcessInstance(this); - ExecutionManager pem = engine.getExecutionManager(); - return pem.createExecution(pinst); - } - - /** - * Get the process instances associated with this process definition - */ - public Set<ProcessInstance> getProcessInstances() - { - ProcessInstanceManager pim = ProcessInstanceManager.locateProcessInstanceManager(); - Set<ProcessInstance> pinsts = pim.findProcessInstances(this); - return pinsts; - } - - // private - - private StartNode getStartNodeInternal() - { - Node rootNode = null; - for (Node aux : nodes) - { - if (aux instanceof StartNode) - { - rootNode = aux; - break; - } - } - return (StartNode)rootNode; - } - - private Node findNodeInternal(String name) - { - Node apiNode = null; - for (Node aux : nodes) - { - if (aux.getName().equals(name)) - { - apiNode = aux; - break; - } - } - return apiNode; - } -} \ No newline at end of file Copied: api/trunk/src/main/java/org/jboss/bpm/client/ProcessDefinition.java (from rev 1487, api/trunk/src/main/java/org/jbpm/api/client/ProcessDefinition.java) =================================================================== --- api/trunk/src/main/java/org/jboss/bpm/client/ProcessDefinition.java (rev 0) +++ api/trunk/src/main/java/org/jboss/bpm/client/ProcessDefinition.java 2008-07-03 10:09:55 UTC (rev 1488) @@ -0,0 +1,229 @@ +/* + * 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.client; + +// $Id: $ + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.jboss.bpm.InvalidProcessDefinitionException; +import org.jboss.bpm.NameNotUniqueException; + +/** + * Represents the structural definition of a BPM process + * + * @author tho...@jb... + * @since 18-Jun-2008 + */ +public abstract class ProcessDefinition +{ + // The list of nodes + private List<Node> nodes = new ArrayList<Node>(); + // The set of process instances + private Set<ProcessInstance> pinstSet = new HashSet<ProcessInstance>(); + + // Construct the process definition + protected ProcessDefinition() + { + } + + // Call to initialize fully + protected void init(String name) + { + if (name == null) + { + ProcessDefinitionManager pdm = ProcessDefinitionManager.locateProcessDefinitionManager(); + name = "AnonymousDef#" + pdm.getProcessDefinitions().size(); + setName(name); + } + } + + /** + * Get the name + */ + public abstract String getName(); + + // Set the name + protected abstract void setName(String name); + + /** + * Get an unmutable list of node objects + */ + public List<Node> getNodes() + { + return Collections.unmodifiableList(nodes); + } + + /** + * Find a node for a given name + * + * @return null if the node is not defined + */ + public Node findNode(String name) + { + return findNodeInternal(name); + } + + /** + * Get the start node for this process definition + * + * @return The start node + * + * @throws InvalidProcessDefinitionException if there is no start node + */ + public StartNode getStartNode() + { + Node rootNode = getStartNodeInternal(); + if (rootNode == null) + throw new InvalidProcessDefinitionException("Process definition does not have a start node"); + + return (StartNode)rootNode; + } + + /** + * Get the set of end nodes + * + * @return an emty set if + */ + public Set<EndNode> getEndNodes() + { + Set<EndNode> endNodes = new HashSet<EndNode>(); + for (Node aux : nodes) + { + if (aux instanceof EndNode) + { + endNodes.add((EndNode)aux); + } + } + if (endNodes.size() == 0) + throw new InvalidProcessDefinitionException("Process definition does not have end nodes"); + + return endNodes; + } + + // Add a node + protected void addNode(Node apiNode) + { + if (apiNode instanceof StartNode && getStartNodeInternal() != null) + throw new InvalidProcessDefinitionException("Process definition cannot have multiple start nodes: " + apiNode); + + String name = apiNode.getName(); + if (findNodeInternal(name) != null) + throw new NameNotUniqueException("Node: " + name); + + nodes.add(apiNode); + } + + /** + * Create an instance of this process definition. + */ + public ProcessInstance createProcessInstance() + { + ProcessEngine engine = ProcessEngineLocator.locateProcessEngine(); + ProcessInstanceFactory pim = engine.getProcessInstanceManager(); + ProcessInstance pinst = pim.createProcessInstance(this); + return pinst; + } + + /** + * Get the set of registered process instances + */ + public Set<ProcessInstance> getProcessInstances() + { + return Collections.unmodifiableSet(pinstSet); + } + + /** + * Find a ProcessInstance for a given name + * @return null if it cannot be found + */ + public ProcessInstance findProcessInstance(String name) + { + for (ProcessInstance pinst : pinstSet) + { + if (pinst.getName() == name) + return pinst; + } + return null; + } + + /** + * Remove a ProcessInstance for a given name + */ + public void removeProcessInstance(String name) + { + for (ProcessInstance pinst : pinstSet) + { + if (pinst.getName() == name) + { + pinstSet.remove(pinst); + break; + } + } + } + + /* + * Create an execution for this process definition. Note, that this will automatically create a new process instance. + */ + public Execution createExecution() + { + ProcessEngine engine = ProcessEngineLocator.locateProcessEngine(); + ProcessInstanceFactory pim = engine.getProcessInstanceManager(); + ProcessInstance pinst = pim.createProcessInstance(this); + ExecutionFactory pem = engine.getExecutionManager(); + return pem.createExecution(pinst); + } + + // private + + private StartNode getStartNodeInternal() + { + Node rootNode = null; + for (Node aux : nodes) + { + if (aux instanceof StartNode) + { + rootNode = aux; + break; + } + } + return (StartNode)rootNode; + } + + private Node findNodeInternal(String name) + { + Node apiNode = null; + for (Node aux : nodes) + { + if (aux.getName().equals(name)) + { + apiNode = aux; + break; + } + } + return apiNode; + } +} \ No newline at end of file Deleted: api/trunk/src/main/java/org/jboss/bpm/client/ProcessDefinitionManager.java =================================================================== --- api/trunk/src/main/java/org/jbpm/api/client/ProcessDefinitionManager.java 2008-07-03 06:55:23 UTC (rev 1483) +++ api/trunk/src/main/java/org/jboss/bpm/client/ProcessDefinitionManager.java 2008-07-03 10:09:55 UTC (rev 1488) @@ -1,122 +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.jbpm.api.client; - -// $Id: $ - -import java.io.IOException; -import java.net.URL; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - -/** - * The process definition manager is the entry point to create, find and otherwise manage process definitions. - * - * @author tho...@jb... - * @since 18-Jun-2008 - */ -public abstract class ProcessDefinitionManager -{ - - // Injected through the MC - protected ProcessEngine engine; - // The set of process definitions - private Set<ProcessDefinition> pdefs = new HashSet<ProcessDefinition>(); - - /** Get the associated process engine */ - public ProcessEngine getProcessEngine() - { - if (engine == null) - throw new IllegalStateException("ProcessEngine not available through kernel configuration"); - - return engine; - } - - /** Locate the process definition manage... [truncated message content] |
From: <do-...@jb...> - 2008-07-03 10:03:43
|
Author: tho...@jb... Date: 2008-07-03 06:03:39 -0400 (Thu, 03 Jul 2008) New Revision: 1487 Added: jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/StartNodeImpl.java Removed: jbpm3/trunk/eclipse/ jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/StartStateImpl.java Modified: jbpm3/trunk/.classpath jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/EndNodeImpl.java jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ExecutionImpl.java jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ExecutionManagerImpl.java jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/NodeImpl.java jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessDefinitionAdapter.java jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessDefinitionImpl.java jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessDefinitionManagerImpl.java jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessEngineImpl.java jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessInstanceImpl.java jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessInstanceManagerImpl.java Log: Update API Modified: jbpm3/trunk/.classpath =================================================================== --- jbpm3/trunk/.classpath 2008-07-03 10:03:26 UTC (rev 1486) +++ jbpm3/trunk/.classpath 2008-07-03 10:03:39 UTC (rev 1487) @@ -1,39 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="src" output="modules/jpdl/core/target/classes" path="modules/jpdl/core/src/main/java"/> - <classpathentry kind="src" output="modules/jpdl/core/target/test-classes" path="modules/jpdl/core/src/test/java"/> - <classpathentry excluding="**" kind="src" output="modules/jpdl/core/target/classes" path="modules/jpdl/core/src/main/resources"/> - <classpathentry excluding="**" kind="src" output="modules/jpdl/core/target/test-classes" path="modules/jpdl/core/src/test/resources"/> - <classpathentry excluding="**" kind="src" output="modules/jpdl/db/target/classes" path="modules/jpdl/db/src/main/resources"/> - <classpathentry kind="src" output="modules/jpdl/identity/target/classes" path="modules/jpdl/identity/src/main/java"/> - <classpathentry kind="src" output="modules/jpdl/identity/target/test-classes" path="modules/jpdl/identity/src/test/java"/> - <classpathentry excluding="**" kind="src" output="modules/jpdl/identity/target/classes" path="modules/jpdl/identity/src/main/resources"/> - <classpathentry excluding="**" kind="src" output="modules/jpdl/identity/target/test-classes" path="modules/jpdl/identity/src/test/resources"/> - <classpathentry kind="src" output="modules/jpdl/examples/target/test-classes" path="modules/jpdl/examples/src/test/java"/> - <classpathentry excluding="**" kind="src" output="modules/jpdl/examples/target/test-classes" path="modules/jpdl/examples/src/test/resources"/> - <classpathentry kind="src" output="modules/jpdl/integration/target/classes" path="modules/jpdl/integration/src/main/java"/> - <classpathentry kind="src" output="modules/jpdl/integration/target/test-classes" path="modules/jpdl/integration/src/test/java"/> - <classpathentry excluding="**" kind="src" output="modules/jpdl/integration/target/classes" path="modules/jpdl/integration/src/main/resources"/> - <classpathentry excluding="**" kind="src" output="modules/jpdl/integration/target/test-classes" path="modules/jpdl/integration/src/test/resources"/> - <classpathentry kind="src" output="modules/jpdl/simulation/target/classes" path="modules/jpdl/simulation/src/main/java"/> - <classpathentry kind="src" output="modules/jpdl/simulation/target/test-classes" path="modules/jpdl/simulation/src/test/java"/> - <classpathentry excluding="**" kind="src" output="modules/jpdl/simulation/target/classes" path="modules/jpdl/simulation/src/main/resources"/> - <classpathentry kind="src" output="modules/jpdl/ws/target/classes" path="modules/jpdl/ws/src/main/java"/> - <classpathentry excluding="**" kind="src" output="modules/jpdl/ws/target/classes" path="modules/jpdl/ws/src/main/resources"/> - <classpathentry kind="src" output="modules/jbpm4jsf/target/classes" path="modules/jbpm4jsf/src/main/java"/> - <classpathentry excluding="**" kind="src" output="modules/jbpm4jsf/target/classes" path="modules/jbpm4jsf/src/main/resources"/> - <classpathentry excluding="**" kind="src" output="modules/console/target/classes" path="modules/console/src/main/resources"/> - <classpathentry kind="src" output="modules/enterprise/target/classes" path="modules/enterprise/src/main/java"/> - <classpathentry kind="src" output="modules/enterprise/target/test-classes" path="modules/enterprise/src/test/java"/> - <classpathentry excluding="**" kind="src" output="modules/enterprise/target/classes" path="modules/enterprise/src/main/resources"/> - <classpathentry excluding="**" kind="src" output="modules/enterprise/target/test-classes" path="modules/enterprise/src/test/resources"/> - <classpathentry kind="src" output="modules/bamconsole/ejb/target/classes" path="modules/bamconsole/ejb/src/main/java"/> - <classpathentry kind="src" output="modules/bamconsole/ejb/target/test-classes" path="modules/bamconsole/ejb/src/test/java"/> - <classpathentry excluding="**" kind="src" output="modules/bamconsole/ejb/target/classes" path="modules/bamconsole/ejb/src/main/resources"/> - <classpathentry excluding="**" kind="src" output="modules/bamconsole/ejb/target/test-classes" path="modules/bamconsole/ejb/src/test/resources"/> - <classpathentry excluding="**" kind="src" output="modules/bamconsole/war/target/classes" path="modules/bamconsole/war/src/main/resources"/> - <classpathentry excluding="**" kind="src" output="modules/bamconsole/ear/target/classes" path="modules/bamconsole/ear/src/main/resources"/> + <classpathentry kind="src" path="modules/jpdl/core/src/main/java"/> + <classpathentry kind="src" path="modules/jpdl/integration/src/main/java"/> + <classpathentry kind="src" path="modules/jpdl/core/src/test/java"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/> - <classpathentry kind="output" path="target/classes"/> + <classpathentry kind="output" path="target/eclipse-classes"/> </classpath> Modified: jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/EndNodeImpl.java =================================================================== --- jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/EndNodeImpl.java 2008-07-03 10:03:26 UTC (rev 1486) +++ jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/EndNodeImpl.java 2008-07-03 10:03:39 UTC (rev 1487) @@ -32,9 +32,26 @@ * @author tho...@jb... * @since 18-Jun-2008 */ -public class EndNodeImpl extends EndNode { +public class EndNodeImpl extends EndNode +{ + private org.jbpm.graph.def.Node oldNode; - EndNodeImpl(ProcessDefinition def, String name) { - super(def, name); + EndNodeImpl(ProcessDefinition def, org.jbpm.graph.def.Node oldNode) + { + super(def); + this.oldNode = oldNode; + init(oldNode.getName()); } + + @Override + public String getName() + { + return oldNode.getName(); + } + + @Override + protected void setName(String name) + { + oldNode.setName(name); + } } Modified: jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ExecutionImpl.java =================================================================== --- jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ExecutionImpl.java 2008-07-03 10:03:26 UTC (rev 1486) +++ jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ExecutionImpl.java 2008-07-03 10:03:39 UTC (rev 1487) @@ -21,36 +21,55 @@ */ package org.jbpm.integration.client; +//$Id$ + import org.jbpm.api.client.Execution; import org.jbpm.api.client.Node; import org.jbpm.api.client.ProcessInstance; -// $Id$ - /** * TODO * * @author tho...@jb... * @since 18-Jun-2008 */ -public class ExecutionImpl extends Execution { +public class ExecutionImpl extends Execution +{ org.jbpm.graph.exe.Execution oldEx; private ProcessInstance pinst; - - ExecutionImpl(ProcessInstance pi, org.jbpm.graph.exe.Execution oldEx) { - super(pi, oldEx.getKey()); + + ExecutionImpl(ProcessInstance pi, org.jbpm.graph.exe.Execution oldEx) + { + super(pi); this.pinst = pi; this.oldEx = oldEx; + init(oldEx.getKey()); } - public Node getNode() { + @Override + protected Node getNodeOverride() + { org.jbpm.graph.def.Node oldNode = oldEx.getRootToken().getNode(); Node apiNode = pinst.getProcessDefinition().findNode(oldNode.getName()); return apiNode; } - public void signal() { + @Override + protected void signalOverride() + { oldEx.signal(); } + + @Override + public String getName() + { + return oldEx.getKey(); + } + + @Override + protected void setName(String name) + { + oldEx.setKey(name); + } } Modified: jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ExecutionManagerImpl.java =================================================================== --- jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ExecutionManagerImpl.java 2008-07-03 10:03:26 UTC (rev 1486) +++ jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ExecutionManagerImpl.java 2008-07-03 10:03:39 UTC (rev 1487) @@ -24,7 +24,7 @@ // $Id$ import org.jbpm.api.client.Execution; -import org.jbpm.api.client.ExecutionManager; +import org.jbpm.api.client.ExecutionFactory; import org.jbpm.api.client.ProcessEngine; import org.jbpm.api.client.ProcessInstance; @@ -34,20 +34,20 @@ * @author tho...@jb... * @since 18-Jun-2008 */ -public class ExecutionManagerImpl extends ExecutionManager { +public class ExecutionManagerImpl extends ExecutionFactory +{ - public void setProcessEngine(ProcessEngine engine) { + public void setProcessEngine(ProcessEngine engine) + { this.engine = engine; } - public Execution createExecution(ProcessInstance pi) { - - ProcessDefinitionImpl apiPD = (ProcessDefinitionImpl) pi.getProcessDefinition(); + @Override + protected Execution createExecutionOverride(ProcessInstance pi) + { + ProcessDefinitionImpl apiPD = (ProcessDefinitionImpl)pi.getProcessDefinition(); org.jbpm.graph.exe.Execution oldEx = new org.jbpm.graph.exe.Execution(apiPD.oldPD); - ExecutionImpl ex = new ExecutionImpl(pi, oldEx); - addExecution(ex); return ex; } - } Modified: jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/NodeImpl.java =================================================================== --- jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/NodeImpl.java 2008-07-03 10:03:26 UTC (rev 1486) +++ jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/NodeImpl.java 2008-07-03 10:03:39 UTC (rev 1487) @@ -32,9 +32,26 @@ * @author tho...@jb... * @since 18-Jun-2008 */ -public class NodeImpl extends Node { +public class NodeImpl extends Node +{ + private org.jbpm.graph.def.Node oldNode; + + NodeImpl(ProcessDefinition def, org.jbpm.graph.def.Node oldNode) + { + super(def); + this.oldNode = oldNode; + init(oldNode.getName()); + } - NodeImpl(ProcessDefinition def, String name) { - super(def, name); + @Override + public String getName() + { + return oldNode.getName(); } + + @Override + protected void setName(String name) + { + oldNode.setName(name); + } } Modified: jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessDefinitionAdapter.java =================================================================== --- jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessDefinitionAdapter.java 2008-07-03 10:03:26 UTC (rev 1486) +++ jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessDefinitionAdapter.java 2008-07-03 10:03:39 UTC (rev 1487) @@ -48,10 +48,10 @@ Node apiNode = NodeAdapter.adaptNode(apiPD, oldNode); apiPD.addNode(apiNode); } - + // validate validateProcessDefinition(apiPD); - + return apiPD; } @@ -67,19 +67,18 @@ static Node adaptNode(ProcessDefinition pDef, org.jbpm.graph.def.Node oldNode) { - String oldName = oldNode.getName(); Node apiNode; if (oldNode instanceof StartState) { - apiNode = new StartStateImpl(pDef, oldName); + apiNode = new StartNodeImpl(pDef, oldNode); } else if (oldNode instanceof EndState) { - apiNode = new EndNodeImpl(pDef, oldName); + apiNode = new EndNodeImpl(pDef, oldNode); } else { - apiNode = new NodeImpl(pDef, oldName); + apiNode = new NodeImpl(pDef, oldNode); } return apiNode; } Modified: jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessDefinitionImpl.java =================================================================== --- jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessDefinitionImpl.java 2008-07-03 10:03:26 UTC (rev 1486) +++ jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessDefinitionImpl.java 2008-07-03 10:03:39 UTC (rev 1487) @@ -32,18 +32,31 @@ * @author tho...@jb... * @since 18-Jun-2008 */ -public class ProcessDefinitionImpl extends ProcessDefinition { +public class ProcessDefinitionImpl extends ProcessDefinition +{ + org.jbpm.graph.def.ProcessDefinition oldPD; - org.jbpm.graph.def.ProcessDefinition oldPD; - - ProcessDefinitionImpl(org.jbpm.graph.def.ProcessDefinition oldPD) { - super(oldPD.getName()); + ProcessDefinitionImpl(org.jbpm.graph.def.ProcessDefinition oldPD) + { this.oldPD = oldPD; + init(oldPD.getName()); } - + // Add a node - public void addNode(Node apiNode) { + public void addNode(Node apiNode) + { super.addNode(apiNode); } - + + @Override + public String getName() + { + return oldPD.getName(); + } + + @Override + protected void setName(String name) + { + oldPD.setName(name); + } } Modified: jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessDefinitionManagerImpl.java =================================================================== --- jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessDefinitionManagerImpl.java 2008-07-03 10:03:26 UTC (rev 1486) +++ jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessDefinitionManagerImpl.java 2008-07-03 10:03:39 UTC (rev 1487) @@ -46,7 +46,8 @@ this.engine = engine; } - public ProcessDefinition createProcessDefinition(String jpdl) + @Override + protected ProcessDefinition createProcessDefinitionOverride(String jpdl) { org.jbpm.graph.def.ProcessDefinition oldPD; try @@ -62,7 +63,8 @@ return pdef; } - public ProcessDefinition createProcessDefinition(URL jpdl) throws IOException + @Override + protected ProcessDefinition createProcessDefinitionOverride(URL jpdl) throws IOException { org.jbpm.graph.def.ProcessDefinition oldPD; try Modified: jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessEngineImpl.java =================================================================== --- jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessEngineImpl.java 2008-07-03 10:03:26 UTC (rev 1486) +++ jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessEngineImpl.java 2008-07-03 10:03:39 UTC (rev 1487) @@ -23,10 +23,10 @@ //$Id$ -import org.jbpm.api.client.ExecutionManager; +import org.jbpm.api.client.ExecutionFactory; import org.jbpm.api.client.ProcessDefinitionManager; import org.jbpm.api.client.ProcessEngine; -import org.jbpm.api.client.ProcessInstanceManager; +import org.jbpm.api.client.ProcessInstanceFactory; /** * A process engine with public access @@ -40,11 +40,11 @@ this.processDefinitionManager = processDefinitionManager; } - public void setProcessInstanceManager(ProcessInstanceManager processInstanceManager) { + public void setProcessInstanceManager(ProcessInstanceFactory processInstanceManager) { this.processInstanceManager = processInstanceManager; } - public void setExecutionManager(ExecutionManager executionManager) { + public void setExecutionManager(ExecutionFactory executionManager) { this.executionManager = executionManager; } } Modified: jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessInstanceImpl.java =================================================================== --- jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessInstanceImpl.java 2008-07-03 10:03:26 UTC (rev 1486) +++ jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessInstanceImpl.java 2008-07-03 10:03:39 UTC (rev 1487) @@ -32,10 +32,11 @@ * @author tho...@jb... * @since 18-Jun-2008 */ -public class ProcessInstanceImpl extends ProcessInstance { - - ProcessInstanceImpl(ProcessDefinition pdef) { +public class ProcessInstanceImpl extends ProcessInstance +{ + ProcessInstanceImpl(ProcessDefinition pdef) + { super(pdef); + init(null); } - } Modified: jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessInstanceManagerImpl.java =================================================================== --- jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessInstanceManagerImpl.java 2008-07-03 10:03:26 UTC (rev 1486) +++ jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/ProcessInstanceManagerImpl.java 2008-07-03 10:03:39 UTC (rev 1487) @@ -26,7 +26,7 @@ import org.jbpm.api.client.ProcessDefinition; import org.jbpm.api.client.ProcessEngine; import org.jbpm.api.client.ProcessInstance; -import org.jbpm.api.client.ProcessInstanceManager; +import org.jbpm.api.client.ProcessInstanceFactory; /** * TODO @@ -34,18 +34,15 @@ * @author tho...@jb... * @since 18-Jun-2008 */ -public class ProcessInstanceManagerImpl extends ProcessInstanceManager { +public class ProcessInstanceManagerImpl extends ProcessInstanceFactory { public void setProcessEngine(ProcessEngine engine) { this.engine = engine; } - /** - * Create a new process instance based on this process description - */ - public ProcessInstance createProcessInstance(ProcessDefinition pdef) { + @Override + protected ProcessInstance createProcessInstanceOverride(ProcessDefinition pdef) { ProcessInstance pinst = new ProcessInstanceImpl(pdef); - addProcessInstance(pinst); return pinst; } } Copied: jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/StartNodeImpl.java (from rev 1484, jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/StartStateImpl.java) =================================================================== --- jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/StartNodeImpl.java (rev 0) +++ jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/StartNodeImpl.java 2008-07-03 10:03:39 UTC (rev 1487) @@ -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.jbpm.integration.client; + +//$Id$ + +import org.jbpm.api.client.ProcessDefinition; +import org.jbpm.api.client.StartNode; + +/** + * TODO + * + * @author tho...@jb... + * @since 18-Jun-2008 + */ +public class StartNodeImpl extends StartNode +{ + private org.jbpm.graph.def.Node oldNode; + + StartNodeImpl(ProcessDefinition def, org.jbpm.graph.def.Node oldNode) + { + super(def); + this.oldNode = oldNode; + init(oldNode.getName()); + } + + @Override + public String getName() + { + return oldNode.getName(); + } + + @Override + protected void setName(String name) + { + oldNode.setName(name); + } +} Deleted: jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/StartStateImpl.java =================================================================== --- jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/StartStateImpl.java 2008-07-03 10:03:26 UTC (rev 1486) +++ jbpm3/trunk/modules/jpdl/integration/src/main/java/org/jbpm/integration/client/StartStateImpl.java 2008-07-03 10:03:39 UTC (rev 1487) @@ -1,40 +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.jbpm.integration.client; - -//$Id$ - -import org.jbpm.api.client.ProcessDefinition; -import org.jbpm.api.client.StartNode; - -/** - * TODO - * - * @author tho...@jb... - * @since 18-Jun-2008 - */ -public class StartStateImpl extends StartNode { - - StartStateImpl(ProcessDefinition def, String name) { - super(def, name); - } -} |
From: <do-...@jb...> - 2008-07-03 10:03:34
|
Author: tho...@jb... Date: 2008-07-03 06:03:26 -0400 (Thu, 03 Jul 2008) New Revision: 1486 Added: api/trunk/src/main/java/org/jbpm/api/EngineShutdownException.java api/trunk/src/main/java/org/jbpm/api/client/ContextImpl.java api/trunk/src/main/java/org/jbpm/api/client/ExecutionFactory.java api/trunk/src/main/java/org/jbpm/api/client/ProcessInstanceFactory.java Removed: api/trunk/src/main/java/org/jbpm/api/ContextImpl.java api/trunk/src/main/java/org/jbpm/api/client/ExecutionManager.java api/trunk/src/main/java/org/jbpm/api/client/ProcessInstanceManager.java Modified: api/trunk/docs/VioletUML/ClientView.class.violet api/trunk/docs/VioletUML/EngineAndManagers.class.violet api/trunk/eclipse/jBPMCodeStyle.xml api/trunk/src/main/java/org/jbpm/api/client/EndNode.java api/trunk/src/main/java/org/jbpm/api/client/Execution.java api/trunk/src/main/java/org/jbpm/api/client/Node.java api/trunk/src/main/java/org/jbpm/api/client/ProcessDefinition.java api/trunk/src/main/java/org/jbpm/api/client/ProcessDefinitionManager.java api/trunk/src/main/java/org/jbpm/api/client/ProcessEngine.java api/trunk/src/main/java/org/jbpm/api/client/ProcessInstance.java api/trunk/src/main/java/org/jbpm/api/client/StartNode.java api/trunk/src/test/java/org/jbpm/api/client/MockProcessEngine.java api/trunk/src/test/java/org/jbpm/api/client/ProcessDefinitionTest.java api/trunk/src/test/java/org/jbpm/api/samples/basic/BasicSequenceTest.java Log: Update API Modified: api/trunk/docs/VioletUML/ClientView.class.violet =================================================================== --- api/trunk/docs/VioletUML/ClientView.class.violet 2008-07-03 07:47:31 UTC (rev 1485) +++ api/trunk/docs/VioletUML/ClientView.class.violet 2008-07-03 10:03:26 UTC (rev 1486) @@ -10,7 +10,9 @@ </void> <void property="methods"> <void property="text"> - <string>createProcessInstance</string> + <string>createProcessInstance +findProcessInstance +removeProcessInstance</string> </void> </void> <void property="name"> @@ -42,8 +44,8 @@ </object> <object class="java.awt.geom.Point2D$Double"> <void method="setLocation"> - <double>448.0</double> - <double>206.0</double> + <double>433.0</double> + <double>224.0</double> </void> </object> </void> @@ -88,7 +90,9 @@ </void> <void property="methods"> <void property="text"> - <string>createExecution</string> + <string>createExecution +findExecution +removeExecution</string> </void> </void> <void property="name"> @@ -99,8 +103,8 @@ </object> <object class="java.awt.geom.Point2D$Double"> <void method="setLocation"> - <double>215.0</double> - <double>320.0</double> + <double>209.0</double> + <double>354.0</double> </void> </object> </void> @@ -124,8 +128,8 @@ </object> <object class="java.awt.geom.Point2D$Double"> <void method="setLocation"> - <double>447.0</double> - <double>332.0</double> + <double>444.0</double> + <double>366.0</double> </void> </object> </void> @@ -145,8 +149,8 @@ </object> <object class="java.awt.geom.Point2D$Double"> <void method="setLocation"> - <double>594.0</double> - <double>336.0</double> + <double>611.0</double> + <double>365.0</double> </void> </object> </void> @@ -178,8 +182,8 @@ </object> <object class="java.awt.geom.Point2D$Double"> <void method="setLocation"> - <double>231.0</double> - <double>64.0</double> + <double>241.0</double> + <double>63.0</double> </void> </object> </void> @@ -195,8 +199,8 @@ </object> <object class="java.awt.geom.Point2D$Double"> <void method="setLocation"> - <double>486.0</double> - <double>427.0</double> + <double>476.0</double> + <double>483.0</double> </void> </object> </void> Modified: api/trunk/docs/VioletUML/EngineAndManagers.class.violet =================================================================== --- api/trunk/docs/VioletUML/EngineAndManagers.class.violet 2008-07-03 07:47:31 UTC (rev 1485) +++ api/trunk/docs/VioletUML/EngineAndManagers.class.violet 2008-07-03 10:03:26 UTC (rev 1486) @@ -8,11 +8,6 @@ <string>name</string> </void> </void> - <void property="methods"> - <void property="text"> - <string>createProcessInstance</string> - </void> - </void> <void property="name"> <void property="text"> <string>ProcessDefinition @@ -22,8 +17,8 @@ </object> <object class="java.awt.geom.Point2D$Double"> <void method="setLocation"> - <double>578.0</double> - <double>131.0</double> + <double>591.0</double> + <double>136.0</double> </void> </object> </void> @@ -78,11 +73,6 @@ metadata</string> </void> </void> - <void property="methods"> - <void property="text"> - <string>createExecution</string> - </void> - </void> <void property="name"> <void property="text"> <string>ProcessInstance</string> @@ -91,8 +81,8 @@ </object> <object class="java.awt.geom.Point2D$Double"> <void method="setLocation"> - <double>577.0</double> - <double>261.0</double> + <double>588.0</double> + <double>284.0</double> </void> </object> </void> @@ -103,11 +93,6 @@ <string>name</string> </void> </void> - <void property="methods"> - <void property="text"> - <string>signal()</string> - </void> - </void> <void property="name"> <void property="text"> <string>Execution</string> @@ -116,8 +101,8 @@ </object> <object class="java.awt.geom.Point2D$Double"> <void method="setLocation"> - <double>586.0</double> - <double>413.0</double> + <double>602.0</double> + <double>437.0</double> </void> </object> </void> Modified: api/trunk/eclipse/jBPMCodeStyle.xml =================================================================== --- api/trunk/eclipse/jBPMCodeStyle.xml 2008-07-03 07:47:31 UTC (rev 1485) +++ api/trunk/eclipse/jBPMCodeStyle.xml 2008-07-03 10:03:26 UTC (rev 1486) @@ -69,7 +69,7 @@ <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="false"/> +<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="true"/> <setting id="org.eclipse.jdt.core.formatter.lineSplit" value="168"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/> @@ -139,7 +139,7 @@ <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment" value="false"/> +<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment" value="true"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="16"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert"/> @@ -185,7 +185,7 @@ <setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16"/> -<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="false"/> +<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="true"/> <setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="168"/> <setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="1"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert"/> Deleted: api/trunk/src/main/java/org/jbpm/api/ContextImpl.java =================================================================== --- api/trunk/src/main/java/org/jbpm/api/ContextImpl.java 2008-07-03 07:47:31 UTC (rev 1485) +++ api/trunk/src/main/java/org/jbpm/api/ContextImpl.java 2008-07-03 10:03:26 UTC (rev 1486) @@ -1,86 +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.jbpm.api; - -//$Id$ - -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -/** - * A general extendible artifact - * - * @author Tho...@jb... - * @since 20-Apr-2007 - */ -class ContextImpl implements Context -{ - private Map<Class, Object> attachments = new HashMap<Class, Object>(); - private Map<String, Object> properties = new HashMap<String, Object>(); - - public Collection<Object> getAttachments() - { - return attachments.values(); - } - - public <T> T getAttachment(Class<T> clazz) - { - return (T)attachments.get(clazz); - } - - public <T> T addAttachment(Class<T> clazz, Object obj) - { - return (T)attachments.put(clazz, obj); - } - - public <T> T removeAttachment(Class<T> key) - { - return (T)attachments.remove(key); - } - - public Set<String> getProperties() - { - return properties.keySet(); - } - - public Object getProperty(String key) - { - return properties.get(key); - } - - public void removeProperty(String key) - { - properties.remove(key); - } - - public void setProperty(String key, Object value) - { - properties.put(key, value); - } - - public void setProperties(Map<String, Object> props) - { - properties.putAll(props); - } -} Added: api/trunk/src/main/java/org/jbpm/api/EngineShutdownException.java =================================================================== --- api/trunk/src/main/java/org/jbpm/api/EngineShutdownException.java (rev 0) +++ api/trunk/src/main/java/org/jbpm/api/EngineShutdownException.java 2008-07-03 10:03:26 UTC (rev 1486) @@ -0,0 +1,42 @@ +/* + * 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; + +// $Id$ + +/** + * A JBPMException that is thrown when an invalid operation is invoked on + * engine shutdown. + * + * @author tho...@jb... + * @since 18-Jun-2008 + */ +public class EngineShutdownException extends JBPMException { + + public EngineShutdownException() { + super(); + } + + public EngineShutdownException(String message) { + super(message); + } +} Property changes on: api/trunk/src/main/java/org/jbpm/api/EngineShutdownException.java ___________________________________________________________________ Name: svn:keywords + Id Revision Name: svn:eol-style + LF Copied: api/trunk/src/main/java/org/jbpm/api/client/ContextImpl.java (from rev 1483, api/trunk/src/main/java/org/jbpm/api/ContextImpl.java) =================================================================== --- api/trunk/src/main/java/org/jbpm/api/client/ContextImpl.java (rev 0) +++ api/trunk/src/main/java/org/jbpm/api/client/ContextImpl.java 2008-07-03 10:03:26 UTC (rev 1486) @@ -0,0 +1,88 @@ +/* + * 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$ + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import org.jbpm.api.Context; + +/** + * A general extendible artifact + * + * @author Tho...@jb... + * @since 20-Apr-2007 + */ +class ContextImpl implements Context +{ + private Map<Class, Object> attachments = new HashMap<Class, Object>(); + private Map<String, Object> properties = new HashMap<String, Object>(); + + public Collection<Object> getAttachments() + { + return attachments.values(); + } + + public <T> T getAttachment(Class<T> clazz) + { + return (T)attachments.get(clazz); + } + + public <T> T addAttachment(Class<T> clazz, Object obj) + { + return (T)attachments.put(clazz, obj); + } + + public <T> T removeAttachment(Class<T> key) + { + return (T)attachments.remove(key); + } + + public Set<String> getProperties() + { + return properties.keySet(); + } + + public Object getProperty(String key) + { + return properties.get(key); + } + + public void removeProperty(String key) + { + properties.remove(key); + } + + public void setProperty(String key, Object value) + { + properties.put(key, value); + } + + public void setProperties(Map<String, Object> props) + { + properties.putAll(props); + } +} Modified: api/trunk/src/main/java/org/jbpm/api/client/EndNode.java =================================================================== --- api/trunk/src/main/java/org/jbpm/api/client/EndNode.java 2008-07-03 07:47:31 UTC (rev 1485) +++ api/trunk/src/main/java/org/jbpm/api/client/EndNode.java 2008-07-03 10:03:26 UTC (rev 1486) @@ -31,10 +31,8 @@ */ public abstract class EndNode extends Node { - - protected EndNode(ProcessDefinition pdef, String name) + protected EndNode(ProcessDefinition pdef) { - super(pdef, name); + super(pdef); } - } \ No newline at end of file Modified: api/trunk/src/main/java/org/jbpm/api/client/Execution.java =================================================================== --- api/trunk/src/main/java/org/jbpm/api/client/Execution.java 2008-07-03 07:47:31 UTC (rev 1485) +++ api/trunk/src/main/java/org/jbpm/api/client/Execution.java 2008-07-03 10:03:26 UTC (rev 1486) @@ -31,42 +31,69 @@ * @author tho...@jb... * @since 18-Jun-2008 */ -public abstract class Execution { +public abstract class Execution +{ + // The associated process instance + private ProcessInstance pinst; - private String name; - private ProcessInstance pinst; - - protected Execution(ProcessInstance pinst, String name) { - + // Construct the execution + protected Execution(ProcessInstance pinst) + { if (pinst == null) throw new IllegalArgumentException("Process instance cannot be null"); - - if (name == null) - name = "AnonymousExecution#" + pinst.getExecutions().size(); this.pinst = pinst; - this.name = name; } - /** Get the associated process instance */ - public ProcessInstance getProcessInstance() { + // Call to initialize fully + protected void init(String name) + { + if (name == null) + { + name = "AnonymousExecution#" + pinst.getExecutions().size(); + setName(name); + } + } + + /* Get the associated process instance */ + public ProcessInstance getProcessInstance() + { return pinst; } - /** Get the name for this execution */ - public String getName() { - return name; - } + /** + * Get the name for the execution + */ + public abstract String getName(); - /** + // Set the name for the execution + protected abstract void setName(String name); + + /* * Get the current node for this execution */ - public abstract Node getNode(); + public final Node getNode() + { + Node node = getNodeOverride(); + return node; + } + /* + * Get the current node for this execution + */ + protected abstract Node getNodeOverride(); - /** + /* * Signal this execution */ - public abstract void signal(); + public final void signal() + { + signalOverride(); + } + /* + * Signal this execution + */ + protected abstract void signalOverride(); + } \ No newline at end of file Copied: api/trunk/src/main/java/org/jbpm/api/client/ExecutionFactory.java (from rev 1483, api/trunk/src/main/java/org/jbpm/api/client/ExecutionManager.java) =================================================================== --- api/trunk/src/main/java/org/jbpm/api/client/ExecutionFactory.java (rev 0) +++ api/trunk/src/main/java/org/jbpm/api/client/ExecutionFactory.java 2008-07-03 10:03:26 UTC (rev 1486) @@ -0,0 +1,74 @@ +/* + * 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: $ + +import org.jbpm.api.EngineShutdownException; + +/** + * The execution manager is the entry point to create, find and otherwise manage process executions. + * + * @author tho...@jb... + * @since 18-Jun-2008 + */ +public abstract class ExecutionFactory +{ + // Injected through the MC + protected ProcessEngine engine; + + /** + * Get the associated process engine + */ + public ProcessEngine getProcessEngine() + { + if (engine == null) + throw new IllegalStateException("ProcessEngine not available through kernel configuration"); + + return engine; + } + + /** + * Locate the execution manager + */ + public static ExecutionFactory locateExecutionManager() + { + ProcessEngine engine = ProcessEngineLocator.locateProcessEngine(); + return engine.getExecutionManager(); + } + + /** + * Create an execution for a given process instance + */ + public final Execution createExecution(ProcessInstance pinst) + { + // TODO: test this + if (engine.isPrepareForShutdown()) + throw new EngineShutdownException("Cannot create new Execution while engine is shutting down"); + + Execution ex = createExecutionOverride(pinst); + return ex; + } + + // Override to implement execution creation + protected abstract Execution createExecutionOverride(ProcessInstance pinst); +} \ No newline at end of file Deleted: api/trunk/src/main/java/org/jbpm/api/client/ExecutionManager.java =================================================================== --- api/trunk/src/main/java/org/jbpm/api/client/ExecutionManager.java 2008-07-03 07:47:31 UTC (rev 1485) +++ api/trunk/src/main/java/org/jbpm/api/client/ExecutionManager.java 2008-07-03 10:03:26 UTC (rev 1486) @@ -1,112 +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.jbpm.api.client; - -// $Id: $ - -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import org.jbpm.api.NameNotUniqueException; - -/** - * The execution manager is the entry point to create, find and otherwise - * manage process executions. - * - * @author tho...@jb... - * @since 18-Jun-2008 - */ -public abstract class ExecutionManager { - - // Injected through the MC - protected ProcessEngine engine; - - // The map of executions - private Map<String, Execution> execs = new HashMap<String, Execution>(); - - /** Get the associated process engine */ - public ProcessEngine getProcessEngine() { - if (engine == null) - throw new IllegalStateException("ProcessEngine not available through kernel configuration"); - - return engine; - } - - /** Locate the execution manager */ - public static ExecutionManager locateExecutionManager() { - ProcessEngine engine = ProcessEngineLocator.locateProcessEngine(); - return engine.getExecutionManager(); - } - - /** - * Create an execution for a given process instance - */ - public abstract Execution createExecution(ProcessInstance pinst); - - /** - * Get the set of registered executions - */ - public Set<Execution> getExecutions() { - return Collections.unmodifiableSet((Set<Execution>) execs.values()); - } - - /** - * Find executions for a given process instance - */ - public Set<Execution> findExecutions(ProcessInstance pinst) { - Set<Execution> subset = new HashSet<Execution>(); - for (Execution ex : execs.values()) - { - if (ex.getProcessInstance() == pinst) - subset.add(ex); - } - return subset; - } - - /** - * Find an execution for a given name - * @return null if the execution is not defined - */ - public Execution findExecution(String name) { - return execs.get(name); - } - - /** - * Remove an execution - */ - public void removeExecution(Execution ex) { - execs.remove(ex.getName()); - } - - // Add an execution - protected void addExecution(Execution ex) { - - String name = ex.getName(); - if (execs.get(name) != null) - throw new NameNotUniqueException("Execution: " + name); - - execs.put(ex.getName(), ex); - } -} \ No newline at end of file Modified: api/trunk/src/main/java/org/jbpm/api/client/Node.java =================================================================== --- api/trunk/src/main/java/org/jbpm/api/client/Node.java 2008-07-03 07:47:31 UTC (rev 1485) +++ api/trunk/src/main/java/org/jbpm/api/client/Node.java 2008-07-03 10:03:26 UTC (rev 1486) @@ -24,43 +24,50 @@ // $Id:$ /** - * Represents a node in the process definition. + * Represents a node in the process definition. A node is an immutable object. The name of a node is unique in the scope of the process definition. * - * A node is an immutable object. - * The name of a node is unique in the scope of the process definition. - * * @author tho...@jb... * @since 18-Jun-2008 */ -public abstract class Node { - +public abstract class Node +{ + // The associated process definition private ProcessDefinition pdef; - private String name; - protected Node(ProcessDefinition pdef, String name) { - + // Construct the node + protected Node(ProcessDefinition pdef) + { if (pdef == null) throw new IllegalArgumentException("Process definition cannot be null"); - - if (name == null) - name = "AnonymousNode#" + pdef.getNodes().size(); this.pdef = pdef; - this.name = name; } + // Call to initialize fully + protected void init(String name) + { + if (name == null) + { + name = "AnonymousNode#" + pdef.getNodes().size(); + setName(name); + } + } + /** Get the associated process definition */ - public ProcessDefinition getProcessDefinition() { + public ProcessDefinition getProcessDefinition() + { return pdef; } /** Get the node name */ - public String getName() { - return name; - } + public abstract String getName(); + // Set the node name + protected abstract void setName(String name); + /** Returns a string representation of the object. */ - public String toString() { - return "Node[" + name + "]"; + public String toString() + { + return "Node[" + getName() + "]"; } } \ No newline at end of file Modified: api/trunk/src/main/java/org/jbpm/api/client/ProcessDefinition.java =================================================================== --- api/trunk/src/main/java/org/jbpm/api/client/ProcessDefinition.java 2008-07-03 07:47:31 UTC (rev 1485) +++ api/trunk/src/main/java/org/jbpm/api/client/ProcessDefinition.java 2008-07-03 10:03:26 UTC (rev 1486) @@ -38,37 +38,40 @@ * @author tho...@jb... * @since 18-Jun-2008 */ -public class ProcessDefinition +public abstract class ProcessDefinition { - - /** The protected name */ - private String name; - /** The protected list of nodes */ + // The list of nodes private List<Node> nodes = new ArrayList<Node>(); + // The set of process instances + private Set<ProcessInstance> pinstSet = new HashSet<ProcessInstance>(); - /** - * Construct the process definition with a given name - */ - protected ProcessDefinition(String name) + // Construct the process definition + protected ProcessDefinition() { + } + + // Call to initialize fully + protected void init(String name) + { if (name == null) { ProcessDefinitionManager pdm = ProcessDefinitionManager.locateProcessDefinitionManager(); name = "AnonymousDef#" + pdm.getProcessDefinitions().size(); + setName(name); } - - this.name = name; } - + /** - * Get the name of this process definition + * Get the name */ - public String getName() - { - return name; - } + public abstract String getName(); - /** Get an unmutable list of node objects */ + // Set the name + protected abstract void setName(String name); + + /** + * Get an unmutable list of node objects + */ public List<Node> getNodes() { return Collections.unmodifiableList(nodes); @@ -88,6 +91,7 @@ * Get the start node for this process definition * * @return The start node + * * @throws InvalidProcessDefinitionException if there is no start node */ public StartNode getStartNode() @@ -134,39 +138,65 @@ } /** - * Create an instance of this process definition. + * Create an instance of this process definition. */ public ProcessInstance createProcessInstance() { ProcessEngine engine = ProcessEngineLocator.locateProcessEngine(); - ProcessInstanceManager pim = engine.getProcessInstanceManager(); + ProcessInstanceFactory pim = engine.getProcessInstanceManager(); ProcessInstance pinst = pim.createProcessInstance(this); return pinst; } /** - * Create an execution for this process definition. - * Note, that this will automatically create a new process instance. + * Get the set of registered process instances */ + public Set<ProcessInstance> getProcessInstances() + { + return Collections.unmodifiableSet(pinstSet); + } + + /** + * Find a ProcessInstance for a given name + * @return null if it cannot be found + */ + public ProcessInstance findProcessInstance(String name) + { + for (ProcessInstance pinst : pinstSet) + { + if (pinst.getName() == name) + return pinst; + } + return null; + } + + /** + * Remove a ProcessInstance for a given name + */ + public void removeProcessInstance(String name) + { + for (ProcessInstance pinst : pinstSet) + { + if (pinst.getName() == name) + { + pinstSet.remove(pinst); + break; + } + } + } + + /* + * Create an execution for this process definition. Note, that this will automatically create a new process instance. + */ public Execution createExecution() { ProcessEngine engine = ProcessEngineLocator.locateProcessEngine(); - ProcessInstanceManager pim = engine.getProcessInstanceManager(); + ProcessInstanceFactory pim = engine.getProcessInstanceManager(); ProcessInstance pinst = pim.createProcessInstance(this); - ExecutionManager pem = engine.getExecutionManager(); + ExecutionFactory pem = engine.getExecutionManager(); return pem.createExecution(pinst); } - /** - * Get the process instances associated with this process definition - */ - public Set<ProcessInstance> getProcessInstances() - { - ProcessInstanceManager pim = ProcessInstanceManager.locateProcessInstanceManager(); - Set<ProcessInstance> pinsts = pim.findProcessInstances(this); - return pinsts; - } - // private private StartNode getStartNodeInternal() Modified: api/trunk/src/main/java/org/jbpm/api/client/ProcessDefinitionManager.java =================================================================== --- api/trunk/src/main/java/org/jbpm/api/client/ProcessDefinitionManager.java 2008-07-03 07:47:31 UTC (rev 1485) +++ api/trunk/src/main/java/org/jbpm/api/client/ProcessDefinitionManager.java 2008-07-03 10:03:26 UTC (rev 1486) @@ -29,6 +29,8 @@ import java.util.HashSet; import java.util.Set; +import org.jbpm.api.EngineShutdownException; + /** * The process definition manager is the entry point to create, find and otherwise manage process definitions. * @@ -43,7 +45,7 @@ // The set of process definitions private Set<ProcessDefinition> pdefs = new HashSet<ProcessDefinition>(); - /** Get the associated process engine */ + /* Get the associated process engine */ public ProcessEngine getProcessEngine() { if (engine == null) @@ -52,24 +54,50 @@ return engine; } - /** Locate the process definition manager */ + /* Locate the process definition manager */ public static ProcessDefinitionManager locateProcessDefinitionManager() { ProcessEngine engine = ProcessEngineLocator.locateProcessEngine(); return engine.getProcessDefinitionManager(); } - /** + /* * Create a process defintion from a XML string in one of the supported formats */ - public abstract ProcessDefinition createProcessDefinition(String pdDescriptor); + public final ProcessDefinition createProcessDefinition(String pdDescriptor) + { + // TODO: test this + if (engine.isPrepareForShutdown()) + throw new EngineShutdownException("Cannot create new ProcessDefinition while engine is shutting down"); + + ProcessDefinition pd = createProcessDefinitionOverride(pdDescriptor); + return pd; + } - /** + /* + * Override to implement process definition creation + */ + protected abstract ProcessDefinition createProcessDefinitionOverride(String pdDescriptor); + + /* * Create a process defintion from an URL to a XML descritor in one of the supported formats */ - public abstract ProcessDefinition createProcessDefinition(URL pdURL) throws IOException; + public final ProcessDefinition createProcessDefinition(URL pdURL) throws IOException + { + // TODO: test this + if (engine.isPrepareForShutdown()) + throw new EngineShutdownException("Cannot create new ProcessDefinition while engine is shutting down"); + + ProcessDefinition pd = createProcessDefinitionOverride(pdURL); + return pd; + } - /** + /* + * Override to implement process definition creation + */ + protected abstract ProcessDefinition createProcessDefinitionOverride(URL pdURL) throws IOException; + + /* * Get the set of registered process definitions */ public Set<ProcessDefinition> getProcessDefinitions() @@ -77,7 +105,7 @@ return Collections.unmodifiableSet(pdefs); } - /** + /* * Find a process definition for a given name * * @return null if the process definition is not defined @@ -96,20 +124,11 @@ return pdef; } - /** + /* * Remove a process definition and all its associated process instances */ public void removeProcessDefinition(ProcessDefinition pdef) { - - // Remove the process instances - ProcessInstanceManager pim = engine.getProcessInstanceManager(); - Set<ProcessInstance> subset = pim.findProcessInstances(pdef); - for (ProcessInstance pinst : subset) - { - pim.removeProcessInstance(pinst); - } - // Remove the preocess definition pdefs.remove(pdef.getName()); } Modified: api/trunk/src/main/java/org/jbpm/api/client/ProcessEngine.java =================================================================== --- api/trunk/src/main/java/org/jbpm/api/client/ProcessEngine.java 2008-07-03 07:47:31 UTC (rev 1485) +++ api/trunk/src/main/java/org/jbpm/api/client/ProcessEngine.java 2008-07-03 10:03:26 UTC (rev 1486) @@ -39,10 +39,27 @@ // Injected through the MC protected ProcessDefinitionManager processDefinitionManager; // Injected through the MC - protected ProcessInstanceManager processInstanceManager; + protected ProcessInstanceFactory processInstanceManager; // Injected through the MC - protected ExecutionManager executionManager; + protected ExecutionFactory executionManager; + // Flag to indicate that the Engine is shutting down + private boolean prepareForShutdown; + public void prepareForShutdown() + { + prepareForShutdown = true; + } + + public boolean isPrepareForShutdown() + { + return prepareForShutdown; + } + + public void cancelShutdown() + { + prepareForShutdown = false; + } + /** * Get the configured instance of the process definition manager * @return The process definition manager @@ -58,7 +75,7 @@ * Get the configured instance of the process instance manager * @return The process instance manager */ - public ProcessInstanceManager getProcessInstanceManager() { + public ProcessInstanceFactory getProcessInstanceManager() { if (processInstanceManager == null) throw new IllegalStateException("ProcessInstanceManager not available through kernel configuration"); @@ -69,7 +86,7 @@ * Get the configured instance of the execution manager * @return The execution manager */ - public ExecutionManager getExecutionManager() { + public ExecutionFactory getExecutionManager() { if (executionManager == null) throw new IllegalStateException("ExecutionManager not available through kernel configuration"); Modified: api/trunk/src/main/java/org/jbpm/api/client/ProcessInstance.java =================================================================== --- api/trunk/src/main/java/org/jbpm/api/client/ProcessInstance.java 2008-07-03 07:47:31 UTC (rev 1485) +++ api/trunk/src/main/java/org/jbpm/api/client/ProcessInstance.java 2008-07-03 10:03:26 UTC (rev 1486) @@ -21,40 +21,101 @@ */ package org.jbpm.api.client; +// $Id: $ + +import java.util.Collections; +import java.util.HashSet; import java.util.Set; -// $Id: $ - /** - * Represents an instance of a BPM process. + * Represents an instance of a BPM process. It is the combination of a process definition plus its associated instance data * - * It is the combination of a process definition plus its associated instance data - * * @author tho...@jb... * @since 18-Jun-2008 */ -public abstract class ProcessInstance { +public abstract class ProcessInstance +{ + // The process definition + private ProcessDefinition pdef; + // The name + private String name; + // The map of executions + private Set<Execution> execs = new HashSet<Execution>(); - private ProcessDefinition pdef; - - /** Construct a process instance with a given process definition */ - protected ProcessInstance(ProcessDefinition pdef) { + // Construct a process instance with a given process definition + protected ProcessInstance(ProcessDefinition pdef) + { if (pdef == null) throw new IllegalArgumentException("Process definition cannot be null"); + this.pdef = pdef; } - /** Get the associated process definition */ - public ProcessDefinition getProcessDefinition() { - return pdef; + // Call to initialize fully + protected void init(String name) + { + if (name == null) + { + name = "AnonymousInst#" + pdef.getProcessInstances().size(); + setName(name); + } } - /** - * Get the executions associated with this process instance + /** + * Get the associated process definition */ - public Set<Execution> getExecutions() { - ExecutionManager exm = ExecutionManager.locateExecutionManager(); - Set<Execution> execs = exm.findExecutions(this); - return execs; + public ProcessDefinition getProcessDefinition() + { + return pdef; } + + /** + * Get the name of this process instance + */ + public String getName() + { + return name; + } + + private void setName(String name) + { + this.name = name; + } + + /** + * Get the set of registered executions + */ + public Set<Execution> getExecutions() + { + return Collections.unmodifiableSet(execs); + } + + /** + * Find an execution for a given name + * + * @return null if it cannot be found + */ + public Execution findExecution(String name) + { + for (Execution ex : execs) + { + if (ex.getName() == name) + return ex; + } + return null; + } + + /** + * Remove an execution for a given name + */ + public void removeExecution(String name) + { + for (Execution ex : execs) + { + if (ex.getName() == name) + { + execs.remove(ex); + } + } + } } \ No newline at end of file Copied: api/trunk/src/main/java/org/jbpm/api/client/ProcessInstanceFactory.java (from rev 1483, api/trunk/src/main/java/org/jbpm/api/client/ProcessInstanceManager.java) =================================================================== --- api/trunk/src/main/java/org/jbpm/api/client/ProcessInstanceFactory.java (rev 0) +++ api/trunk/src/main/java/org/jbpm/api/client/ProcessInstanceFactory.java 2008-07-03 10:03:26 UTC (rev 1486) @@ -0,0 +1,79 @@ +/* + * 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: $ + +import org.jbpm.api.EngineShutdownException; + +/** + * The process instance manager is the entry point to create, find and otherwise + * manage process instances. + * + * @author tho...@jb... + * @since 18-Jun-2008 + */ +public abstract class ProcessInstanceFactory +{ + + // Injected through the MC + protected ProcessEngine engine; + + /* Get the associated process engine */ + public ProcessEngine getProcessEngine() + { + if (engine == null) + throw new IllegalStateException("ProcessEngine not available through kernel configuration"); + + return engine; + } + + /* Locate the process instance manager */ + public static ProcessInstanceFactory locateProcessInstanceManager() + { + ProcessEngine engine = ProcessEngineLocator.locateProcessEngine(); + return engine.getProcessInstanceManager(); + } + + /* + * Create a process instance for a given process definition + * + * @param pd The process definition + * + * @return A process instance + */ + public final ProcessInstance createProcessInstance(ProcessDefinition pdef) + { + // TODO: test this + if (engine.isPrepareForShutdown()) + throw new EngineShutdownException("Cannot create new ProcessInstance while engine is shutting down"); + + ProcessInstance pinst = createProcessInstanceOverride(pdef); + return pinst; + } + + /* + * Override to implement process instance creation + */ + protected abstract ProcessInstance createProcessInstanceOverride(ProcessDefinition pdef); + +} Deleted: api/trunk/src/main/java/org/jbpm/api/client/ProcessInstanceManager.java =================================================================== --- api/trunk/src/main/java/org/jbpm/api/client/ProcessInstanceManager.java 2008-07-03 07:47:31 UTC (rev 1485) +++ api/trunk/src/main/java/org/jbpm/api/client/ProcessInstanceManager.java 2008-07-03 10:03:26 UTC (rev 1486) @@ -1,106 +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.jbpm.api.client; - -//$Id: $ - -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - -/** - * The process instance manager is the entry point to create, find and otherwise - * manage process instances. - * - * @author tho...@jb... - * @since 18-Jun-2008 - */ -public abstract class ProcessInstanceManager { - - // Injected through the MC - protected ProcessEngine engine; - - // The set of process instances - private Set<ProcessInstance> pinstSet = new HashSet<ProcessInstance>(); - - /** Get the associated process engine */ - public ProcessEngine getProcessEngine() { - if (engine == null) - throw new IllegalStateException("ProcessEngine not available through kernel configuration"); - - return engine; - } - - /** Locate the process instance manager */ - public static ProcessInstanceManager locateProcessInstanceManager() { - ProcessEngine engine = ProcessEngineLocator.locateProcessEngine(); - return engine.getProcessInstanceManager(); - } - - /** - * Create a process instance for a given process definition - * @param pd The process definition - * @return A process instance - */ - public abstract ProcessInstance createProcessInstance(ProcessDefinition pdef); - - /** - * Get the set of registered process instances - */ - public Set<ProcessInstance> getProcessInstances() { - return Collections.unmodifiableSet(pinstSet); - } - - /** - * Get the set of registered process instances for a given process definition - */ - public Set<ProcessInstance> findProcessInstances(ProcessDefinition pdef) { - Set<ProcessInstance> subset = new HashSet<ProcessInstance>(); - for (ProcessInstance pinst : pinstSet) - { - if (pinst.getProcessDefinition() == pdef) - subset.add(pinst); - } - return subset; - } - - /** - * Remove a process instances and all its associated process executions - */ - public void removeProcessInstance(ProcessInstance pinst) { - // Remove executions - ExecutionManager exm = engine.getExecutionManager(); - Set<Execution> execs = exm.findExecutions(pinst); - for (Execution ex : execs) - { - exm.removeExecution(ex); - } - - // Remove process instance - pinstSet.remove(pinst); - } - - // Add a process instance - protected void addProcessInstance(ProcessInstance pinst) { - pinstSet.add(pinst); - } -} Modified: api/trunk/src/main/java/org/jbpm/api/client/StartNode.java =================================================================== --- api/trunk/src/main/java/org/jbpm/api/client/StartNode.java 2008-07-03 07:47:31 UTC (rev 1485) +++ api/trunk/src/main/java/org/jbpm/api/client/StartNode.java 2008-07-03 10:03:26 UTC (rev 1486) @@ -29,10 +29,10 @@ * @author tho...@jb... * @since 18-Jun-2008 */ -public abstract class StartNode extends Node { - - protected StartNode(ProcessDefinition pdef, String name) { - super(pdef, name); +public abstract class StartNode extends Node +{ + protected StartNode(ProcessDefinition pdef) + { + super(pdef); } - } \ No newline at end of file Modified: api/trunk/src/test/java/org/jbpm/api/client/MockProcessEngine.java =================================================================== --- api/trunk/src/test/java/org/jbpm/api/client/MockProcessEngine.java 2008-07-03 07:47:31 UTC (rev 1485) +++ api/trunk/src/test/java/org/jbpm/api/client/MockProcessEngine.java 2008-07-03 10:03:26 UTC (rev 1486) @@ -23,10 +23,10 @@ //$Id$ -import org.jbpm.api.client.ExecutionManager; +import org.jbpm.api.client.ExecutionFactory; import org.jbpm.api.client.ProcessDefinitionManager; import org.jbpm.api.client.ProcessEngine; -import org.jbpm.api.client.ProcessInstanceManager; +import org.jbpm.api.client.ProcessInstanceFactory; /** * A process engine with public access @@ -40,11 +40,11 @@ this.processDefinitionManager = processDefinitionManager; } - public void setProcessInstanceManager(ProcessInstanceManager processInstanceManager) { + public void setProcessInstanceManager(ProcessInstanceFactory processInstanceManager) { this.processInstanceManager = processInstanceManager; } - public void setExecutionManager(ExecutionManager executionManager) { + public void setExecutionManager(ExecutionFactory executionManager) { this.executionManager = executionManager; } } \ No newline at end of file Modified: api/trunk/src/test/java/org/jbpm/api/client/ProcessDefinitionTest.java =================================================================== --- api/trunk/src/test/java/org/jbpm/api/client/ProcessDefinitionTest.java 2008-07-03 07:47:31 UTC (rev 1485) +++ api/trunk/src/test/java/org/jbpm/api/client/ProcessDefinitionTest.java 2008-07-03 10:03:26 UTC (rev 1486) @@ -85,7 +85,7 @@ } catch (InvalidProcessDefinitionException ex) { - assertTrue("Unexpected message: " + ex.getMessage(), ex.getMessage().indexOf("start state") > 0); + assertTrue("Unexpected message: " + ex.getMessage(), ex.getMessage().indexOf("start node") > 0); } } @@ -110,7 +110,7 @@ } catch (InvalidProcessDefinitionException ex) { - assertTrue("Unexpected message: " + ex.getMessage(), ex.getMessage().indexOf("end state") > 0); + assertTrue("Unexpected message: " + ex.getMessage(), ex.getMessage().indexOf("end node") > 0); } } Modified: api/trunk/src/test/java/org/jbpm/api/samples/basic/BasicSequenceTest.java =================================================================== --- api/trunk/src/test/java/org/jbpm/api/samples/basic/BasicSequenceTest.java 2008-07-03 07:47:31 UTC (rev 1485) +++ api/trunk/src/test/java/org/jbpm/api/samples/basic/BasicSequenceTest.java 2008-07-03 10:03:26 UTC (rev 1486) @@ -25,13 +25,13 @@ import org.jbpm.api.DefaultEngineTestCase; import org.jbpm.api.client.Execution; -import org.jbpm.api.client.ExecutionManager; +import org.jbpm.api.client.ExecutionFactory; import org.jbpm.api.client.ProcessDefinition; import org.jbpm.api.client.ProcessDefinitionManager; import org.jbpm.api.client.ProcessEngine; import org.jbpm.api.client.ProcessEngineLocator; import org.jbpm.api.client.ProcessInstance; -import org.jbpm.api.client.ProcessInstanceManager; +import org.jbpm.api.client.ProcessInstanceFactory; public class BasicSequenceTest extends DefaultEngineTestCase { @@ -57,11 +57,11 @@ ProcessDefinition pd = pdm.createProcessDefinition(jpdl); // Create a ProcessInstance through the ProcessInstanceManager - ProcessInstanceManager pim = engine.getProcessInstanceManager(); + ProcessInstanceFactory pim = engine.getProcessInstanceManager(); ProcessInstance pi = pim.createProcessInstance(pd); // Create an Execution through the ExecutionManager - ExecutionManager pem = engine.getExecutionManager(); + ExecutionFactory pem = engine.getExecutionManager(); Execution ex = pem.createExecution(pi); // Signal the execution @@ -79,7 +79,7 @@ // Create an Execution through the ProcessDefinition Execution ex = pd.createExecution(); - assertEquals(ex.getNode(), pd.getStartState()); + assertEquals(pd.getStartNode(), ex.getNode()); // Signal the execution ex.signal(); @@ -90,6 +90,6 @@ // Signal the execution ex.signal(); - assertEquals(ex.getNode(), null); + assertEquals(pd.findNode("end"), ex.getNode()); } } |
From: <do-...@jb...> - 2008-07-03 07:47:34
|
Author: tho...@jb... Date: 2008-07-03 03:47:31 -0400 (Thu, 03 Jul 2008) New Revision: 1485 Added: api/trunk/eclipse/ Modified: api/trunk/src/test/java/org/jbpm/api/samples/basic/BasicSequenceTest.java Log: Add code style Copied: api/trunk/eclipse (from rev 1484, jbpm3/trunk/eclipse) Modified: api/trunk/src/test/java/org/jbpm/api/samples/basic/BasicSequenceTest.java =================================================================== --- api/trunk/src/test/java/org/jbpm/api/samples/basic/BasicSequenceTest.java 2008-07-03 07:09:20 UTC (rev 1484) +++ api/trunk/src/test/java/org/jbpm/api/samples/basic/BasicSequenceTest.java 2008-07-03 07:47:31 UTC (rev 1485) @@ -26,7 +26,6 @@ import org.jbpm.api.DefaultEngineTestCase; import org.jbpm.api.client.Execution; import org.jbpm.api.client.ExecutionManager; -import org.jbpm.api.client.Node; import org.jbpm.api.client.ProcessDefinition; import org.jbpm.api.client.ProcessDefinitionManager; import org.jbpm.api.client.ProcessEngine; @@ -34,8 +33,8 @@ import org.jbpm.api.client.ProcessInstance; import org.jbpm.api.client.ProcessInstanceManager; -public class BasicSequenceTest extends DefaultEngineTestCase { - +public class BasicSequenceTest extends DefaultEngineTestCase +{ String jpdl = "<process-definition>" + " <start-state>" + @@ -47,15 +46,16 @@ " <end-state name='end' />" + "</process-definition>"; - public void testBasicSequence() throws Exception { + public void testBasicSequence() throws Exception + { // Locate the ProcessEngine ProcessEngine engine = ProcessEngineLocator.locateProcessEngine(); - + // Create a ProcessDefinition through the ProcessDefinitionManager ProcessDefinitionManager pdm = engine.getProcessDefinitionManager(); ProcessDefinition pd = pdm.createProcessDefinition(jpdl); - + // Create a ProcessInstance through the ProcessInstanceManager ProcessInstanceManager pim = engine.getProcessInstanceManager(); ProcessInstance pi = pim.createProcessInstance(pd); @@ -63,14 +63,12 @@ // Create an Execution through the ExecutionManager ExecutionManager pem = engine.getExecutionManager(); Execution ex = pem.createExecution(pi); - + // Signal the execution ex.signal(); // Verify the nodes - Node expNode = pd.findNode("stateA"); - Node wasNode = ex.getNode(); - assertEquals(expNode.getName(), wasNode.getName()); + assertEquals(pd.findNode("stateA"), ex.getNode()); } public void testBasicSequenceShortcut() throws Exception { @@ -81,15 +79,17 @@ // Create an Execution through the ProcessDefinition Execution ex = pd.createExecution(); + assertEquals(ex.getNode(), pd.getStartState()); // Signal the execution ex.signal(); // Verify the nodes - Node expNode = pd.findNode("stateA"); - Node wasNode = ex.getNode(); - assertEquals(expNode, wasNode); - assertEquals(expNode.getName(), wasNode.getName()); + assertEquals(pd.findNode("stateA"), ex.getNode()); + + // Signal the execution + ex.signal(); + + assertEquals(ex.getNode(), null); } - } |
From: <do-...@jb...> - 2008-07-03 07:09:23
|
Author: ale...@jb... Date: 2008-07-03 03:09:20 -0400 (Thu, 03 Jul 2008) New Revision: 1484 Modified: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java Log: added maxIdleInterval check, removed unused fields Modified: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java =================================================================== --- jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java 2008-07-03 06:55:23 UTC (rev 1483) +++ jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java 2008-07-03 07:09:20 UTC (rev 1484) @@ -36,17 +36,14 @@ this.idleInterval = idleInterval; this.maxIdleInterval = maxIdleInterval; this.maxLockTime = maxLockTime; - this.maxHistory = maxHistory; } - JobExecutor jobExecutor; - JbpmConfiguration jbpmConfiguration; - int idleInterval; - int maxIdleInterval; - long maxLockTime; - int maxHistory; + final JobExecutor jobExecutor; + final JbpmConfiguration jbpmConfiguration; + final int idleInterval; + final int maxIdleInterval; + final long maxLockTime; - Collection history = new ArrayList(); int currentIdleInterval; volatile boolean isActive = true; @@ -91,7 +88,10 @@ } // after an exception, the current idle interval is doubled to prevent // continuous exception generation when e.g. the db is unreachable - currentIdleInterval = currentIdleInterval*2; + currentIdleInterval <<= 1; + if (currentIdleInterval > maxIdleInterval || currentIdleInterval < 0) { + currentIdleInterval = maxIdleInterval; + } } } } catch (Exception e) { |