[jbpm-commits] JBoss JBPM SVN: r1591 - in api/trunk/modules: api/src/main/java/org/jboss/bpm/client/internal and 3 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Fri Jul 11 12:01:30 EDT 2008
Author: thomas.diesler at jboss.com
Date: 2008-07-11 12:01:29 -0400 (Fri, 11 Jul 2008)
New Revision: 1591
Added:
api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ExecutionManager.java
api/trunk/modules/api/src/main/java/org/jboss/bpm/client/internal/InitialToken.java
api/trunk/modules/api/src/main/java/org/jboss/bpm/client/internal/ProcessEngineImpl.java
api/trunk/modules/api/src/main/java/org/jboss/bpm/client/internal/SignalManagerImpl.java
api/trunk/modules/api/src/main/java/org/jboss/bpm/model/ExecutableFlowObject.java
Removed:
api/trunk/modules/api/src/main/java/org/jboss/bpm/model/InitialToken.java
Modified:
api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessEngine.java
api/trunk/modules/api/src/main/java/org/jboss/bpm/model/EndEvent.java
api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Event.java
api/trunk/modules/api/src/main/java/org/jboss/bpm/model/FlowObject.java
api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Gateway.java
api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Process.java
api/trunk/modules/api/src/main/java/org/jboss/bpm/model/SubProcess.java
api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Task.java
api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/context/TaskA.java
api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/task/TaskA.java
Log:
Delegate to ExecutionManager
Added: api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ExecutionManager.java
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ExecutionManager.java (rev 0)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ExecutionManager.java 2008-07-11 16:01:29 UTC (rev 1591)
@@ -0,0 +1,168 @@
+/*
+ * 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.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.bpm.NotImplementedException;
+import org.jboss.bpm.client.internal.InitialToken;
+import org.jboss.bpm.model.EndEvent;
+import org.jboss.bpm.model.ExecutableFlowObject;
+import org.jboss.bpm.model.FlowObject;
+import org.jboss.bpm.model.Process;
+import org.jboss.bpm.model.Result;
+import org.jboss.bpm.model.Signal;
+import org.jboss.bpm.runtime.Attachments;
+import org.jboss.bpm.runtime.Token;
+
+/**
+ * The process manager is the entry point to create, find and otherwise manage processes.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 18-Jun-2008
+ */
+public abstract class ExecutionManager
+{
+ // provide logging
+ private static final Log log = LogFactory.getLog(ExecutionManager.class);
+
+ // Injected through the MC
+ protected ProcessEngine engine;
+
+ // Hide public constructor
+ protected ExecutionManager()
+ {
+ }
+
+ /**
+ * Locate the signal manager
+ */
+ public static ExecutionManager locateExecutionManager()
+ {
+ ProcessEngine engine = ProcessEngineLocator.locateProcessEngine();
+ return engine.getExecutionManager();
+ }
+
+ public Future<Result> startProcess(Process proc, Attachments att)
+ {
+ throwSignal(new Signal(proc, Signal.Type.ENTER_PROCESS));
+ try
+ {
+ FlowObject fo = proc.getStartEvent();
+ ExecutableFlowObject exfo = getExecutable(fo);
+ Token token = new InitialToken(proc, att);
+
+ boolean hasEnded = false;
+ while(hasEnded == false)
+ {
+ try
+ {
+ throwSignal(exfo.getEnterSignal());
+ exfo.execute(token);
+ }
+ finally
+ {
+ throwSignal(exfo.getExitSignal());
+ }
+ }
+ }
+ finally
+ {
+ throwSignal(new Signal(proc, Signal.Type.EXIT_PROCESS));
+ }
+ return new ResultFuture(proc);
+ }
+
+ protected ExecutableFlowObject getExecutable(FlowObject fo)
+ {
+ if (fo instanceof ExecutableFlowObject == false)
+ throw new IllegalStateException("Flow object is not executable: " + fo);
+
+ return (ExecutableFlowObject)fo;
+ }
+
+ protected void throwSignal(Signal signal)
+ {
+ SignalManager sm = SignalManager.locateSignalManager();
+ sm.throwSignal(signal);
+ }
+
+ public class ResultFuture implements Future<Result>
+ {
+ private Result result;
+ private Process proc;
+
+ public ResultFuture(Process proc)
+ {
+ this.proc = proc;
+ }
+
+ public boolean cancel(boolean mayInterruptIfRunning)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Result get() throws InterruptedException, ExecutionException
+ {
+ return getResult();
+ }
+
+ public Result get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
+ {
+ throw new NotImplementedException();
+ }
+
+ public boolean isCancelled()
+ {
+ return false;
+ }
+
+ public boolean isDone()
+ {
+ boolean isDone = getResult() != null;
+ return isDone;
+ }
+
+ private Result getResult()
+ {
+ if (result == null)
+ {
+ for (EndEvent aux : proc.getEndEvents())
+ {
+ result = aux.getResult();
+ if (result != null)
+ {
+ break;
+ }
+ }
+ }
+ return result;
+ }
+ }
+}
\ No newline at end of file
Property changes on: api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ExecutionManager.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: 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 2008-07-11 14:21:35 UTC (rev 1590)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessEngine.java 2008-07-11 16:01:29 UTC (rev 1591)
@@ -36,9 +36,12 @@
/** The default bean config: jbpm-beans.xml */
public static final String JBPM_ENGINE_CONFIG = "jbpm-beans.xml";
+ // Injected through the MC
protected ProcessManager processManager;
// Injected through the MC
protected SignalManager signalManager;
+ // Injected through the MC
+ protected ExecutionManager executionManager;
// Flag to indicate that the Engine is shutting down
private boolean prepareForShutdown;
@@ -72,8 +75,8 @@
}
/**
- * Get the configured instance of the process manager
- * @return The process manager
+ * Get the configured instance of the ProcessManager
+ * @return The ProcessManager
*/
public ProcessManager getProcessManager()
{
@@ -84,8 +87,8 @@
}
/**
- * Get the configured instance of the signal manager
- * @return The signal manager
+ * Get the configured instance of the SignalManager
+ * @return The SignalManager
*/
public SignalManager getSignalManager()
{
@@ -94,4 +97,16 @@
return signalManager;
}
+
+ /**
+ * Get the configured instance of the ExecutionManager
+ * @return The ExecutionManager
+ */
+ public ExecutionManager getExecutionManager()
+ {
+ if (executionManager == null)
+ throw new IllegalStateException("ExecutionManager not available through kernel configuration");
+
+ return executionManager;
+ }
}
\ No newline at end of file
Added: api/trunk/modules/api/src/main/java/org/jboss/bpm/client/internal/InitialToken.java
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/client/internal/InitialToken.java (rev 0)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/client/internal/InitialToken.java 2008-07-11 16:01:29 UTC (rev 1591)
@@ -0,0 +1,66 @@
+/*
+ * 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.model.Process;
+import org.jboss.bpm.runtime.Attachments;
+import org.jboss.bpm.runtime.BasicAttachments;
+import org.jboss.bpm.runtime.ExecutionContext;
+import org.jboss.bpm.runtime.Token;
+
+/**
+ * An initial token
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+public class InitialToken implements Token
+{
+ private Process proc;
+ private ExecutionContext context;
+
+ public InitialToken(Process proc, Attachments att)
+ {
+ this.proc = proc;
+ this.context = new InitialContext(att);
+ }
+
+ public Process getProcess()
+ {
+ return proc;
+ }
+
+ public ExecutionContext getExecutionContext()
+ {
+ return context;
+ }
+
+ static class InitialContext extends BasicAttachments implements ExecutionContext
+ {
+ InitialContext(Attachments att)
+ {
+ super(att);
+ }
+ }
+}
\ No newline at end of file
Added: api/trunk/modules/api/src/main/java/org/jboss/bpm/client/internal/ProcessEngineImpl.java
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/client/internal/ProcessEngineImpl.java (rev 0)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/client/internal/ProcessEngineImpl.java 2008-07-11 16:01:29 UTC (rev 1591)
@@ -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.jboss.bpm.client.internal;
+
+//$Id$
+
+import org.jboss.bpm.client.ExecutionManager;
+import org.jboss.bpm.client.ProcessEngine;
+import org.jboss.bpm.client.ProcessManager;
+import org.jboss.bpm.client.SignalManager;
+
+/**
+ * A process engine with public access
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 18-Jun-2008
+ */
+public class ProcessEngineImpl extends ProcessEngine
+{
+ public void setProcessManager(ProcessManager processManager)
+ {
+ this.processManager = processManager;
+ }
+
+ public void setExecutionManager(ExecutionManager executionManager)
+ {
+ this.executionManager = executionManager;
+ }
+
+ public void setSignalManager(SignalManager signalManager)
+ {
+ this.signalManager = signalManager;
+ }
+}
Property changes on: api/trunk/modules/api/src/main/java/org/jboss/bpm/client/internal/ProcessEngineImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: api/trunk/modules/api/src/main/java/org/jboss/bpm/client/internal/SignalManagerImpl.java
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/client/internal/SignalManagerImpl.java (rev 0)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/client/internal/SignalManagerImpl.java 2008-07-11 16:01:29 UTC (rev 1591)
@@ -0,0 +1,48 @@
+/*
+ * 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.client.ProcessEngine;
+import org.jboss.bpm.client.SignalManager;
+import org.jboss.bpm.model.Signal;
+
+/**
+ * An implementation of a signal manager
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 18-Jun-2008
+ */
+public class SignalManagerImpl extends SignalManager
+{
+ public void setProcessEngine(ProcessEngine engine)
+ {
+ this.engine = engine;
+ }
+
+ @Override
+ public void throwSignal(Signal signal)
+ {
+ super.throwSignal(signal);
+ }
+}
Property changes on: api/trunk/modules/api/src/main/java/org/jboss/bpm/client/internal/SignalManagerImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/model/EndEvent.java
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/model/EndEvent.java 2008-07-11 14:21:35 UTC (rev 1590)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/model/EndEvent.java 2008-07-11 16:01:29 UTC (rev 1591)
@@ -100,11 +100,8 @@
return new Signal(getProcess(), Signal.Type.EXIT_END_EVENT);
}
- @Override
public void execute(final Token token)
{
- super.execute(token);
-
// Provide the result
result = new Result()
{
Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Event.java
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Event.java 2008-07-11 14:21:35 UTC (rev 1590)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Event.java 2008-07-11 16:01:29 UTC (rev 1591)
@@ -35,7 +35,7 @@
* @since 08-Jul-2008
*/
@XmlType(name="Event")
-public abstract class Event extends AbstractEvent
+public abstract class Event extends AbstractEvent implements ExecutableFlowObject
{
/**
* Construct an anonymous StartEvent.
Added: api/trunk/modules/api/src/main/java/org/jboss/bpm/model/ExecutableFlowObject.java
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/model/ExecutableFlowObject.java (rev 0)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/model/ExecutableFlowObject.java 2008-07-11 16:01:29 UTC (rev 1591)
@@ -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.model;
+
+import org.jboss.bpm.runtime.Token;
+
+//$Id$
+
+/**
+ * Implement to make the FlowObject executable
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+public interface ExecutableFlowObject
+{
+ /**
+ * Get signal for enter
+ */
+ Signal getEnterSignal();
+
+ /**
+ * Get signal for exit
+ */
+ Signal getExitSignal();
+
+ /**
+ * Execute this flow object
+ */
+ void execute(Token token);
+}
\ No newline at end of file
Property changes on: api/trunk/modules/api/src/main/java/org/jboss/bpm/model/ExecutableFlowObject.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/model/FlowObject.java
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/model/FlowObject.java 2008-07-11 14:21:35 UTC (rev 1590)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/model/FlowObject.java 2008-07-11 16:01:29 UTC (rev 1591)
@@ -21,12 +21,9 @@
*/
package org.jboss.bpm.model;
-import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
import org.jboss.bpm.InvalidProcessException;
-import org.jboss.bpm.client.SignalManager;
-import org.jboss.bpm.runtime.Token;
//$Id$
@@ -134,42 +131,4 @@
{
return super.getProcess();
}
-
- /**
- * Get signal for enter
- */
- @XmlTransient
- public abstract Signal getEnterSignal();
-
- /**
- * Get signal for exit
- */
- @XmlTransient
- public abstract Signal getExitSignal();
-
- /**
- * Execute this flow object
- */
- public void execute(Token token)
- {
- SignalManager sm = SignalManager.locateSignalManager();
- try
- {
- sm.throwSignal(getEnterSignal());
- executeOverwrite(token);
- }
- finally
- {
- sm.throwSignal(getExitSignal());
- }
- }
-
- /**
- * Overwrite to provide an actual implemenation
- * Note, this MUST NOT leak into the public API.
- */
- protected void executeOverwrite(Token token)
- {
- // nothing to do
- }
}
\ No newline at end of file
Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Gateway.java
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Gateway.java 2008-07-11 14:21:35 UTC (rev 1590)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Gateway.java 2008-07-11 16:01:29 UTC (rev 1591)
@@ -38,7 +38,7 @@
* @since 08-Jul-2008
*/
@XmlType(name="Gateway")
-public abstract class Gateway extends AbstractGateway implements NamedFlowObject
+public abstract class Gateway extends AbstractGateway implements NamedFlowObject, ExecutableFlowObject
{
@XmlTransient
protected List<Flow> inFlows = new ArrayList<Flow>();
Deleted: api/trunk/modules/api/src/main/java/org/jboss/bpm/model/InitialToken.java
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/model/InitialToken.java 2008-07-11 14:21:35 UTC (rev 1590)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/model/InitialToken.java 2008-07-11 16:01:29 UTC (rev 1591)
@@ -1,69 +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.model;
-
-// $Id$
-
-import javax.xml.bind.annotation.XmlTransient;
-
-import org.jboss.bpm.runtime.Attachments;
-import org.jboss.bpm.runtime.BasicAttachments;
-import org.jboss.bpm.runtime.ExecutionContext;
-import org.jboss.bpm.runtime.Token;
-
-/**
- * An initial token
- *
- * @author thomas.diesler at jboss.com
- * @since 08-Jul-2008
- */
- at XmlTransient
-class InitialToken implements Token
-{
- private Process proc;
- private ExecutionContext context;
-
- public InitialToken(Process proc, Attachments att)
- {
- this.proc = proc;
- this.context = new InitialContext(att);
- }
-
- public Process getProcess()
- {
- return proc;
- }
-
- public ExecutionContext getExecutionContext()
- {
- return context;
- }
-
- @XmlTransient
- static class InitialContext extends BasicAttachments implements ExecutionContext
- {
- InitialContext(Attachments att)
- {
- super(att);
- }
- }
-}
\ No newline at end of file
Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Process.java
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Process.java 2008-07-11 14:21:35 UTC (rev 1590)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Process.java 2008-07-11 16:01:29 UTC (rev 1591)
@@ -26,19 +26,16 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
import org.jboss.bpm.InvalidProcessException;
import org.jboss.bpm.NameNotUniqueException;
-import org.jboss.bpm.NotImplementedException;
+import org.jboss.bpm.client.ExecutionManager;
import org.jboss.bpm.runtime.Attachments;
+import org.jboss.bpm.runtime.Token;
/**
* A Process is any Activity performed within a company or organization.
@@ -146,8 +143,8 @@
throw new IllegalStateException("Cannot start process in state: " + processState);
processState = ProcessState.STARTED;
- execute(new InitialToken(this, att));
- return new ResultFuture();
+ ExecutionManager exm = ExecutionManager.locateExecutionManager();
+ return exm.startProcess(this, att);
}
/**
@@ -177,24 +174,6 @@
}
/**
- * Get signal for enter
- */
- @Override
- public Signal getEnterSignal()
- {
- return new Signal(this, Signal.Type.ENTER_PROCESS);
- }
-
- /**
- * Get signal for exit
- */
- @Override
- public Signal getExitSignal()
- {
- return new Signal(this, Signal.Type.EXIT_PROCESS);
- }
-
- /**
* Get the process state
*/
public ProcessState getProcessState()
@@ -202,6 +181,12 @@
return processState;
}
+ // Overwrite to prevent execution
+ public void execute(Token token)
+ {
+ throw new IllegalStateException("A Process cannot get executed. Go through startProcess");
+ }
+
/**
* Set the process state
*/
@@ -222,56 +207,4 @@
processState = ProcessState.INITIALIZED;
}
-
- @XmlTransient
- class ResultFuture implements Future<Result>
- {
- private Result result;
-
- public boolean cancel(boolean mayInterruptIfRunning)
- {
- throw new NotImplementedException();
- }
-
- public Result get() throws InterruptedException, ExecutionException
- {
- return getResult();
- }
-
- public Result get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
- {
- throw new NotImplementedException();
- }
-
- public boolean isCancelled()
- {
- return false;
- }
-
- public boolean isDone()
- {
- boolean isDone = getResult() != null;
- if (isDone)
- processState = ProcessState.ENDED;
-
- return isDone;
- }
-
- private Result getResult()
- {
- if (result == null)
- {
- for (EndEvent aux : getEndEvents())
- {
- result = aux.getResult();
- if (result != null)
- {
- processState = ProcessState.ENDED;
- break;
- }
- }
- }
- return result;
- }
- }
}
\ No newline at end of file
Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/model/SubProcess.java
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/model/SubProcess.java 2008-07-11 14:21:35 UTC (rev 1590)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/model/SubProcess.java 2008-07-11 16:01:29 UTC (rev 1591)
@@ -26,6 +26,8 @@
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
+import org.jboss.bpm.runtime.Token;
+
/**
* A Sub-Process is Process that is included within another Process.
*
@@ -33,7 +35,7 @@
* @since 08-Jul-2008
*/
@XmlType(name="SubProcess")
-public class SubProcess extends AbstractSubProcess implements SingleInFlowSupport
+public class SubProcess extends AbstractSubProcess implements SingleInFlowSupport, ExecutableFlowObject
{
private Flow inFlow;
@@ -70,6 +72,24 @@
{
this.inFlow = inFlow;
}
+
+ /** Get signal for enter */
+ public Signal getEnterSignal()
+ {
+ return new Signal(getProcess(), Signal.Type.ENTER_SUB_PROCESS, getName());
+ }
+
+ /** Get signal for exit */
+ public Signal getExitSignal()
+ {
+ return new Signal(getProcess(), Signal.Type.EXIT_SUB_PROCESS, getName());
+ }
+
+ public void execute(Token token)
+ {
+ startProcess(token.getExecutionContext());
+ }
+
public String toString()
{
Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Task.java
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Task.java 2008-07-11 14:21:35 UTC (rev 1590)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Task.java 2008-07-11 16:01:29 UTC (rev 1591)
@@ -24,6 +24,8 @@
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
+import org.jboss.bpm.runtime.Token;
+
//$Id$
/**
@@ -36,7 +38,7 @@
* @since 08-Jul-2008
*/
@XmlType(name = "Task")
-public class Task extends AbstractTask implements SingleInFlowSupport
+public class Task extends AbstractTask implements SingleInFlowSupport, ExecutableFlowObject
{
private Flow inFlow;
@@ -86,6 +88,11 @@
return new Signal(getProcess(), Signal.Type.EXIT_TASK, getName());
}
+ public void execute(Token token)
+ {
+ throw new IllegalStateException("Overwrite to impolement the task");
+ }
+
public String toString()
{
return "Task[" + getName() + "]";
Modified: api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/context/TaskA.java
===================================================================
--- api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/context/TaskA.java 2008-07-11 14:21:35 UTC (rev 1590)
+++ api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/context/TaskA.java 2008-07-11 16:01:29 UTC (rev 1591)
@@ -35,7 +35,8 @@
*/
public class TaskA extends Task
{
- protected void executeOverwrite(Token token)
+ @Override
+ public void execute(Token token)
{
ExecutionContext ctx = token.getExecutionContext();
ctx.addAttachment(String.class, "TaskMessage", getName() + " has: " + ctx.getAttachmentKeys());
Modified: api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/task/TaskA.java
===================================================================
--- api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/task/TaskA.java 2008-07-11 14:21:35 UTC (rev 1590)
+++ api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/task/TaskA.java 2008-07-11 16:01:29 UTC (rev 1591)
@@ -35,7 +35,8 @@
*/
public class TaskA extends Task
{
- protected void executeOverwrite(Token token)
+ @Override
+ public void execute(Token token)
{
ExecutionContext ctx = token.getExecutionContext();
ctx.addAttachment(String.class, "Task: " + getName());
More information about the jbpm-commits
mailing list