[jbpm-commits] JBoss JBPM SVN: r2893 - in projects/spec/trunk/modules: api/src/main/java/org/jbpm/api/runtime/preview and 8 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Wed Nov 12 09:28:34 EST 2008
Author: thomas.diesler at jboss.com
Date: 2008-11-12 09:28:34 -0500 (Wed, 12 Nov 2008)
New Revision: 2893
Added:
projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/client/PersistenceToken.java
projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/client/Token.java
projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/task/waitstate/
projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/task/waitstate/WaitStateTest.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/InProcessTokenExecutor.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/MutableToken.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/ThreadingTokenExecutor.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/TokenImpl.java
Removed:
projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/client/Execution.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/ExecutionImpl.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/MutableExecution.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/TokenExecutorImpl.java
Modified:
projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/client/Process.java
projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/runtime/preview/ExecutionHandler.java
projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/runtime/preview/FlowHandler.java
projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/runtime/preview/SignalHandler.java
projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/runtime/preview/TokenExecutor.java
projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/preview/task/java/JavaTaskTest.java
projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/preview/transaction/TxRequiredTest.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/EndEventImpl.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/EventImpl.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/ExclusiveGatewayImpl.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/GatewayImpl.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/InclusiveGatewayImpl.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/NodeImpl.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/ParallelGatewayImpl.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/ProcessImpl.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/ReceiveTaskImpl.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/SendTaskImpl.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/StartEventImpl.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/TaskImpl.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/UserTaskImpl.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/AssignmentInterceptor.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/DelegatingToken.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/ExitSignalInterceptor.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/ExpressionEvaluator.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/FlowHandlerInterceptor.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/MessageSender.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/NodeExecuteInterceptor.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/PersistenceSessionInterceptor.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/RunnableToken.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/RuntimeContext.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/RuntimeProcess.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/RuntimeProcessImpl.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/SignalHandlerInterceptor.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/TransactionInterceptor.java
projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/service/ExecutionServiceImpl.java
projects/spec/trunk/modules/ri/src/test/java/org/jbpm/test/ri/service/persistence/TaskPersistenceTest.java
Log:
Add startProcess() and startProcessAsync()
Deleted: projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/client/Execution.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/client/Execution.java 2008-11-12 11:37:11 UTC (rev 2892)
+++ projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/client/Execution.java 2008-11-12 14:28:34 UTC (rev 2893)
@@ -1,78 +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 org.hibernate.Session;
-import org.jbpm.api.model.SequenceFlow;
-import org.jbpm.api.runtime.preview.ExecutionContext;
-
-/**
- * A Token is a descriptive construct used to describe how the flow of a Process will proceed at runtime.
- *
- * By tracking how the Token traverses the Flow Objects, gets diverted through alternative paths, and gets split into
- * parallel paths, the normal Sequence Flow should be completely definable.
- *
- * A Token will have a unique identity that can be used to separate multiple Tokens that may exist because of concurrent
- * process instances or the splitting of the Token for parallel processing within a single process instance.
- *
- * @author Thomas.Diesler at jboss.com
- * @since 20-Apr-2007
- */
-public interface Execution
-{
- public enum ExecutionStatus
- {
- Created, Started, Stoped, Destroyed, Suspended
- }
-
- /**
- * Get the unique token identity
- */
- String getExecutionID();
-
- /**
- * Get the token status
- */
- ExecutionStatus getExecutionStatus();
-
- /**
- * Get the associated {@link Process}
- */
- Process getProcess();
-
- /**
- * Get the associated {@link ExecutionContext}
- */
- ExecutionContext getExecutionContext();
-
- /**
- * Get the current {@link SequenceFlow}
- */
- SequenceFlow getSequenceFlow();
-
- /**
- * Get the associated persistence session
- */
- Session getSession();
-}
\ No newline at end of file
Added: projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/client/PersistenceToken.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/client/PersistenceToken.java (rev 0)
+++ projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/client/PersistenceToken.java 2008-11-12 14:28:34 UTC (rev 2893)
@@ -0,0 +1,40 @@
+/*
+ * 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.hibernate.Session;
+
+/**
+ * A Token that gives access to the persistence context
+ *
+ * @author Thomas.Diesler at jboss.com
+ * @since 20-Apr-2007
+ */
+public interface PersistenceToken extends Token
+{
+ /**
+ * Get the associated persistence session
+ */
+ Session getSession();
+}
\ No newline at end of file
Property changes on: projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/client/PersistenceToken.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/client/Process.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/client/Process.java 2008-11-12 11:37:11 UTC (rev 2892)
+++ projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/client/Process.java 2008-11-12 14:28:34 UTC (rev 2893)
@@ -57,11 +57,21 @@
/**
* Start the process
*/
- ObjectName startProcessAsync();
+ Token startProcess();
/**
* Start the process, with a given execution context
*/
+ Token startProcess(Attachments att);
+
+ /**
+ * Start the process asynchronously
+ */
+ ObjectName startProcessAsync();
+
+ /**
+ * Start the process asynchronously, with a given execution context
+ */
ObjectName startProcessAsync(Attachments att);
/**
Copied: projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/client/Token.java (from rev 2891, projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/client/Execution.java)
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/client/Token.java (rev 0)
+++ projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/client/Token.java 2008-11-12 14:28:34 UTC (rev 2893)
@@ -0,0 +1,83 @@
+/*
+ * 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.model.Node;
+import org.jbpm.api.model.SequenceFlow;
+import org.jbpm.api.runtime.preview.ExecutionContext;
+
+/**
+ * A Token is a descriptive construct used to describe how the flow of a Process will proceed at runtime.
+ *
+ * By tracking how the Token traverses the Flow Objects, gets diverted through alternative paths, and gets split into
+ * parallel paths, the normal Sequence Flow should be completely definable.
+ *
+ * A Token will have a unique identity that can be used to separate multiple Tokens that may exist because of concurrent
+ * process instances or the splitting of the Token for parallel processing within a single process instance.
+ *
+ * @author Thomas.Diesler at jboss.com
+ * @since 20-Apr-2007
+ */
+public interface Token
+{
+ public enum TokenStatus
+ {
+ Created, Started, Stoped, Destroyed, Suspended
+ }
+
+ /**
+ * Get the unique token identity
+ */
+ String getTokenID();
+
+ /**
+ * Get the token status
+ */
+ TokenStatus getTokenStatus();
+
+ /**
+ * Get the associated {@link Process}
+ */
+ Process getProcess();
+
+ /**
+ * Get the associated {@link ExecutionContext}
+ */
+ ExecutionContext getExecutionContext();
+
+ /**
+ * Get the last {@link SequenceFlow}
+ */
+ SequenceFlow getLastFlow();
+
+ /**
+ * Get the current {@link Node}
+ */
+ Node getCurrentNode();
+
+ /**
+ * Signal the Token, which takes it to the next wait state
+ */
+ void signal();
+}
\ No newline at end of file
Modified: projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/runtime/preview/ExecutionHandler.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/runtime/preview/ExecutionHandler.java 2008-11-12 11:37:11 UTC (rev 2892)
+++ projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/runtime/preview/ExecutionHandler.java 2008-11-12 14:28:34 UTC (rev 2893)
@@ -23,7 +23,7 @@
//$Id$
-import org.jbpm.api.client.Execution;
+import org.jbpm.api.client.Token;
import org.jbpm.api.model.Node;
/**
@@ -38,6 +38,6 @@
/**
* Execute the associated business logic.
*/
- void execute(Execution token);
+ void execute(Token token);
}
\ No newline at end of file
Modified: projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/runtime/preview/FlowHandler.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/runtime/preview/FlowHandler.java 2008-11-12 11:37:11 UTC (rev 2892)
+++ projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/runtime/preview/FlowHandler.java 2008-11-12 14:28:34 UTC (rev 2893)
@@ -23,13 +23,13 @@
// $Id$
-import org.jbpm.api.client.Execution;
+import org.jbpm.api.client.Token;
import org.jbpm.api.client.ProcessEngine;
import org.jbpm.api.model.Node;
/**
* The {@link ProcessEngine} invokes the FlowHandler on a {@link Node}
- * to move the {@link Execution} to the next {@link Node}.
+ * to move the {@link Token} to the next {@link Node}.
*
* @author thomas.diesler at jboss.com
* @since 08-Jul-2008
@@ -40,8 +40,8 @@
* Execute the FlowHandler.
* <p/>
* The FlowHandler typically invoves one of the {@link TokenExecutor}
- * methods to move the {@link Execution} to the next {@link Node}.
+ * methods to move the {@link Token} to the next {@link Node}.
*/
- void execute(TokenExecutor tokenExecutor, Execution token);
+ void execute(TokenExecutor tokenExecutor, Token token);
}
\ No newline at end of file
Modified: projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/runtime/preview/SignalHandler.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/runtime/preview/SignalHandler.java 2008-11-12 11:37:11 UTC (rev 2892)
+++ projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/runtime/preview/SignalHandler.java 2008-11-12 14:28:34 UTC (rev 2893)
@@ -23,7 +23,7 @@
// $Id$
-import org.jbpm.api.client.Execution;
+import org.jbpm.api.client.Token;
import org.jbpm.api.client.ProcessEngine;
import org.jbpm.api.model.Node;
import org.jbpm.api.model.preview.Signal;
@@ -40,10 +40,10 @@
/**
* Get signal for enter
*/
- void throwEnterSignal(Execution token);
+ void throwEnterSignal(Token token);
/**
* Get signal for exit
*/
- void throwExitSignal(Execution token);
+ void throwExitSignal(Token token);
}
\ No newline at end of file
Modified: projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/runtime/preview/TokenExecutor.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/runtime/preview/TokenExecutor.java 2008-11-12 11:37:11 UTC (rev 2892)
+++ projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/runtime/preview/TokenExecutor.java 2008-11-12 14:28:34 UTC (rev 2893)
@@ -23,14 +23,12 @@
//$Id$
-import java.util.Set;
-
-import org.jbpm.api.client.Execution;
+import org.jbpm.api.client.Token;
import org.jbpm.api.model.SequenceFlow;
/**
- * The {@link FlowHandler} invokes the TokenExecutor to move {@link Execution}s
- * along the {@link SequenceFlow}s in the {@link Process}.
+ * The {@link FlowHandler} invokes the TokenExecutor to move {@link Token}s along the {@link SequenceFlow}s in the
+ * {@link Process}.
*
* @author thomas.diesler at jboss.com
* @since 08-Jul-2008
@@ -38,47 +36,37 @@
public interface TokenExecutor
{
/**
- * Get the set of active tokens
+ * Create a {@link Token} with an initial flow
*/
- Set<Execution> getRunnableTokens();
-
+ void create(Token token, SequenceFlow flow);
+
/**
- * True if there are active tokens
+ * Start a {@link Token}
*/
- boolean hasRunnableTokens();
-
+ void start(Token token);
+
/**
- * Create a {@link Execution} with an initial flow
+ * Stop a {@link Token}
*/
- void create(Execution token, SequenceFlow flow);
-
+ void stop(Token token);
+
/**
- * Start a {@link Execution}
+ * Destroy a {@link Token}
*/
- void start(Execution token);
-
+ void destroy(Token token);
+
/**
- * Stop a {@link Execution}
+ * Suspend a {@link Token}
*/
- void stop(Execution token);
-
+ String suspend(Token token);
+
/**
- * Destroy a {@link Execution}
+ * Activate a {@link Token}
*/
- void destroy(Execution token);
-
+ Token activate(String tokenID);
+
/**
- * Suspend a {@link Execution}
+ * Move a given {@link Token} along a given flow.
*/
- String suspend(Execution token);
-
- /**
- * Activate a {@link Execution}
- */
- Execution activate(String tokenID);
-
- /**
- * Move a given {@link Execution} along a given flow.
- */
- void move(Execution token, SequenceFlow flow);
+ void move(Token token, SequenceFlow flow);
}
Modified: projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/preview/task/java/JavaTaskTest.java
===================================================================
--- projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/preview/task/java/JavaTaskTest.java 2008-11-12 11:37:11 UTC (rev 2892)
+++ projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/preview/task/java/JavaTaskTest.java 2008-11-12 14:28:34 UTC (rev 2893)
@@ -25,7 +25,7 @@
import java.io.IOException;
-import org.jbpm.api.client.Execution;
+import org.jbpm.api.client.Token;
import org.jbpm.api.client.Process;
import org.jbpm.api.client.ProcessDefinition;
import org.jbpm.api.model.Expression.ExpressionLanguage;
@@ -89,7 +89,7 @@
* - The result of start time activity assignments
*/
@Override
- public void execute(Execution token)
+ public void execute(Token token)
{
ExecutionContext exContext = token.getExecutionContext();
procProp = (String)exContext.getAttachment("TaskExecutionHandlerTest.procProp");
Modified: projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/preview/transaction/TxRequiredTest.java
===================================================================
--- projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/preview/transaction/TxRequiredTest.java 2008-11-12 11:37:11 UTC (rev 2892)
+++ projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/preview/transaction/TxRequiredTest.java 2008-11-12 14:28:34 UTC (rev 2893)
@@ -29,7 +29,7 @@
import org.hibernate.Transaction;
import org.jbpm.api.Constants;
import org.jbpm.api.Constants.TxType;
-import org.jbpm.api.client.Execution;
+import org.jbpm.api.client.Token;
import org.jbpm.api.client.Process;
import org.jbpm.api.client.ProcessDefinition;
import org.jbpm.api.model.Node;
@@ -110,7 +110,7 @@
private Node node;
@Override
- public void execute(Execution token)
+ public void execute(Token token)
{
Transaction tx = TransactionAssociation.getTransaction();
Boolean doRollback = token.getExecutionContext().getAttachment(Boolean.class, "rollback");
Added: projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/task/waitstate/WaitStateTest.java
===================================================================
--- projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/task/waitstate/WaitStateTest.java (rev 0)
+++ projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/task/waitstate/WaitStateTest.java 2008-11-12 14:28:34 UTC (rev 2893)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.cts.task.waitstate;
+
+// $Id$
+
+import java.io.IOException;
+
+import org.jbpm.api.client.Process;
+import org.jbpm.api.client.ProcessDefinition;
+import org.jbpm.api.client.Token;
+import org.jbpm.api.model.builder.ProcessBuilder;
+import org.jbpm.api.service.ProcessBuilderService;
+import org.jbpm.api.test.CTSTestCase;
+
+/**
+ * Test the basic execution sequence
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 03-Jul-2008
+ */
+public class WaitStateTest extends CTSTestCase
+{
+ public void testSequence() throws Exception
+ {
+ ProcessDefinition procDef = unregisterOnTearDown(getProcessDefinition());
+ Process proc = procDef.newInstance();
+
+ // Start the Process
+ Token tok = proc.startProcess();
+ tok.signal();
+ }
+
+ public ProcessDefinition getProcessDefinition() throws IOException
+ {
+ ProcessBuilder builder = ProcessBuilderService.locateProcessBuilder();
+ builder.addProcess("Proc").addStartEvent("Start").addSequenceFlow("Task");
+ builder.addTask("Task").addSequenceFlow("End").addEndEvent("End");
+ return builder.getProcessDefinition();
+ }
+}
Property changes on: projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/task/waitstate/WaitStateTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/EndEventImpl.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/EndEventImpl.java 2008-11-12 11:37:11 UTC (rev 2892)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/EndEventImpl.java 2008-11-12 14:28:34 UTC (rev 2893)
@@ -28,7 +28,7 @@
import org.jbpm.api.Constants;
import org.jbpm.api.InvalidProcessException;
-import org.jbpm.api.client.Execution;
+import org.jbpm.api.client.Token;
import org.jbpm.api.client.ProcessEngine;
import org.jbpm.api.model.EndEvent;
import org.jbpm.api.model.Node;
@@ -117,13 +117,13 @@
ProcessEngine engine = getProcessDefinition().getProcessEngine();
SignalService sigService = engine.getService(SignalService.class);
- public void throwEnterSignal(Execution token)
+ public void throwEnterSignal(Token token)
{
Signal signal = new SignalImpl(Signal.SignalType.SYSTEM_END_EVENT_ENTER, getKey());
sigService.throwSignal(signal);
}
- public void throwExitSignal(Execution token)
+ public void throwExitSignal(Token token)
{
Signal signal = new SignalImpl(Signal.SignalType.SYSTEM_END_EVENT_EXIT, getKey());
sigService.throwSignal(signal);
@@ -155,7 +155,7 @@
{
private static final long serialVersionUID = 1L;
- public void execute(TokenExecutor tokenExecutor, Execution token)
+ public void execute(TokenExecutor tokenExecutor, Token token)
{
log.debug("End reached in: " + getName());
ExecutionContext exContext = token.getExecutionContext();
@@ -186,7 +186,7 @@
this.tokenExecutor = tokenExecutor;
}
- void destroyToken(Execution token)
+ void destroyToken(Token token)
{
tokenExecutor.destroy(token);
}
Modified: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/EventImpl.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/EventImpl.java 2008-11-12 11:37:11 UTC (rev 2892)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/EventImpl.java 2008-11-12 14:28:34 UTC (rev 2893)
@@ -32,7 +32,7 @@
import org.jbpm.api.Constants;
import org.jbpm.api.InvalidProcessException;
-import org.jbpm.api.client.Execution;
+import org.jbpm.api.client.Token;
import org.jbpm.api.client.Process;
import org.jbpm.api.client.ProcessDefinition;
import org.jbpm.api.client.ProcessEngine;
@@ -133,7 +133,7 @@
{
private static final long serialVersionUID = 1L;
- public void execute(Execution token)
+ public void execute(Token token)
{
if (detailType == EventDetailType.Message && getMessageRef() != null)
{
@@ -166,13 +166,13 @@
ProcessEngine engine = getProcessDefinition().getProcessEngine();
SignalService sigService = engine.getService(SignalService.class);
- public void throwEnterSignal(Execution token)
+ public void throwEnterSignal(Token token)
{
Signal signal = new SignalImpl(Signal.SignalType.SYSTEM_EVENT_ENTER, getKey());
sigService.throwSignal(signal);
}
- public void throwExitSignal(Execution token)
+ public void throwExitSignal(Token token)
{
Signal signal = new SignalImpl(Signal.SignalType.SYSTEM_EVENT_EXIT, getKey());
sigService.throwSignal(signal);
Modified: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/ExclusiveGatewayImpl.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/ExclusiveGatewayImpl.java 2008-11-12 11:37:11 UTC (rev 2892)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/ExclusiveGatewayImpl.java 2008-11-12 14:28:34 UTC (rev 2893)
@@ -29,7 +29,7 @@
import javax.persistence.Entity;
import javax.persistence.Transient;
-import org.jbpm.api.client.Execution;
+import org.jbpm.api.client.Token;
import org.jbpm.api.model.ExclusiveGateway;
import org.jbpm.api.model.Expression;
import org.jbpm.api.model.Node;
@@ -88,7 +88,7 @@
{
private static final long serialVersionUID = 1L;
- public void execute(Execution token)
+ public void execute(Token token)
{
// Call the super default handler
superExecHandler.execute(token);
@@ -97,7 +97,7 @@
if (outstandingFlows == null)
outstandingFlows = new HashSet<SequenceFlow>(inFlows);
- SequenceFlow flow = token.getSequenceFlow();
+ SequenceFlow flow = token.getLastFlow();
outstandingFlows.remove(flow);
}
@@ -122,9 +122,9 @@
{
private static final long serialVersionUID = 1L;
- public void execute(TokenExecutor tokenExecutor, Execution token)
+ public void execute(TokenExecutor tokenExecutor, Token token)
{
- String sourceRef = token.getSequenceFlow().getSourceRef();
+ String sourceRef = token.getLastFlow().getSourceRef();
// Schedule the first token that arrives
if (token == receivedTokens.get(0))
@@ -170,7 +170,7 @@
// Get a single selected gate which' condition evaluates to TRUE
// Fall back to the default gate if there is one
// Choke if there is no selected gate
- private SequenceFlow getSelectedGate(Execution token)
+ private SequenceFlow getSelectedGate(Token token)
{
SequenceFlow selectedGate = null;
for (SequenceFlow auxGate : getGates())
Modified: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/GatewayImpl.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/GatewayImpl.java 2008-11-12 11:37:11 UTC (rev 2892)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/GatewayImpl.java 2008-11-12 14:28:34 UTC (rev 2893)
@@ -34,7 +34,7 @@
import javax.persistence.Transient;
import org.jbpm.api.Constants;
-import org.jbpm.api.client.Execution;
+import org.jbpm.api.client.Token;
import org.jbpm.api.client.ProcessEngine;
import org.jbpm.api.model.Gateway;
import org.jbpm.api.model.Node;
@@ -71,7 +71,7 @@
// The list of received tokens
@Transient
- protected List<Execution> receivedTokens;
+ protected List<Token> receivedTokens;
public GatewayImpl(ProcessStructure procStruct, String name, GatewayType gatewayType)
{
@@ -162,17 +162,17 @@
{
private static final long serialVersionUID = 1L;
- public void execute(Execution token)
+ public void execute(Token token)
{
// Initialize the gateway
if (expectedFlows == null)
{
expectedFlows = new ArrayList<SequenceFlow>(inFlows);
- receivedTokens = new ArrayList<Execution>();
+ receivedTokens = new ArrayList<Token>();
}
// Check that token from flow is valid
- SequenceFlow flow = token.getSequenceFlow();
+ SequenceFlow flow = token.getLastFlow();
if (expectedFlows.contains(flow) == false)
throw new IllegalStateException("Unexpected token from: " + flow);
@@ -207,13 +207,13 @@
ProcessEngine engine = getProcessDefinition().getProcessEngine();
SignalService sigService = engine.getService(SignalService.class);
- public void throwEnterSignal(Execution token)
+ public void throwEnterSignal(Token token)
{
Signal signal = new SignalImpl(Signal.SignalType.SYSTEM_GATEWAY_ENTER, getKey());
sigService.throwSignal(signal);
}
- public void throwExitSignal(Execution token)
+ public void throwExitSignal(Token token)
{
Signal signal = new SignalImpl(Signal.SignalType.SYSTEM_GATEWAY_EXIT, getKey());
sigService.throwSignal(signal);
Modified: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/InclusiveGatewayImpl.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/InclusiveGatewayImpl.java 2008-11-12 11:37:11 UTC (rev 2892)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/InclusiveGatewayImpl.java 2008-11-12 14:28:34 UTC (rev 2893)
@@ -30,7 +30,7 @@
import javax.persistence.Entity;
-import org.jbpm.api.client.Execution;
+import org.jbpm.api.client.Token;
import org.jbpm.api.model.Expression;
import org.jbpm.api.model.Node;
import org.jbpm.api.model.ProcessStructure;
@@ -42,7 +42,7 @@
import org.jbpm.api.runtime.preview.ExecutionContext;
import org.jbpm.api.runtime.preview.FlowHandler;
import org.jbpm.api.runtime.preview.TokenExecutor;
-import org.jbpm.ri.runtime.MutableExecution;
+import org.jbpm.ri.runtime.MutableToken;
import org.mvel.MVEL;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -81,10 +81,10 @@
{
private static final long serialVersionUID = 1L;
- public void execute(TokenExecutor tokenExecutor, Execution token)
+ public void execute(TokenExecutor tokenExecutor, Token token)
{
- MutableExecution mutableToken = (MutableExecution)token;
- String sourceRef = token.getSequenceFlow().getSourceRef();
+ MutableToken mutableToken = (MutableToken)token;
+ String sourceRef = token.getLastFlow().getSourceRef();
log.debug("Propagate token comming from: " + sourceRef);
// Get the applicable gates
@@ -98,15 +98,15 @@
}
else
{
- List<Execution> outTokens = new ArrayList<Execution>();
+ List<Token> outTokens = new ArrayList<Token>();
for (SequenceFlow auxGate : applicableGates)
{
SequenceFlow outFlow = auxGate;
- Execution outToken = mutableToken.copyToken();
+ Token outToken = mutableToken.copyToken();
tokenExecutor.create(outToken, outFlow);
outTokens.add(outToken);
}
- for (Execution outToken : outTokens)
+ for (Token outToken : outTokens)
{
tokenExecutor.start(outToken);
}
@@ -134,7 +134,7 @@
// Get applicable gates which' condition evaluates to TRUE.
// Fall back to the default gate if there is one.
// Choke if there is no applicable gate.
- private List<SequenceFlow> getApplicableGates(Execution token)
+ private List<SequenceFlow> getApplicableGates(Token token)
{
List<SequenceFlow> applicableGates = new ArrayList<SequenceFlow>();
for (SequenceFlow auxGate : getGates())
Modified: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/NodeImpl.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/NodeImpl.java 2008-11-12 11:37:11 UTC (rev 2892)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/NodeImpl.java 2008-11-12 14:28:34 UTC (rev 2893)
@@ -43,10 +43,10 @@
import org.hibernate.annotations.IndexColumn;
import org.jbpm.api.InvalidProcessException;
import org.jbpm.api.NameNotUniqueException;
-import org.jbpm.api.client.Execution;
+import org.jbpm.api.client.Token;
import org.jbpm.api.client.Process;
import org.jbpm.api.client.ProcessDefinition;
-import org.jbpm.api.client.Execution.ExecutionStatus;
+import org.jbpm.api.client.Token.TokenStatus;
import org.jbpm.api.model.EndEvent;
import org.jbpm.api.model.Node;
import org.jbpm.api.model.ProcessStructure;
@@ -248,7 +248,7 @@
public void execute(RuntimeContext rtContext)
{
- Execution token = rtContext.getToken();
+ Token token = rtContext.getToken();
// The default implementation calls the ExecutionHandler
ExecutionHandler execHandler = getExecutionHandler();
@@ -289,7 +289,7 @@
{
private static final long serialVersionUID = 1L;
- public void execute(Execution token)
+ public void execute(Token token)
{
// nothing to do
}
@@ -340,12 +340,12 @@
{
private static final long serialVersionUID = 1L;
- public void execute(TokenExecutor tokenExecutor, Execution token)
+ public void execute(TokenExecutor tokenExecutor, Token token)
{
if (getOutFlows().size() == 1)
{
SequenceFlow outFlow = getOutFlows().get(0);
- if (token.getExecutionStatus() == ExecutionStatus.Started)
+ if (token.getTokenStatus() == TokenStatus.Started)
tokenExecutor.move(token, outFlow);
}
else
Modified: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/ParallelGatewayImpl.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/ParallelGatewayImpl.java 2008-11-12 11:37:11 UTC (rev 2892)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/ParallelGatewayImpl.java 2008-11-12 14:28:34 UTC (rev 2893)
@@ -31,7 +31,7 @@
import javax.persistence.Entity;
import javax.persistence.Transient;
-import org.jbpm.api.client.Execution;
+import org.jbpm.api.client.Token;
import org.jbpm.api.model.Node;
import org.jbpm.api.model.ProcessStructure;
import org.jbpm.api.model.SequenceFlow;
@@ -39,8 +39,8 @@
import org.jbpm.api.runtime.preview.ExecutionHandler;
import org.jbpm.api.runtime.preview.FlowHandler;
import org.jbpm.api.runtime.preview.TokenExecutor;
-import org.jbpm.ri.runtime.MutableExecution;
-import org.jbpm.ri.runtime.ExecutionImpl;
+import org.jbpm.ri.runtime.MutableToken;
+import org.jbpm.ri.runtime.TokenImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -63,7 +63,7 @@
private Set<SequenceFlow> outstandingFlows;
@Transient
- private Set<Execution> mergeTokens;
+ private Set<Token> mergeTokens;
public ParallelGatewayImpl(ProcessStructure procStruct, String name)
{
@@ -85,7 +85,7 @@
{
private static final long serialVersionUID = 1L;
- public void execute(Execution token)
+ public void execute(Token token)
{
// Call the super default handler
superExecHandler.execute(token);
@@ -94,10 +94,10 @@
if (outstandingFlows == null)
{
outstandingFlows = new HashSet<SequenceFlow>(inFlows);
- mergeTokens = new HashSet<Execution>();
+ mergeTokens = new HashSet<Token>();
}
- SequenceFlow flow = token.getSequenceFlow();
+ SequenceFlow flow = token.getLastFlow();
outstandingFlows.remove(flow);
mergeTokens.add(token);
}
@@ -123,13 +123,13 @@
{
private static final long serialVersionUID = 1L;
- public void execute(TokenExecutor tokenExecutor, Execution token)
+ public void execute(TokenExecutor tokenExecutor, Token token)
{
// In any case, the incomming token is not propagated
tokenExecutor.suspend(token);
// If the gateway has a single incomming flow the outgoing token is the incomming token
- MutableExecution outToken = (getInFlows().size() == 1 ? (MutableExecution)token : null);
+ MutableToken outToken = (getInFlows().size() == 1 ? (MutableToken)token : null);
// The outgoing token is the merge of all incomming tokens
if (outToken == null)
@@ -152,7 +152,7 @@
if (outToken != null)
{
// Start a copy of the outgoing token for every gate
- List<Execution> outTokens = new ArrayList<Execution>();
+ List<Token> outTokens = new ArrayList<Token>();
for(SequenceFlow auxGate : getGates())
{
SequenceFlow outFlow = auxGate;
@@ -160,13 +160,13 @@
tokenExecutor.create(outToken, outFlow);
outTokens.add(outToken);
}
- for (Execution auxToken : outTokens)
+ for (Token auxToken : outTokens)
{
tokenExecutor.start(auxToken);
}
// Destroy the received tokens
- for (Execution auxToken : receivedTokens)
+ for (Token auxToken : receivedTokens)
{
tokenExecutor.destroy(auxToken);
}
@@ -197,10 +197,10 @@
mergeTokens = null;
}
- private ExecutionImpl getMergedTokens()
+ private TokenImpl getMergedTokens()
{
- ExecutionImpl mergedToken = new ExecutionImpl(getProcess(), null);
- for (Execution auxToken : mergeTokens)
+ TokenImpl mergedToken = new TokenImpl(getProcess(), null);
+ for (Token auxToken : mergeTokens)
{
log.debug("mergeToken: " + auxToken);
mergedToken.mergeToken(auxToken);
Modified: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/ProcessImpl.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/ProcessImpl.java 2008-11-12 11:37:11 UTC (rev 2892)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/ProcessImpl.java 2008-11-12 14:28:34 UTC (rev 2893)
@@ -41,6 +41,7 @@
import org.jbpm.api.client.Process;
import org.jbpm.api.client.ProcessDefinition;
import org.jbpm.api.client.ProcessEngine;
+import org.jbpm.api.client.Token;
import org.jbpm.api.model.Node;
import org.jbpm.api.model.builder.preview.ObjectNameFactory;
import org.jbpm.api.model.preview.Assignment;
@@ -50,6 +51,7 @@
import org.jbpm.api.runtime.Attachments;
import org.jbpm.api.service.ExecutionService;
import org.jbpm.api.service.ProcessInstanceService;
+import org.jbpm.ri.runtime.TokenImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -225,18 +227,40 @@
setProcessStatus(ProcessStatus.Aborted);
}
- public ObjectName startProcessAsync()
+ @Override
+ public Token startProcess()
{
return startProcessInternal(null);
}
- public ObjectName startProcessAsync(Attachments att)
+ @Override
+ public Token startProcess(Attachments att)
{
return startProcessInternal(att);
}
- private ObjectName startProcessInternal(Attachments att)
+ private Token startProcessInternal(Attachments att)
{
+ ProcessStatus status = getProcessStatus();
+ if (status != ProcessStatus.Ready)
+ throw new IllegalStateException("Cannot start process in state: " + status);
+
+ TokenImpl token = new TokenImpl(this, att);
+ return token;
+ }
+
+ public ObjectName startProcessAsync()
+ {
+ return startProcessAsyncInternal(null);
+ }
+
+ public ObjectName startProcessAsync(Attachments att)
+ {
+ return startProcessAsyncInternal(att);
+ }
+
+ private ObjectName startProcessAsyncInternal(Attachments att)
+ {
ProcessEngine engine = getProcessEngine();
ExecutionService exService = engine.getService(ExecutionService.class);
try
Modified: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/ReceiveTaskImpl.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/ReceiveTaskImpl.java 2008-11-12 11:37:11 UTC (rev 2892)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/ReceiveTaskImpl.java 2008-11-12 14:28:34 UTC (rev 2893)
@@ -31,7 +31,7 @@
import org.jbpm.api.InvalidProcessException;
import org.jbpm.api.NotImplementedException;
-import org.jbpm.api.client.Execution;
+import org.jbpm.api.client.Token;
import org.jbpm.api.client.Process;
import org.jbpm.api.client.ProcessDefinition;
import org.jbpm.api.client.preview.MessageListener;
@@ -65,7 +65,7 @@
private List<Message> receivedMessages = new ArrayList<Message>();
@Transient
- private transient Execution suspendedToken;
+ private transient Token suspendedToken;
@Transient
private transient TokenExecutor tokenExecutor;
@@ -100,7 +100,7 @@
@Override
public void execute(RuntimeContext rtContext)
{
- Execution token = rtContext.getToken();
+ Token token = rtContext.getToken();
tokenExecutor = rtContext.getTokenExecutor();
if (receivedMessages.size() > 0)
@@ -142,7 +142,7 @@
// Activate the suspended token
if (suspendedToken != null)
{
- tokenExecutor.activate(suspendedToken.getExecutionID());
+ tokenExecutor.activate(suspendedToken.getTokenID());
suspendedToken = null;
}
}
Modified: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/SendTaskImpl.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/SendTaskImpl.java 2008-11-12 11:37:11 UTC (rev 2892)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/SendTaskImpl.java 2008-11-12 14:28:34 UTC (rev 2893)
@@ -27,7 +27,7 @@
import javax.persistence.Transient;
import org.jbpm.api.InvalidProcessException;
-import org.jbpm.api.client.Execution;
+import org.jbpm.api.client.Token;
import org.jbpm.api.client.Process;
import org.jbpm.api.client.ProcessDefinition;
import org.jbpm.api.model.Node;
@@ -83,7 +83,7 @@
{
private static final long serialVersionUID = 1L;
- public void execute(Execution token)
+ public void execute(Token token)
{
Message messageRef = thisNode.getMessageRef();
MessageSender messageSender = new MessageSender(thisNode, messageRef);
Modified: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/StartEventImpl.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/StartEventImpl.java 2008-11-12 11:37:11 UTC (rev 2892)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/StartEventImpl.java 2008-11-12 14:28:34 UTC (rev 2893)
@@ -29,7 +29,7 @@
import org.jbpm.api.Constants;
import org.jbpm.api.InvalidProcessException;
-import org.jbpm.api.client.Execution;
+import org.jbpm.api.client.Token;
import org.jbpm.api.client.Process;
import org.jbpm.api.client.ProcessDefinition;
import org.jbpm.api.client.ProcessEngine;
@@ -123,13 +123,13 @@
ProcessEngine engine = getProcessDefinition().getProcessEngine();
SignalService sigService = engine.getService(SignalService.class);
- public void throwEnterSignal(Execution token)
+ public void throwEnterSignal(Token token)
{
Signal signal = new SignalImpl(Signal.SignalType.SYSTEM_START_EVENT_ENTER, getKey());
sigService.throwSignal(signal);
}
- public void throwExitSignal(Execution token)
+ public void throwExitSignal(Token token)
{
Signal signal = new SignalImpl(Signal.SignalType.SYSTEM_START_EVENT_EXIT, getKey());
sigService.throwSignal(signal);
Modified: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/TaskImpl.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/TaskImpl.java 2008-11-12 11:37:11 UTC (rev 2892)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/TaskImpl.java 2008-11-12 14:28:34 UTC (rev 2893)
@@ -39,7 +39,7 @@
import org.jbpm.api.Constants;
import org.jbpm.api.InvalidProcessException;
import org.jbpm.api.NotImplementedException;
-import org.jbpm.api.client.Execution;
+import org.jbpm.api.client.Token;
import org.jbpm.api.client.ProcessEngine;
import org.jbpm.api.model.Expression;
import org.jbpm.api.model.Node;
@@ -187,7 +187,7 @@
{
private static final long serialVersionUID = 1L;
- public void execute(Execution token)
+ public void execute(Token token)
{
superExecHandler.execute(token);
processOutputSet(token);
@@ -209,7 +209,7 @@
/**
* Select and validate active inputSet
*/
- protected InputSet getActiveInputSet(Execution token)
+ protected InputSet getActiveInputSet(Token token)
{
InputSetImpl inputSet = null;
ExecutionContext exContext = token.getExecutionContext();
@@ -280,7 +280,7 @@
/**
* Transfer data from outputSet to Token
*/
- protected void processOutputSet(Execution token)
+ protected void processOutputSet(Token token)
{
ExecutionContext exContext = token.getExecutionContext();
@@ -308,13 +308,13 @@
ProcessEngine engine = getProcessEngine();
SignalService sigService = engine.getService(SignalService.class);
- public void throwEnterSignal(Execution token)
+ public void throwEnterSignal(Token token)
{
Signal signal = new SignalImpl(Signal.SignalType.SYSTEM_TASK_ENTER, getKey());
sigService.throwSignal(signal);
}
- public void throwExitSignal(Execution token)
+ public void throwExitSignal(Token token)
{
Signal signal = new SignalImpl(Signal.SignalType.SYSTEM_TASK_EXIT, getKey());
sigService.throwSignal(signal);
Modified: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/UserTaskImpl.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/UserTaskImpl.java 2008-11-12 11:37:11 UTC (rev 2892)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/model/UserTaskImpl.java 2008-11-12 14:28:34 UTC (rev 2893)
@@ -33,7 +33,7 @@
import javax.persistence.Transient;
import org.jbpm.api.InvalidProcessException;
-import org.jbpm.api.client.Execution;
+import org.jbpm.api.client.Token;
import org.jbpm.api.client.Process;
import org.jbpm.api.client.ProcessDefinition;
import org.jbpm.api.client.preview.MessageListener;
@@ -71,7 +71,7 @@
private List<Message> receivedMessages = new ArrayList<Message>();
@Transient
- private transient Execution suspendedToken;
+ private transient Token suspendedToken;
@Transient
private transient TokenExecutor tokenExecutor;
@@ -126,7 +126,7 @@
@Override
public void execute(RuntimeContext rtContext)
{
- Execution token = rtContext.getToken();
+ Token token = rtContext.getToken();
tokenExecutor = rtContext.getTokenExecutor();
if (receivedMessages.size() == 0)
@@ -176,7 +176,7 @@
// Activate the suspended token
if (suspendedToken != null)
{
- tokenExecutor.activate(suspendedToken.getExecutionID());
+ tokenExecutor.activate(suspendedToken.getTokenID());
suspendedToken = null;
}
}
Modified: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/AssignmentInterceptor.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/AssignmentInterceptor.java 2008-11-12 11:37:11 UTC (rev 2892)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/AssignmentInterceptor.java 2008-11-12 14:28:34 UTC (rev 2893)
@@ -23,7 +23,7 @@
//$Id$
-import org.jbpm.api.client.Execution;
+import org.jbpm.api.client.Token;
import org.jbpm.api.model.Expression;
import org.jbpm.api.model.Node;
import org.jbpm.api.model.preview.Assignment;
@@ -41,8 +41,8 @@
@Override
public void execute(RuntimeContext rtContext)
{
- Node node = rtContext.getNode();
- Execution token = rtContext.getToken();
+ Token token = rtContext.getToken();
+ Node node = token.getCurrentNode();
// Do start time assignments
for (Assignment ass : node.getAssignments())
@@ -62,7 +62,7 @@
}
}
- protected void anyTimeAssignment(Assignment ass, Execution token)
+ protected void anyTimeAssignment(Assignment ass, Token token)
{
Expression expr = ass.getFrom();
ExpressionEvaluator exprEvaluator = new ExpressionEvaluator(expr);
Modified: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/DelegatingToken.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/DelegatingToken.java 2008-11-12 11:37:11 UTC (rev 2892)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/DelegatingToken.java 2008-11-12 14:28:34 UTC (rev 2893)
@@ -24,29 +24,28 @@
//$Id$
import org.hibernate.Session;
-import org.jbpm.api.client.Execution;
+import org.jbpm.api.client.Token;
import org.jbpm.api.client.Process;
import org.jbpm.api.model.Node;
import org.jbpm.api.model.SequenceFlow;
import org.jbpm.api.runtime.preview.ExecutionContext;
/**
- * A {@link Execution} that includes properties from the current {@link Node}
+ * A {@link Token} that includes properties from the current {@link Node}
*
* @author Thomas.Diesler at jboss.com
* @since 15-Aug-2008
*/
-public class DelegatingToken implements MutableExecution
+public class DelegatingToken implements MutableToken
{
- private MutableExecution delegateToken;
+ private MutableToken delegateToken;
private ExecutionContext delegateContext;
- public DelegatingToken(MutableExecution token)
+ public DelegatingToken(MutableToken token)
{
this.delegateToken = token;
- String targetRef = token.getSequenceFlow().getTargetRef();
- Node targetNode = token.getProcess().getNode(targetRef);
+ Node targetNode = token.getCurrentNode();
ExecutionContext exContext = token.getExecutionContext();
this.delegateContext = new DelegatingExecutionContext(targetNode, exContext);
}
@@ -58,27 +57,27 @@
}
@Override
- public MutableExecution copyToken()
+ public MutableToken copyToken()
{
return delegateToken.copyToken();
}
@Override
- public SequenceFlow getSequenceFlow()
+ public SequenceFlow getLastFlow()
{
- return delegateToken.getSequenceFlow();
+ return delegateToken.getLastFlow();
}
@Override
- public String getExecutionID()
+ public String getTokenID()
{
- return delegateToken.getExecutionID();
+ return delegateToken.getTokenID();
}
@Override
- public ExecutionStatus getExecutionStatus()
+ public TokenStatus getTokenStatus()
{
- return delegateToken.getExecutionStatus();
+ return delegateToken.getTokenStatus();
}
@Override
@@ -88,21 +87,27 @@
}
@Override
- public void mergeToken(Execution token)
+ public Node getCurrentNode()
{
+ return delegateToken.getCurrentNode();
+ }
+
+ @Override
+ public void mergeToken(Token token)
+ {
delegateToken.mergeToken(token);
}
@Override
- public void setSequenceFlow(SequenceFlow flow)
+ public void setLastFlow(SequenceFlow flow)
{
- delegateToken.setSequenceFlow(flow);
+ delegateToken.setLastFlow(flow);
}
@Override
- public void setExecutionStatus(ExecutionStatus status)
+ public void setTokenStatus(TokenStatus status)
{
- delegateToken.setExecutionStatus(status);
+ delegateToken.setTokenStatus(status);
}
@Override
@@ -117,6 +122,12 @@
delegateToken.setSession(session);
}
+ @Override
+ public void signal()
+ {
+ delegateToken.signal();
+ }
+
public String toString()
{
return delegateToken.toString();
Deleted: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/ExecutionImpl.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/ExecutionImpl.java 2008-11-12 11:37:11 UTC (rev 2892)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/ExecutionImpl.java 2008-11-12 14:28:34 UTC (rev 2893)
@@ -1,147 +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.ri.runtime;
-
-//$Id$
-
-import org.hibernate.Session;
-import org.jboss.util.id.UID;
-import org.jbpm.api.client.Execution;
-import org.jbpm.api.client.Process;
-import org.jbpm.api.model.SequenceFlow;
-import org.jbpm.api.runtime.Attachments;
-import org.jbpm.api.runtime.Attachments.Key;
-import org.jbpm.api.runtime.preview.BasicExecutionContext;
-import org.jbpm.api.runtime.preview.ExecutionContext;
-
-/**
- * A Token is a descriptive construct used to describe how the flow of a Process will proceed at runtime.
- *
- * By tracking how the Token traverses the Flow Objects, gets diverted through alternative paths,
- * and gets split into parallel paths, the normal Sequence Flow should be completely definable.
- *
- * A Token will have a unique identity that can be used to separate multiple Tokens that may exist because of
- * concurrent process instances or the splitting of the Token for parallel processing within a single process instance.
- *
- * @author Thomas.Diesler at jboss.com
- * @since 20-Apr-2007
- */
-public class ExecutionImpl implements MutableExecution
-{
- private String id;
- private SequenceFlow flow;
- private ExecutionContext context;
- private ExecutionStatus status;
- private Process process;
- private Session session;
-
- /**
- * Construct a Token with given {@link Attachments}
- */
- public ExecutionImpl(Process process, Attachments att)
- {
- this.context = new BasicExecutionContext(att);
- this.id = new UID().toString();
- this.status = ExecutionStatus.Created;
- this.process = process;
- }
-
- @Override
- public String getExecutionID()
- {
- return id;
- }
-
- @Override
- public ExecutionStatus getExecutionStatus()
- {
- return status;
- }
-
- @Override
- public void setExecutionStatus(ExecutionStatus status)
- {
- this.status = status;
- }
-
- @Override
- public Process getProcess()
- {
- return process;
- }
-
- @Override
- public ExecutionContext getExecutionContext()
- {
- return context;
- }
-
- @Override
- public SequenceFlow getSequenceFlow()
- {
- return flow;
- }
-
- @Override
- public void setSequenceFlow(SequenceFlow flow)
- {
- this.flow = flow;
- }
-
- @Override
- public Session getSession()
- {
- return session;
- }
-
- @Override
- public void setSession(Session session)
- {
- this.session = session;
- }
-
- @Override
- public MutableExecution copyToken()
- {
- return new ExecutionImpl(process, context);
- }
-
- @Override
- public void mergeToken(Execution token)
- {
- ExecutionContext mergeContext = token.getExecutionContext();
- for(Key key : mergeContext.getAttachmentKeys())
- {
- Object mergeValue = mergeContext.getAttachment(key.getClassPart(), key.getNamePart());
- Object existValue = context.getAttachment(key.getClassPart(), key.getNamePart());
- if (existValue != null && existValue.equals(mergeValue) == false)
- throw new IllegalStateException("Cannot merge the same key with different values: " + key);
-
- context.addAttachment(key.getClassPart(), key.getNamePart(), mergeValue);
- }
- }
-
- public String toString()
- {
- return "[sf=" + getSequenceFlow() + ",status=" + getExecutionStatus() + ",ctx=" + getExecutionContext() + ",id=" + id + "]";
- }
-}
\ No newline at end of file
Modified: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/ExitSignalInterceptor.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/ExitSignalInterceptor.java 2008-11-12 11:37:11 UTC (rev 2892)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/ExitSignalInterceptor.java 2008-11-12 14:28:34 UTC (rev 2893)
@@ -23,7 +23,7 @@
//$Id$
-import org.jbpm.api.client.Execution;
+import org.jbpm.api.client.Token;
import org.jbpm.api.model.Node;
import org.jbpm.api.runtime.preview.SignalHandler;
@@ -38,8 +38,8 @@
@Override
public void execute(RuntimeContext rtContext)
{
- Node node = rtContext.getNode();
- Execution token = rtContext.getToken();
+ Token token = rtContext.getToken();
+ Node node = token.getCurrentNode();
SignalHandler sigHandler = node.getSignalHandler();
sigHandler.throwExitSignal(token);
Modified: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/ExpressionEvaluator.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/ExpressionEvaluator.java 2008-11-12 11:37:11 UTC (rev 2892)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/ExpressionEvaluator.java 2008-11-12 14:28:34 UTC (rev 2893)
@@ -26,7 +26,7 @@
import java.util.HashMap;
import java.util.Map;
-import org.jbpm.api.client.Execution;
+import org.jbpm.api.client.Token;
import org.jbpm.api.model.Expression;
import org.jbpm.api.model.Expression.ExpressionLanguage;
import org.jbpm.api.runtime.Attachments.Key;
@@ -52,7 +52,7 @@
* Evaluate an expression for a given token. <p/> Note that <code>propName.replace(".", "_")</code> applies to
* property names for MVEL expressions, because the dot notation has special meaning in MVEL.
*/
- public Object evaluateExpression(Execution token)
+ public Object evaluateExpression(Token token)
{
ExpressionLanguage exprLang = expr.getExpressionLanguage();
if (exprLang == ExpressionLanguage.MVEL)
Modified: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/FlowHandlerInterceptor.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/FlowHandlerInterceptor.java 2008-11-12 11:37:11 UTC (rev 2892)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/FlowHandlerInterceptor.java 2008-11-12 14:28:34 UTC (rev 2893)
@@ -23,7 +23,7 @@
//$Id$
-import org.jbpm.api.client.Execution;
+import org.jbpm.api.client.Token;
import org.jbpm.api.model.Node;
import org.jbpm.api.runtime.preview.FlowHandler;
import org.jbpm.api.runtime.preview.TokenExecutor;
@@ -40,8 +40,8 @@
public void execute(RuntimeContext rtContext)
{
TokenExecutor tokenExecutor = rtContext.getTokenExecutor();
- Node node = rtContext.getNode();
- Execution token = rtContext.getToken();
+ Token token = rtContext.getToken();
+ Node node = token.getCurrentNode();
// Call the next Interceptor
rtContext.next();
Added: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/InProcessTokenExecutor.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/InProcessTokenExecutor.java (rev 0)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/InProcessTokenExecutor.java 2008-11-12 14:28:34 UTC (rev 2893)
@@ -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.jbpm.ri.runtime;
+
+//$Id$
+
+import org.jbpm.api.NotImplementedException;
+import org.jbpm.api.client.Process;
+import org.jbpm.api.client.Token;
+import org.jbpm.api.client.Process.ProcessStatus;
+import org.jbpm.api.client.Token.TokenStatus;
+import org.jbpm.api.model.SequenceFlow;
+import org.jbpm.api.runtime.preview.TokenExecutor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A TokenExecutor that works in the Thread of the calling client
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 12-Nov-2008
+ */
+public class InProcessTokenExecutor implements TokenExecutor
+{
+ // provide logging
+ final static Logger log = LoggerFactory.getLogger(InProcessTokenExecutor.class);
+
+ private Process proc;
+
+ public InProcessTokenExecutor(Process proc)
+ {
+ this.proc = proc;
+ }
+
+ public void create(Token token, SequenceFlow initialFlow)
+ {
+ MutableToken mutableToken = (MutableToken)token;
+ mutableToken.setTokenStatus(TokenStatus.Created);
+ mutableToken.setLastFlow(initialFlow);
+
+ log.debug("Create Token: " + token);
+ }
+
+ public void start(Token token)
+ {
+ ProcessStatus procStatus = proc.getProcessStatus();
+ if (procStatus != ProcessStatus.Ready && procStatus != ProcessStatus.Active)
+ throw new IllegalStateException("Cannot start token to process in state: " + procStatus);
+
+ log.debug("Start Token: " + token);
+ MutableToken mutableToken = (MutableToken)token;
+ mutableToken.setTokenStatus(TokenStatus.Started);
+ }
+
+ public void move(Token token, SequenceFlow flow)
+ {
+ if (flow == null)
+ throw new IllegalArgumentException("Flow cannot be null");
+
+ if (token.getTokenStatus() != TokenStatus.Started)
+ throw new IllegalStateException("Cannot move token in state: " + token.getTokenStatus());
+
+ MutableToken mutableToken = (MutableToken)token;
+ mutableToken.setLastFlow(flow);
+ }
+
+ public void stop(Token token)
+ {
+ log.debug("Stop Token: " + token);
+ MutableToken mutableToken = (MutableToken)token;
+ mutableToken.setTokenStatus(TokenStatus.Stoped);
+ }
+
+ public void destroy(Token token)
+ {
+ log.debug("Destroy Token: " + token);
+ MutableToken mutableToken = (MutableToken)token;
+ mutableToken.setTokenStatus(TokenStatus.Destroyed);
+ }
+
+ public String suspend(Token token)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Token activate(String tokenID)
+ {
+ throw new NotImplementedException();
+ }
+}
\ No newline at end of file
Property changes on: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/InProcessTokenExecutor.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/MessageSender.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/MessageSender.java 2008-11-12 11:37:11 UTC (rev 2892)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/MessageSender.java 2008-11-12 14:28:34 UTC (rev 2893)
@@ -25,7 +25,7 @@
import javax.management.ObjectName;
-import org.jbpm.api.client.Execution;
+import org.jbpm.api.client.Token;
import org.jbpm.api.client.ProcessEngine;
import org.jbpm.api.model.Node;
import org.jbpm.api.model.builder.preview.MessageBuilder;
@@ -65,7 +65,7 @@
* Extract message content from the token and send the message
* to it's recipient.
*/
- public void sendMessage(Execution token)
+ public void sendMessage(Token token)
{
ExecutionContext exContext = token.getExecutionContext();
MessageBuilder msgBuilder = new MessageBuilderImpl();
Deleted: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/MutableExecution.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/MutableExecution.java 2008-11-12 11:37:11 UTC (rev 2892)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/MutableExecution.java 2008-11-12 14:28:34 UTC (rev 2893)
@@ -1,63 +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.ri.runtime;
-
-//$Id$
-
-import org.hibernate.Session;
-import org.jbpm.api.client.Execution;
-import org.jbpm.api.model.SequenceFlow;
-
-/**
- * A mutable extension to the Token.
- *
- * @author Thomas.Diesler at jboss.com
- * @since 20-Apr-2007
- */
-public interface MutableExecution extends Execution
-{
- /**
- * Set the token status
- */
- void setExecutionStatus(ExecutionStatus status);
-
- /**
- * Set the associated session
- */
- void setSession(Session session);
-
- /**
- * Set the current SequenceFlow
- */
- void setSequenceFlow(SequenceFlow flow);
-
- /**
- * Create a schallow copy of this Token.
- * The content in the ExecutionContext will be copied by reference.
- */
- MutableExecution copyToken();
-
- /**
- * Merge this Token with another token.
- */
- void mergeToken(Execution token);
-}
\ No newline at end of file
Copied: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/MutableToken.java (from rev 2891, projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/MutableExecution.java)
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/MutableToken.java (rev 0)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/MutableToken.java 2008-11-12 14:28:34 UTC (rev 2893)
@@ -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.jbpm.ri.runtime;
+
+//$Id$
+
+import org.hibernate.Session;
+import org.jbpm.api.client.PersistenceToken;
+import org.jbpm.api.client.Token;
+import org.jbpm.api.model.SequenceFlow;
+
+/**
+ * A mutable extension to the Token.
+ *
+ * @author Thomas.Diesler at jboss.com
+ * @since 20-Apr-2007
+ */
+public interface MutableToken extends PersistenceToken
+{
+ /**
+ * Set the token status
+ */
+ void setTokenStatus(TokenStatus status);
+
+ /**
+ * Set the associated session
+ */
+ void setSession(Session session);
+
+ /**
+ * Set the current SequenceFlow
+ */
+ void setLastFlow(SequenceFlow flow);
+
+ /**
+ * Create a schallow copy of this Token.
+ * The content in the ExecutionContext will be copied by reference.
+ */
+ MutableToken copyToken();
+
+ /**
+ * Merge this Token with another token.
+ */
+ void mergeToken(Token token);
+}
\ No newline at end of file
Modified: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/NodeExecuteInterceptor.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/NodeExecuteInterceptor.java 2008-11-12 11:37:11 UTC (rev 2892)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/NodeExecuteInterceptor.java 2008-11-12 14:28:34 UTC (rev 2893)
@@ -23,6 +23,7 @@
//$Id$
+import org.jbpm.api.client.Token;
import org.jbpm.ri.model.NodeImpl;
/**
@@ -36,7 +37,8 @@
@Override
public void execute(RuntimeContext rtContext)
{
- NodeImpl nodeImpl = (NodeImpl)rtContext.getNode();
+ Token token = rtContext.getToken();
+ NodeImpl nodeImpl = (NodeImpl)token.getCurrentNode();
nodeImpl.execute(rtContext);
}
}
\ No newline at end of file
Modified: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/PersistenceSessionInterceptor.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/PersistenceSessionInterceptor.java 2008-11-12 11:37:11 UTC (rev 2892)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/PersistenceSessionInterceptor.java 2008-11-12 14:28:34 UTC (rev 2893)
@@ -25,7 +25,7 @@
import org.hibernate.Session;
import org.jbpm.api.client.ProcessEngine;
-import org.jbpm.api.client.Execution.ExecutionStatus;
+import org.jbpm.api.client.Token.TokenStatus;
import org.jbpm.api.model.Node;
import org.jbpm.api.service.preview.PersistenceService;
import org.slf4j.Logger;
@@ -44,8 +44,8 @@
@Override
public void execute(RuntimeContext rtContext)
{
- Node node = rtContext.getNode();
- MutableExecution token = (MutableExecution)rtContext.getToken();
+ MutableToken token = (MutableToken)rtContext.getToken();
+ Node node = token.getCurrentNode();
Session session = token.getSession();
try
@@ -64,8 +64,8 @@
}
finally
{
- ExecutionStatus status = token.getExecutionStatus();
- if (status == ExecutionStatus.Destroyed || status == ExecutionStatus.Suspended)
+ TokenStatus status = token.getTokenStatus();
+ if (status == TokenStatus.Destroyed || status == TokenStatus.Suspended)
{
session.close();
token.setSession(null);
Modified: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/RunnableToken.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/RunnableToken.java 2008-11-12 11:37:11 UTC (rev 2892)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/RunnableToken.java 2008-11-12 14:28:34 UTC (rev 2893)
@@ -21,13 +21,11 @@
*/
package org.jbpm.ri.runtime;
-import org.jbpm.api.client.Execution;
import org.jbpm.api.client.Process;
-import org.jbpm.api.client.Execution.ExecutionStatus;
+import org.jbpm.api.client.Token;
import org.jbpm.api.client.Process.ProcessStatus;
+import org.jbpm.api.client.Token.TokenStatus;
import org.jbpm.api.model.Node;
-import org.jbpm.api.model.SequenceFlow;
-import org.jbpm.api.runtime.preview.TokenExecutor;
import org.jbpm.api.service.ProcessInstanceService;
import org.jbpm.ri.model.ProcessImpl;
import org.jbpm.ri.service.ProcessServiceImpl;
@@ -46,18 +44,18 @@
final static Logger log = LoggerFactory.getLogger(RunnableToken.class);
private RuntimeProcess rtProc;
- private TokenExecutor tokenExecutor;
- private MutableExecution token;
+ private ThreadingTokenExecutor tokenExecutor;
+ private MutableToken token;
private boolean releaseThread;
- public RunnableToken(TokenExecutorImpl tokenExecutorImpl, RuntimeProcess rtProc, MutableExecution token)
+ public RunnableToken(ThreadingTokenExecutor tokenExecutor, RuntimeProcess rtProc, MutableToken token)
{
- this.tokenExecutor = rtProc.getTokenExecutor();
+ this.tokenExecutor = tokenExecutor;
this.rtProc = rtProc;
this.token = token;
}
- public Execution getToken()
+ public Token getToken()
{
return token;
}
@@ -72,28 +70,29 @@
Process proc = rtProc.getProcess();
try
{
- SequenceFlow flow = token.getSequenceFlow();
- if (flow == null)
- throw new IllegalStateException("Cannot obtain initial flow");
+ Node node = token.getCurrentNode();
+ if (node == null)
+ throw new IllegalStateException("Cannot obtain initial node");
- while (continueTokenThread())
+ RuntimeContext rtContext = new RuntimeContext(tokenExecutor);
+
+ // Add the interceptors that are defined on the ProcessService
+ ProcessServiceImpl procService = (ProcessServiceImpl)node.getProcessEngine().getService(ProcessInstanceService.class);
+ for (NodeInterceptor itor : procService.getNodeInterceptors())
+ rtContext.addInterceptor(itor);
+
+ while (continueTokenExecution())
{
// Get the target node
- String targetRef = token.getSequenceFlow().getTargetRef();
- Node node = proc.getNode(targetRef);
+ node = token.getCurrentNode();
// Synchronize on the target Node
synchronized (node)
{
// Create a Token that includes node properties
DelegatingToken tokCopy = new DelegatingToken(token);
- RuntimeContext rtContext = new RuntimeContext(tokenExecutor, tokCopy);
+ rtContext.setToken(tokCopy);
- // Add the interceptors that are defined on the ProcessService
- ProcessServiceImpl procService = (ProcessServiceImpl)node.getProcessEngine().getService(ProcessInstanceService.class);
- for (NodeInterceptor itor : procService.getNodeInterceptors())
- rtContext.addInterceptor(itor);
-
// Call the interceptor chain
rtContext.next();
}
@@ -105,9 +104,9 @@
((ProcessImpl)proc).setRuntimeException(rte);
log.debug("Terminate all suspended tokens");
- for (Execution auxToken : tokenExecutor.getRunnableTokens())
+ for (Token auxToken : tokenExecutor.getRunnableTokens())
{
- if (auxToken.getExecutionStatus() == ExecutionStatus.Suspended)
+ if (auxToken.getTokenStatus() == TokenStatus.Suspended)
tokenExecutor.destroy(auxToken);
}
@@ -121,11 +120,11 @@
}
}
- private boolean continueTokenThread()
+ private boolean continueTokenExecution()
{
- ExecutionStatus tokStatus = token.getExecutionStatus();
+ TokenStatus tokStatus = token.getTokenStatus();
ProcessStatus procStatus = rtProc.getProcess().getProcessStatus();
- return releaseThread == false && procStatus == ProcessStatus.Active && tokStatus == ExecutionStatus.Started;
+ return releaseThread == false && procStatus == ProcessStatus.Active && tokStatus == TokenStatus.Started;
}
private void notifyRuntimeProcess()
Modified: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/RuntimeContext.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/RuntimeContext.java 2008-11-12 11:37:11 UTC (rev 2892)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/RuntimeContext.java 2008-11-12 14:28:34 UTC (rev 2893)
@@ -26,8 +26,7 @@
import java.util.ArrayList;
import java.util.List;
-import org.jbpm.api.client.Execution;
-import org.jbpm.api.model.Node;
+import org.jbpm.api.client.Token;
import org.jbpm.api.runtime.preview.TokenExecutor;
/**
@@ -38,16 +37,15 @@
*/
public class RuntimeContext
{
- List<NodeInterceptor> interceptors = new ArrayList<NodeInterceptor>();
- int itorIndex;
+ private List<NodeInterceptor> interceptors = new ArrayList<NodeInterceptor>();
+ private int itorIndex;
- TokenExecutor tokenExecutor;
- MutableExecution token;
+ private TokenExecutor tokenExecutor;
+ private MutableToken token;
- public RuntimeContext(TokenExecutor tokenExecutor, MutableExecution token)
+ public RuntimeContext(TokenExecutor tokenExecutor)
{
this.tokenExecutor = tokenExecutor;
- this.token = token;
}
public TokenExecutor getTokenExecutor()
@@ -55,17 +53,17 @@
return tokenExecutor;
}
- public Node getNode()
+ public Token getToken()
{
- String targetRef = token.getSequenceFlow().getTargetRef();
- return token.getProcess().getNode(targetRef);
+ return token;
}
- public Execution getToken()
+ public void setToken(MutableToken token)
{
- return token;
+ this.token = token;
+ this.itorIndex = 0;
}
-
+
void addInterceptor(NodeInterceptor itor)
{
interceptors.add(itor);
Modified: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/RuntimeProcess.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/RuntimeProcess.java 2008-11-12 11:37:11 UTC (rev 2892)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/RuntimeProcess.java 2008-11-12 14:28:34 UTC (rev 2893)
@@ -27,8 +27,9 @@
import org.jbpm.api.runtime.preview.TokenExecutor;
/**
- * A RuntimeProcess add runtime behaviour to the {@link Process} <p/> To protect the engine from maligious user code it
- * does not extend {@link Process} directly.
+ * A RuntimeProcess add runtime behaviour to the {@link Process}
+ * <p/>
+ * To protect the engine from maligious user code it does not extend {@link Process} directly.
*
* @author thomas.diesler at jboss.com
* @since 08-Jul-2008
@@ -43,5 +44,5 @@
/**
* Get the {@link TokenExecutor} for this {@link Process}
*/
- TokenExecutor getTokenExecutor();
+ ThreadingTokenExecutor getTokenExecutor();
}
\ No newline at end of file
Modified: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/RuntimeProcessImpl.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/RuntimeProcessImpl.java 2008-11-12 11:37:11 UTC (rev 2892)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/RuntimeProcessImpl.java 2008-11-12 14:28:34 UTC (rev 2893)
@@ -24,7 +24,6 @@
//$Id$
import org.jbpm.api.client.Process;
-import org.jbpm.api.runtime.preview.TokenExecutor;
/**
* A RuntimeProcess add runtime behaviour to the {@link Process}
@@ -35,12 +34,12 @@
public class RuntimeProcessImpl implements RuntimeProcess
{
private Process proc;
- private TokenExecutor tokenExecutor;
+ private ThreadingTokenExecutor tokenExecutor;
public RuntimeProcessImpl(Process proc)
{
this.proc = proc;
- this.tokenExecutor = new TokenExecutorImpl(this);
+ this.tokenExecutor = new ThreadingTokenExecutor(this);
}
public Process getProcess()
@@ -48,7 +47,7 @@
return proc;
}
- public TokenExecutor getTokenExecutor()
+ public ThreadingTokenExecutor getTokenExecutor()
{
return tokenExecutor;
}
Modified: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/SignalHandlerInterceptor.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/SignalHandlerInterceptor.java 2008-11-12 11:37:11 UTC (rev 2892)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/SignalHandlerInterceptor.java 2008-11-12 14:28:34 UTC (rev 2893)
@@ -23,7 +23,7 @@
//$Id$
-import org.jbpm.api.client.Execution;
+import org.jbpm.api.client.Token;
import org.jbpm.api.model.Node;
import org.jbpm.api.runtime.preview.SignalHandler;
@@ -38,8 +38,8 @@
@Override
public void execute(RuntimeContext rtContext)
{
- Node node = rtContext.getNode();
- Execution token = rtContext.getToken();
+ Token token = rtContext.getToken();
+ Node node = token.getCurrentNode();
try
{
Added: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/ThreadingTokenExecutor.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/ThreadingTokenExecutor.java (rev 0)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/ThreadingTokenExecutor.java 2008-11-12 14:28:34 UTC (rev 2893)
@@ -0,0 +1,194 @@
+/*
+ * 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.ri.runtime;
+
+//$Id$
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import org.jbpm.api.client.Token;
+import org.jbpm.api.client.Token.TokenStatus;
+import org.jbpm.api.client.Process.ProcessStatus;
+import org.jbpm.api.model.SequenceFlow;
+import org.jbpm.api.runtime.preview.FlowHandler;
+import org.jbpm.api.runtime.preview.TokenExecutor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The {@link FlowHandler} invokes the TokenExecutor to schedule {@link SequenceFlow} objects together with their
+ * associated {@link Token}.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+public class ThreadingTokenExecutor implements TokenExecutor
+{
+ // provide logging
+ final static Logger log = LoggerFactory.getLogger(ThreadingTokenExecutor.class);
+
+ private RuntimeProcess rtProc;
+ private ExecutorService executor = Executors.newCachedThreadPool();
+ Map<String, RunnableToken> runnableTokens = new HashMap<String, RunnableToken>();
+
+ public ThreadingTokenExecutor(RuntimeProcess rtProc)
+ {
+ this.rtProc = rtProc;
+ }
+
+ public Set<Token> getRunnableTokens()
+ {
+ synchronized (runnableTokens)
+ {
+ Set<Token> tokenSet = new HashSet<Token>();
+ for (RunnableToken rt : runnableTokens.values())
+ tokenSet.add(rt.getToken());
+
+ return Collections.unmodifiableSet(tokenSet);
+ }
+ }
+
+ public boolean hasRunnableTokens()
+ {
+ synchronized (runnableTokens)
+ {
+ return runnableTokens.size() > 0;
+ }
+ }
+
+ public void create(Token token, SequenceFlow initialFlow)
+ {
+ synchronized (runnableTokens)
+ {
+ MutableToken mutableToken = (MutableToken)token;
+ mutableToken.setTokenStatus(TokenStatus.Created);
+ mutableToken.setLastFlow(initialFlow);
+
+ log.debug("Create Token: " + token);
+
+ RunnableToken rtToken = new RunnableToken(this, rtProc, mutableToken);
+ runnableTokens.put(token.getTokenID(), rtToken);
+ }
+ }
+
+ public void start(Token token)
+ {
+ synchronized (runnableTokens)
+ {
+ ProcessStatus procStatus = rtProc.getProcess().getProcessStatus();
+ if (procStatus != ProcessStatus.Ready && procStatus != ProcessStatus.Active)
+ throw new IllegalStateException("Cannot start token to process in state: " + procStatus);
+
+ log.debug("Start Token: " + token);
+ MutableToken mutableToken = (MutableToken)token;
+ mutableToken.setTokenStatus(TokenStatus.Started);
+
+ RunnableToken rtToken = runnableTokens.get(token.getTokenID());
+ executor.submit(rtToken);
+ }
+ }
+
+ public void move(Token token, SequenceFlow flow)
+ {
+ synchronized (runnableTokens)
+ {
+ if (flow == null)
+ throw new IllegalArgumentException("Flow cannot be null");
+
+ if (token.getTokenStatus() != TokenStatus.Started)
+ throw new IllegalStateException("Cannot move token in state: " + token.getTokenStatus());
+
+ MutableToken mutableToken = (MutableToken)token;
+ mutableToken.setLastFlow(flow);
+ }
+ }
+
+ public void stop(Token token)
+ {
+ synchronized (runnableTokens)
+ {
+ log.debug("Stop Token: " + token);
+ MutableToken mutableToken = (MutableToken)token;
+ mutableToken.setTokenStatus(TokenStatus.Stoped);
+ }
+ }
+
+ public void destroy(Token token)
+ {
+ synchronized (runnableTokens)
+ {
+ log.debug("Destroy Token: " + token);
+ MutableToken mutableToken = (MutableToken)token;
+ mutableToken.setTokenStatus(TokenStatus.Destroyed);
+ runnableTokens.remove(token.getTokenID());
+ }
+ }
+
+ public String suspend(Token token)
+ {
+ synchronized (runnableTokens)
+ {
+ RunnableToken rtToken = runnableTokens.get(token.getTokenID());
+ if (rtToken == null)
+ throw new IllegalStateException("Not a runnable token: " + token);
+
+ log.debug("Suspend Token: " + token);
+ MutableToken mutableToken = (MutableToken)token;
+ mutableToken.setTokenStatus(TokenStatus.Suspended);
+
+ // Release the thread for a suspended token
+ rtToken.releaseThread();
+
+ return token.getTokenID();
+ }
+ }
+
+ public Token activate(String tokenID)
+ {
+ synchronized (runnableTokens)
+ {
+ RunnableToken rtToken = runnableTokens.get(tokenID);
+ if (rtToken == null)
+ throw new IllegalStateException("Not a runnable token: " + tokenID);
+
+ Token token = rtToken.getToken();
+ if (token.getTokenStatus() != TokenStatus.Suspended)
+ throw new IllegalStateException("Activate token in state: " + token.getTokenStatus());
+
+ log.debug("Activate Token: " + token);
+ MutableToken mutableToken = (MutableToken)token;
+ mutableToken.setTokenStatus(TokenStatus.Started);
+
+ rtToken = new RunnableToken(this, rtProc, mutableToken);
+ runnableTokens.put(token.getTokenID(), rtToken);
+ executor.submit(rtToken);
+
+ return token;
+ }
+ }
+}
\ No newline at end of file
Property changes on: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/ThreadingTokenExecutor.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Deleted: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/TokenExecutorImpl.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/TokenExecutorImpl.java 2008-11-12 11:37:11 UTC (rev 2892)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/TokenExecutorImpl.java 2008-11-12 14:28:34 UTC (rev 2893)
@@ -1,194 +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.ri.runtime;
-
-//$Id$
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-import org.jbpm.api.client.Execution;
-import org.jbpm.api.client.Execution.ExecutionStatus;
-import org.jbpm.api.client.Process.ProcessStatus;
-import org.jbpm.api.model.SequenceFlow;
-import org.jbpm.api.runtime.preview.FlowHandler;
-import org.jbpm.api.runtime.preview.TokenExecutor;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * The {@link FlowHandler} invokes the TokenExecutor to schedule {@link SequenceFlow} objects together with their
- * associated {@link Execution}.
- *
- * @author thomas.diesler at jboss.com
- * @since 08-Jul-2008
- */
-public class TokenExecutorImpl implements TokenExecutor
-{
- // provide logging
- final static Logger log = LoggerFactory.getLogger(TokenExecutorImpl.class);
-
- private RuntimeProcess rtProc;
- private ExecutorService executor = Executors.newCachedThreadPool();
- Map<String, RunnableToken> runnableTokens = new HashMap<String, RunnableToken>();
-
- public TokenExecutorImpl(RuntimeProcess rtProc)
- {
- this.rtProc = rtProc;
- }
-
- public Set<Execution> getRunnableTokens()
- {
- synchronized (runnableTokens)
- {
- Set<Execution> tokenSet = new HashSet<Execution>();
- for (RunnableToken rt : runnableTokens.values())
- tokenSet.add(rt.getToken());
-
- return Collections.unmodifiableSet(tokenSet);
- }
- }
-
- public boolean hasRunnableTokens()
- {
- synchronized (runnableTokens)
- {
- return runnableTokens.size() > 0;
- }
- }
-
- public void create(Execution token, SequenceFlow initialFlow)
- {
- synchronized (runnableTokens)
- {
- MutableExecution mutableToken = (MutableExecution)token;
- mutableToken.setExecutionStatus(ExecutionStatus.Created);
- mutableToken.setSequenceFlow(initialFlow);
-
- log.debug("Create Token: " + token);
-
- RunnableToken rtToken = new RunnableToken(this, rtProc, mutableToken);
- runnableTokens.put(token.getExecutionID(), rtToken);
- }
- }
-
- public void start(Execution token)
- {
- synchronized (runnableTokens)
- {
- ProcessStatus procStatus = rtProc.getProcess().getProcessStatus();
- if (procStatus != ProcessStatus.Ready && procStatus != ProcessStatus.Active)
- throw new IllegalStateException("Cannot start token to process in state: " + procStatus);
-
- log.debug("Start Token: " + token);
- MutableExecution mutableToken = (MutableExecution)token;
- mutableToken.setExecutionStatus(ExecutionStatus.Started);
-
- RunnableToken rtToken = runnableTokens.get(token.getExecutionID());
- executor.submit(rtToken);
- }
- }
-
- public void move(Execution token, SequenceFlow flow)
- {
- synchronized (runnableTokens)
- {
- if (flow == null)
- throw new IllegalArgumentException("Flow cannot be null");
-
- if (token.getExecutionStatus() != ExecutionStatus.Started)
- throw new IllegalStateException("Cannot move token in state: " + token.getExecutionStatus());
-
- MutableExecution mutableToken = (MutableExecution)token;
- mutableToken.setSequenceFlow(flow);
- }
- }
-
- public void stop(Execution token)
- {
- synchronized (runnableTokens)
- {
- log.debug("Stop Token: " + token);
- MutableExecution mutableToken = (MutableExecution)token;
- mutableToken.setExecutionStatus(ExecutionStatus.Stoped);
- }
- }
-
- public void destroy(Execution token)
- {
- synchronized (runnableTokens)
- {
- log.debug("Destroy Token: " + token);
- MutableExecution mutableToken = (MutableExecution)token;
- mutableToken.setExecutionStatus(ExecutionStatus.Destroyed);
- runnableTokens.remove(token.getExecutionID());
- }
- }
-
- public String suspend(Execution token)
- {
- synchronized (runnableTokens)
- {
- RunnableToken rtToken = runnableTokens.get(token.getExecutionID());
- if (rtToken == null)
- throw new IllegalStateException("Not a runnable token: " + token);
-
- log.debug("Suspend Token: " + token);
- MutableExecution mutableToken = (MutableExecution)token;
- mutableToken.setExecutionStatus(ExecutionStatus.Suspended);
-
- // Release the thread for a suspended token
- rtToken.releaseThread();
-
- return token.getExecutionID();
- }
- }
-
- public Execution activate(String tokenID)
- {
- synchronized (runnableTokens)
- {
- RunnableToken rtToken = runnableTokens.get(tokenID);
- if (rtToken == null)
- throw new IllegalStateException("Not a runnable token: " + tokenID);
-
- Execution token = rtToken.getToken();
- if (token.getExecutionStatus() != ExecutionStatus.Suspended)
- throw new IllegalStateException("Activate token in state: " + token.getExecutionStatus());
-
- log.debug("Activate Token: " + token);
- MutableExecution mutableToken = (MutableExecution)token;
- mutableToken.setExecutionStatus(ExecutionStatus.Started);
-
- rtToken = new RunnableToken(this, rtProc, mutableToken);
- runnableTokens.put(token.getExecutionID(), rtToken);
- executor.submit(rtToken);
-
- return token;
- }
- }
-}
\ No newline at end of file
Copied: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/TokenImpl.java (from rev 2891, projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/ExecutionImpl.java)
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/TokenImpl.java (rev 0)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/TokenImpl.java 2008-11-12 14:28:34 UTC (rev 2893)
@@ -0,0 +1,160 @@
+/*
+ * 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.ri.runtime;
+
+//$Id$
+
+import org.hibernate.Session;
+import org.jboss.util.id.UID;
+import org.jbpm.api.client.Token;
+import org.jbpm.api.client.Process;
+import org.jbpm.api.model.Node;
+import org.jbpm.api.model.SequenceFlow;
+import org.jbpm.api.runtime.Attachments;
+import org.jbpm.api.runtime.Attachments.Key;
+import org.jbpm.api.runtime.preview.BasicExecutionContext;
+import org.jbpm.api.runtime.preview.ExecutionContext;
+
+/**
+ * A Token is a descriptive construct used to describe how the flow of a Process will proceed at runtime.
+ *
+ * By tracking how the Token traverses the Flow Objects, gets diverted through alternative paths,
+ * and gets split into parallel paths, the normal Sequence Flow should be completely definable.
+ *
+ * A Token will have a unique identity that can be used to separate multiple Tokens that may exist because of
+ * concurrent process instances or the splitting of the Token for parallel processing within a single process instance.
+ *
+ * @author Thomas.Diesler at jboss.com
+ * @since 20-Apr-2007
+ */
+public class TokenImpl implements MutableToken
+{
+ private String id;
+ private SequenceFlow flow;
+ private ExecutionContext context;
+ private TokenStatus status;
+ private Process process;
+ private Session session;
+
+ /**
+ * Construct a Token with given {@link Attachments}
+ */
+ public TokenImpl(Process process, Attachments att)
+ {
+ this.context = new BasicExecutionContext(att);
+ this.id = new UID().toString();
+ this.status = TokenStatus.Created;
+ this.process = process;
+ }
+
+ @Override
+ public String getTokenID()
+ {
+ return id;
+ }
+
+ @Override
+ public TokenStatus getTokenStatus()
+ {
+ return status;
+ }
+
+ @Override
+ public void setTokenStatus(TokenStatus status)
+ {
+ this.status = status;
+ }
+
+ @Override
+ public Process getProcess()
+ {
+ return process;
+ }
+
+ @Override
+ public ExecutionContext getExecutionContext()
+ {
+ return context;
+ }
+
+ @Override
+ public Node getCurrentNode()
+ {
+ String targetRef = flow.getTargetRef();
+ return getProcess().getNode(targetRef);
+ }
+
+ @Override
+ public SequenceFlow getLastFlow()
+ {
+ return flow;
+ }
+
+ @Override
+ public void setLastFlow(SequenceFlow flow)
+ {
+ this.flow = flow;
+ }
+
+ @Override
+ public void signal()
+ {
+ }
+
+ @Override
+ public Session getSession()
+ {
+ return session;
+ }
+
+ @Override
+ public void setSession(Session session)
+ {
+ this.session = session;
+ }
+
+ @Override
+ public MutableToken copyToken()
+ {
+ return new TokenImpl(process, context);
+ }
+
+ @Override
+ public void mergeToken(Token token)
+ {
+ ExecutionContext mergeContext = token.getExecutionContext();
+ for(Key key : mergeContext.getAttachmentKeys())
+ {
+ Object mergeValue = mergeContext.getAttachment(key.getClassPart(), key.getNamePart());
+ Object existValue = context.getAttachment(key.getClassPart(), key.getNamePart());
+ if (existValue != null && existValue.equals(mergeValue) == false)
+ throw new IllegalStateException("Cannot merge the same key with different values: " + key);
+
+ context.addAttachment(key.getClassPart(), key.getNamePart(), mergeValue);
+ }
+ }
+
+ public String toString()
+ {
+ return "[sf=" + getLastFlow() + ",status=" + getTokenStatus() + ",ctx=" + getExecutionContext() + ",id=" + id + "]";
+ }
+}
\ No newline at end of file
Modified: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/TransactionInterceptor.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/TransactionInterceptor.java 2008-11-12 11:37:11 UTC (rev 2892)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/runtime/TransactionInterceptor.java 2008-11-12 14:28:34 UTC (rev 2893)
@@ -28,7 +28,6 @@
import org.jbpm.api.Constants;
import org.jbpm.api.NotImplementedException;
import org.jbpm.api.Constants.TxType;
-import org.jbpm.api.client.Execution;
import org.jbpm.api.client.ProcessEngine;
import org.jbpm.api.model.Node;
import org.jbpm.api.model.preview.Group;
@@ -51,8 +50,10 @@
@Override
public void execute(RuntimeContext rtContext)
{
- Node node = rtContext.getNode();
- Execution token = rtContext.getToken();
+ MutableToken token = (MutableToken)rtContext.getToken();
+ Node node = token.getCurrentNode();
+
+ // Get persistence session
Session session = token.getSession();
// Get the Thread associated Tx
@@ -92,10 +93,9 @@
service.saveNode(session, node);
// Get TxType of the next node
- String targetRef = token.getSequenceFlow().getTargetRef();
- if (targetRef != null)
+ Node nextNode = token.getCurrentNode();
+ if (nextNode != null)
{
- Node nextNode = node.getProcess().getNode(targetRef);
txTypeNext = getTxType(nextNode);
}
Modified: projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/service/ExecutionServiceImpl.java
===================================================================
--- projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/service/ExecutionServiceImpl.java 2008-11-12 11:37:11 UTC (rev 2892)
+++ projects/spec/trunk/modules/ri/src/main/java/org/jbpm/ri/service/ExecutionServiceImpl.java 2008-11-12 14:28:34 UTC (rev 2893)
@@ -32,7 +32,7 @@
import org.jbpm.api.BPMException;
import org.jbpm.api.InvalidProcessException;
import org.jbpm.api.ProcessTimeoutException;
-import org.jbpm.api.client.Execution;
+import org.jbpm.api.client.Token;
import org.jbpm.api.client.Process;
import org.jbpm.api.client.ProcessEngine;
import org.jbpm.api.client.Process.ProcessStatus;
@@ -53,10 +53,11 @@
import org.jbpm.ri.model.SignalImpl;
import org.jbpm.ri.runtime.DelegatingToken;
import org.jbpm.ri.runtime.ExpressionEvaluator;
-import org.jbpm.ri.runtime.MutableExecution;
+import org.jbpm.ri.runtime.MutableToken;
import org.jbpm.ri.runtime.RuntimeProcess;
import org.jbpm.ri.runtime.RuntimeProcessImpl;
-import org.jbpm.ri.runtime.ExecutionImpl;
+import org.jbpm.ri.runtime.ThreadingTokenExecutor;
+import org.jbpm.ri.runtime.TokenImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -121,9 +122,9 @@
boolean startProcessThread = (rtProc == null);
// Create initial Token
- ExecutionImpl initialToken = new ExecutionImpl(proc, att);
+ TokenImpl initialToken = new TokenImpl(proc, att);
InitialFlow initialFlow = new InitialFlow(start);
- initialToken.setSequenceFlow(initialFlow);
+ initialToken.setLastFlow(initialFlow);
// Register the initial Token
rtProc = getRuntimeProcess(proc, true);
@@ -173,9 +174,9 @@
}
// Evaluate the Start time assignments
- private void startTimeAssignments(Process proc, Execution token)
+ private void startTimeAssignments(Process proc, Token token)
{
- DelegatingToken delegatingToken = new DelegatingToken((MutableExecution)token);
+ DelegatingToken delegatingToken = new DelegatingToken((MutableToken)token);
ExecutionContext exContext = token.getExecutionContext();
for (Assignment ass : proc.getAssignments())
{
@@ -320,7 +321,7 @@
public void run()
{
- TokenExecutor tokenExecutor = rtProc.getTokenExecutor();
+ ThreadingTokenExecutor tokenExecutor = rtProc.getTokenExecutor();
ProcessImpl procImpl = (ProcessImpl)rtProc.getProcess();
Process proc = rtProc.getProcess();
Modified: projects/spec/trunk/modules/ri/src/test/java/org/jbpm/test/ri/service/persistence/TaskPersistenceTest.java
===================================================================
--- projects/spec/trunk/modules/ri/src/test/java/org/jbpm/test/ri/service/persistence/TaskPersistenceTest.java 2008-11-12 11:37:11 UTC (rev 2892)
+++ projects/spec/trunk/modules/ri/src/test/java/org/jbpm/test/ri/service/persistence/TaskPersistenceTest.java 2008-11-12 14:28:34 UTC (rev 2893)
@@ -28,7 +28,7 @@
import javax.management.ObjectName;
-import org.jbpm.api.client.Execution;
+import org.jbpm.api.client.Token;
import org.jbpm.api.model.Expression;
import org.jbpm.api.model.Node;
import org.jbpm.api.model.SequenceFlow;
@@ -165,7 +165,7 @@
private static final long serialVersionUID = 1L;
@Override
- public void execute(Execution token)
+ public void execute(Token token)
{
}
@@ -213,12 +213,12 @@
}
@Override
- public void throwEnterSignal(Execution token)
+ public void throwEnterSignal(Token token)
{
}
@Override
- public void throwExitSignal(Execution token)
+ public void throwExitSignal(Token token)
{
}
}
@@ -255,7 +255,7 @@
}
@Override
- public void execute(TokenExecutor tokenExecutor, Execution token)
+ public void execute(TokenExecutor tokenExecutor, Token token)
{
}
}
More information about the jbpm-commits
mailing list