[jbpm-commits] JBoss JBPM SVN: r1738 - in jbossbpm/spec/trunk/modules: api/src/main/java/org/jboss/bpm/runtime and 5 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Mon Jul 28 11:46:17 EDT 2008
Author: thomas.diesler at jboss.com
Date: 2008-07-28 11:46:17 -0400 (Mon, 28 Jul 2008)
New Revision: 1738
Added:
jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/PropertyBuilder.java
jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/PropertyBuilderFactory.java
jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/Executable.java
jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/MutablePropertySupport.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/PropertyBuilderFactoryImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/PropertyBuilderImpl.java
Removed:
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ExecutionHandlerImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/FlowHandlerImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/MutablePropertySupport.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/SignalHandlerImpl.java
Modified:
jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/GatewayBuilder.java
jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/InputSet.java
jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/OutputSet.java
jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/SequenceFlow.java
jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/BasicAttachments.java
jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/ExecutionHandler.java
jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/Token.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/client/internal/ExecutionManagerImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ActivityBuilderImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ActivityImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/EndEventImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ExclusiveGatewayDataBasedImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ExclusiveGatewayImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ExpressionImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/FlowObjectImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/GateImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/GatewayBuilderImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/GatewayImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/InputSetImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/IntermediateEventImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/MessageBuilderImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/MessageImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/OutputSetImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ReceiveTaskImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/SendTaskImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/SequenceFlowImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/StartEventImpl.java
jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/airticket/AirticketTest.java
jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/task/TaskA.java
jbossbpm/spec/trunk/modules/testsuite/src/test/resources/jbpm-beans.xml
Log:
Add MVEL gates
Modified: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/GatewayBuilder.java
===================================================================
--- jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/GatewayBuilder.java 2008-07-28 14:22:17 UTC (rev 1737)
+++ jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/GatewayBuilder.java 2008-07-28 15:46:17 UTC (rev 1738)
@@ -32,6 +32,9 @@
*/
public interface GatewayBuilder extends ProcessBuilder
{
+ GatewayBuilder addDefaultGate(String targetName);
+
+ GatewayBuilder addConditionalGate(String targetName, Expression.ExpressionLanguage exprLang, String exprBody);
+
GatewayBuilder addGate(String targetName);
-
}
\ No newline at end of file
Modified: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/InputSet.java
===================================================================
--- jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/InputSet.java 2008-07-28 14:22:17 UTC (rev 1737)
+++ jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/InputSet.java 2008-07-28 15:46:17 UTC (rev 1738)
@@ -25,13 +25,15 @@
import java.util.List;
+import org.jboss.bpm.runtime.MutablePropertySupport;
+
/**
* An InputSet, which is used in the definition of common attributes for Activities and for attributes of a Process
*
* @author thomas.diesler at jboss.com
* @since 21-Jul-2008
*/
-public interface InputSet extends SupportingElement
+public interface InputSet extends SupportingElement, MutablePropertySupport
{
/**
* Zero or more ArtifactInputs MAY be defined for each InputSet. For the
Modified: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/OutputSet.java
===================================================================
--- jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/OutputSet.java 2008-07-28 14:22:17 UTC (rev 1737)
+++ jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/OutputSet.java 2008-07-28 15:46:17 UTC (rev 1738)
@@ -25,13 +25,15 @@
import java.util.List;
+import org.jboss.bpm.runtime.MutablePropertySupport;
+
/**
* An OuputSet, which is used in the definition of common attributes for Activities and for attributes of a Process
*
* @author thomas.diesler at jboss.com
* @since 21-Jul-2008
*/
-public interface OutputSet extends SupportingElement
+public interface OutputSet extends SupportingElement, MutablePropertySupport
{
/**
* Zero or more ArtifactOutputs MAY be defined for each OutputSet. For the
Added: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/PropertyBuilder.java
===================================================================
--- jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/PropertyBuilder.java (rev 0)
+++ jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/PropertyBuilder.java 2008-07-28 15:46:17 UTC (rev 1738)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bpm.model;
+
+//$Id$
+
+/**
+ * A PropertyBuilder can be used to build a {@link Property} dynamically.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+public interface PropertyBuilder
+{
+ /**
+ * Create a {@link Property} with a given name and value
+ */
+ Property newProperty(String name, String value);
+}
\ No newline at end of file
Property changes on: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/PropertyBuilder.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/PropertyBuilderFactory.java
===================================================================
--- jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/PropertyBuilderFactory.java (rev 0)
+++ jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/PropertyBuilderFactory.java 2008-07-28 15:46:17 UTC (rev 1738)
@@ -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.jboss.bpm.model;
+
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.plugins.util.KernelLocator;
+import org.jboss.kernel.spi.registry.KernelRegistryEntry;
+
+//$Id$
+
+/**
+ * A Factory for the {@link PropertyBuilder}.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+public abstract class PropertyBuilderFactory
+{
+ /** The bean name - jBPMMessageBuilderFactory */
+ public static final String BEAN_NAME = "jBPMPropertyBuilderFactory";
+
+ // Hide the constructor
+ protected PropertyBuilderFactory()
+ {
+ }
+
+ /**
+ * Get a MessageBuilderFactory instance.
+ */
+ public static PropertyBuilderFactory newInstance()
+ {
+ Kernel kernel = KernelLocator.getKernel();
+ KernelRegistryEntry entry = kernel.getRegistry().getEntry(BEAN_NAME);
+ return (PropertyBuilderFactory)entry.getTarget();
+ }
+
+ /**
+ * Get a {@link PropertyBuilder}.
+ */
+ public abstract PropertyBuilder newPropertyBuilder();
+}
\ No newline at end of file
Property changes on: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/PropertyBuilderFactory.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/SequenceFlow.java
===================================================================
--- jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/SequenceFlow.java 2008-07-28 14:22:17 UTC (rev 1737)
+++ jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/SequenceFlow.java 2008-07-28 15:46:17 UTC (rev 1738)
@@ -38,7 +38,7 @@
/**
* The ConditionType
*/
- enum ConditionType
+ public enum ConditionType
{
None, Expression, Default
}
Modified: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/BasicAttachments.java
===================================================================
--- jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/BasicAttachments.java 2008-07-28 14:22:17 UTC (rev 1737)
+++ jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/BasicAttachments.java 2008-07-28 15:46:17 UTC (rev 1738)
@@ -116,4 +116,9 @@
{
return (T)attachments.remove(new Key(null, name));
}
+
+ public String toString()
+ {
+ return attachments.toString();
+ }
}
Added: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/Executable.java
===================================================================
--- jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/Executable.java (rev 0)
+++ jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/Executable.java 2008-07-28 15:46:17 UTC (rev 1738)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bpm.runtime;
+
+//$Id$
+
+/**
+ * Marks Flow Objects as executable.
+ *
+ * @author Thomas.Diesler at jboss.com
+ * @since 20-Apr-2007
+ */
+public interface Executable
+{
+ /**
+ * Engine calls this to execute the @{link FlowObject}
+ */
+ void execute(Token token);
+}
\ No newline at end of file
Property changes on: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/Executable.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/ExecutionHandler.java
===================================================================
--- jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/ExecutionHandler.java 2008-07-28 14:22:17 UTC (rev 1737)
+++ jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/ExecutionHandler.java 2008-07-28 15:46:17 UTC (rev 1738)
@@ -25,9 +25,11 @@
import org.jboss.bpm.client.ProcessEngine;
import org.jboss.bpm.model.FlowObject;
+import org.jboss.bpm.model.InputSet;
+import org.jboss.bpm.model.OutputSet;
/**
- * The {@link ProcessEngine} invokes the ExecutionHandler on an {@link HandlerSupport}
+ * The {@link ProcessEngine} invokes the ExecutionHandler on a
* {@link FlowObject} to execute user provided business logic.
*
* @author thomas.diesler at jboss.com
@@ -36,8 +38,8 @@
public interface ExecutionHandler extends Handler
{
/**
- * Execute business logic associated with a {@link FlowObject}
+ * Execute the associated business logic.
*/
- void execute(Token token);
+ void execute(Token token, InputSet input, OutputSet output);
}
\ No newline at end of file
Copied: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/MutablePropertySupport.java (from rev 1734, jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/MutablePropertySupport.java)
===================================================================
--- jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/MutablePropertySupport.java (rev 0)
+++ jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/MutablePropertySupport.java 2008-07-28 15:46:17 UTC (rev 1738)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bpm.runtime;
+
+import org.jboss.bpm.model.Property;
+import org.jboss.bpm.model.PropertySupport;
+
+//$Id$
+
+/**
+ * Mutable property support
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 21-Jul-2008
+ */
+public interface MutablePropertySupport extends PropertySupport
+{
+ /**
+ * Add a property
+ */
+ void addProperty(Property prop);
+}
\ No newline at end of file
Modified: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/Token.java
===================================================================
--- jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/Token.java 2008-07-28 14:22:17 UTC (rev 1737)
+++ jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/Token.java 2008-07-28 15:46:17 UTC (rev 1738)
@@ -78,6 +78,11 @@
return new Token(proc, context);
}
+ public String toString()
+ {
+ return "[proc=" + proc.getID() + ",ctx=" + context + "]";
+ }
+
static class InitialContext extends BasicAttachments implements ExecutionContext
{
InitialContext(Attachments att)
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/client/internal/ExecutionManagerImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/client/internal/ExecutionManagerImpl.java 2008-07-28 14:22:17 UTC (rev 1737)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/client/internal/ExecutionManagerImpl.java 2008-07-28 15:46:17 UTC (rev 1738)
@@ -37,7 +37,7 @@
import org.jboss.bpm.model.internal.RuntimeProcessImpl;
import org.jboss.bpm.model.internal.SequenceFlowImpl;
import org.jboss.bpm.runtime.Attachments;
-import org.jboss.bpm.runtime.ExecutionHandler;
+import org.jboss.bpm.runtime.Executable;
import org.jboss.bpm.runtime.FlowHandler;
import org.jboss.bpm.runtime.MutableFlowScheduler;
import org.jboss.bpm.runtime.RuntimeProcess;
@@ -71,10 +71,6 @@
// TODO: one thread per process is not scalable
ProcessRunner runner = new ProcessRunner(procImpl, att);
new Thread(runner).start();
-
- // Throw possible exception from the runner
- // if (runner.getException() != null)
- // throw runner.getException();
}
private void startProcessInternal(ProcessImpl proc, Attachments att)
@@ -99,7 +95,7 @@
// Get the target and its handlers
FlowObject target = (FlowObject)flow.getTargetRef();
- ExecutionHandler exHandler = getExecutionHandler(target);
+ Executable executable = getExecutable(target);
SignalHandler sigHandler = getSignalHandler(target);
FlowHandler flowHandler = getFlowHandler(target);
@@ -107,7 +103,7 @@
try
{
throwSignal(sigHandler.getEnterSignal());
- exHandler.execute(token);
+ executable.execute(token);
}
finally
{
@@ -134,6 +130,14 @@
}
}
+ private Executable getExecutable(FlowObject target)
+ {
+ if (target instanceof Executable == false)
+ throw new IllegalStateException("Flow Object is not executable: " + target);
+
+ return (Executable)target;
+ }
+
/**
* The initial flow 'to' the StartEvent
*/
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ActivityBuilderImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ActivityBuilderImpl.java 2008-07-28 14:22:17 UTC (rev 1737)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ActivityBuilderImpl.java 2008-07-28 15:46:17 UTC (rev 1738)
@@ -74,7 +74,7 @@
public ActivityBuilder addIORule(String body, ExpressionLanguage lang)
{
- ExpressionImpl expr = new ExpressionImpl(body, lang);
+ ExpressionImpl expr = new ExpressionImpl(lang, body);
getActivity().addIORule(expr);
return this;
}
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ActivityImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ActivityImpl.java 2008-07-28 14:22:17 UTC (rev 1737)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ActivityImpl.java 2008-07-28 15:46:17 UTC (rev 1738)
@@ -25,7 +25,9 @@
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -38,11 +40,16 @@
import org.jboss.bpm.model.OutputSet;
import org.jboss.bpm.model.Process;
import org.jboss.bpm.model.Property;
+import org.jboss.bpm.model.PropertyBuilder;
+import org.jboss.bpm.model.Expression.ExpressionLanguage;
+import org.jboss.bpm.runtime.ExecutionContext;
import org.jboss.bpm.runtime.ExecutionHandler;
import org.jboss.bpm.runtime.FlowHandler;
import org.jboss.bpm.runtime.FlowScheduler;
+import org.jboss.bpm.runtime.MutablePropertySupport;
import org.jboss.bpm.runtime.Token;
import org.jboss.bpm.runtime.FlowScheduler.Tuple;
+import org.mvel.MVEL;
/**
* An activity is a generic term for work that a company or organization performs via business processes. An activity
@@ -181,22 +188,141 @@
this.outFlow = flow;
}
- public ExecutionHandler getExecutionHandler()
+ @Override
+ public void execute(Token token)
{
- ExecutionHandler handler = super.getExecutionHandler();
- if (handler == null)
+ OutputSetImpl outputSet = new OutputSetImpl();
+ InputSet inputSet = getActiveInputSet(token);
+ executeHandler(token, inputSet, outputSet);
+ processOutputSet(token, outputSet);
+ postProcessInputSet(token, inputSet);
+ }
+
+ /**
+ * Select and validate active inputSet
+ */
+ protected InputSet getActiveInputSet(Token token)
+ {
+ InputSetImpl inputSet = null;
+ ExecutionContext exContext = token.getExecutionContext();
+
+ // Find the InputSet that matches the data in the Token
+ if (inputSets.size() > 0)
{
- handler = new ExecutionHandler()
+ for (InputSet auxSet : inputSets)
{
- public void execute(Token token)
+ boolean allInputPropsInContext = true;
+ for (Property prop : auxSet.getProperties())
{
- log.debug("Nothing to do in task: " + getName());
+ Object att = exContext.getAttachment(prop.getName());
+ allInputPropsInContext &= (att != null);
}
- };
+ if (allInputPropsInContext == true)
+ {
+ inputSet = new InputSetImpl();
+ for (Property prop : auxSet.getProperties())
+ {
+ String name = prop.getName();
+ Expression expr = exContext.getAttachment(name);
+ inputSet.addProperty(new PropertyImpl(name, expr));
+ }
+ break;
+ }
+ }
+ if (inputSet == null)
+ throw new IllegalStateException("Cannot find inputSet that matches token: " + token);
}
- return handler;
+
+ // Create an empty input set
+ if (inputSet == null)
+ inputSet = new InputSetImpl();
+
+ return inputSet;
}
+ /**
+ * Execute external business logic
+ */
+ protected void executeHandler(Token token, InputSet inputSet, OutputSet outputSet)
+ {
+ ExecutionHandler handler = getExecutionHandler();
+
+ // Call the execution handler with the InputSet
+ if (handler != null)
+ {
+ handler.execute(token, inputSet, outputSet);
+ }
+ // Assume the the single IORule actually mapps the data
+ else if (outputSets.size() == 1 && ioRules.size() == 1)
+ {
+ PropertyBuilder propBuilder = new PropertyBuilderImpl();
+ OutputSet outSet = outputSets.get(0);
+ if (outSet.getProperties().size() == 1)
+ {
+ Expression expr = ioRules.get(0);
+ if (expr.getExpressionLanguage() == ExpressionLanguage.MVEL)
+ {
+ String mvel = expr.getExpressionBody();
+ Map<String, Object> vars = new HashMap<String, Object>();
+ for (Property prop : inputSet.getProperties())
+ {
+ String name = prop.getName();
+ Object value = prop.getValue().getExpressionBody();
+ vars.put(name, value);
+ }
+ Object result = MVEL.eval(mvel, vars);
+ if (result != null)
+ {
+ String name = outSet.getPropertyNames().get(0);
+ Property prop = propBuilder.newProperty(name, result.toString());
+ outputSet.addProperty(prop);
+ }
+ }
+ else
+ {
+ throw new IllegalStateException("Unsupported expression language: " + expr.getExpressionLanguage());
+ }
+ }
+ }
+ }
+
+ /**
+ * Transfer data from outputSet to Token
+ */
+ protected void processOutputSet(Token token, OutputSet outputSet)
+ {
+ ExecutionContext exContext = token.getExecutionContext();
+
+ // Add the outputSet properties to the Token
+ if (outputSet != null && outputSets.size() > 0)
+ {
+ if (outputSets.size() > 1)
+ throw new NotImplementedException("IORules and multiple outputSets not supported");
+
+ OutputSet auxSet = outputSets.get(0);
+ for (Property prop : auxSet.getProperties())
+ {
+ Property outProp = outputSet.getProperty(prop.getName());
+ if (outProp == null)
+ throw new IllegalStateException("Cannot find required outputSet property: " + prop.getName());
+
+ exContext.addAttachment(outProp.getName(), outProp.getValue().getExpressionBody());
+ }
+ }
+ }
+
+ /**
+ * Remove the inputSet properties
+ */
+ protected void postProcessInputSet(Token token, InputSet inputSet)
+ {
+ ExecutionContext exContext = token.getExecutionContext();
+ for (Property prop : inputSet.getProperties())
+ {
+ exContext.removeAttachment(prop.getName());
+ }
+ }
+
public FlowHandler getFlowHandler()
{
FlowHandler handler = super.getFlowHandler();
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/EndEventImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/EndEventImpl.java 2008-07-28 14:22:17 UTC (rev 1737)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/EndEventImpl.java 2008-07-28 15:46:17 UTC (rev 1738)
@@ -30,8 +30,6 @@
import org.jboss.bpm.model.FlowObject;
import org.jboss.bpm.model.Result;
import org.jboss.bpm.model.Signal;
-import org.jboss.bpm.runtime.Attachments;
-import org.jboss.bpm.runtime.ExecutionHandler;
import org.jboss.bpm.runtime.FlowHandler;
import org.jboss.bpm.runtime.FlowScheduler;
import org.jboss.bpm.runtime.SignalHandler;
@@ -83,29 +81,6 @@
return result;
}
- public ExecutionHandler getExecutionHandler()
- {
- ExecutionHandler handler = super.getExecutionHandler();
- if (handler == null)
- {
- handler = new ExecutionHandler()
- {
- public void execute(final Token token)
- {
- // Provide the result
- result = new Result()
- {
- public Attachments getAttachments()
- {
- return token.getExecutionContext();
- }
- };
- }
- };
- }
- return handler;
- }
-
public FlowHandler getFlowHandler()
{
FlowHandler handler = super.getFlowHandler();
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ExclusiveGatewayDataBasedImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ExclusiveGatewayDataBasedImpl.java 2008-07-28 14:22:17 UTC (rev 1737)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ExclusiveGatewayDataBasedImpl.java 2008-07-28 15:46:17 UTC (rev 1738)
@@ -47,6 +47,7 @@
public Gate getDefaultGate()
{
+
throw new NotImplementedException();
}
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ExclusiveGatewayImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ExclusiveGatewayImpl.java 2008-07-28 14:22:17 UTC (rev 1737)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ExclusiveGatewayImpl.java 2008-07-28 15:46:17 UTC (rev 1738)
@@ -23,10 +23,26 @@
//$Id$
+import java.util.HashMap;
+import java.util.Map;
+
import org.jboss.bpm.model.ExclusiveGateway;
+import org.jboss.bpm.model.Expression;
+import org.jboss.bpm.model.Gate;
+import org.jboss.bpm.model.SequenceFlow;
+import org.jboss.bpm.model.Expression.ExpressionLanguage;
+import org.jboss.bpm.model.SequenceFlow.ConditionType;
+import org.jboss.bpm.runtime.ExecutionContext;
+import org.jboss.bpm.runtime.FlowHandler;
+import org.jboss.bpm.runtime.FlowScheduler;
+import org.jboss.bpm.runtime.Token;
+import org.jboss.bpm.runtime.Attachments.Key;
+import org.jboss.bpm.runtime.FlowScheduler.Tuple;
+import org.mvel.MVEL;
/**
- * A point in the workflow process where, based on a decision or workflow control data, one of several branches is chosen.
+ * A point in the workflow process where, based on a decision or workflow control data, one of several branches is
+ * chosen.
*
* @author thomas.diesler at jboss.com
* @since 08-Jul-2008
@@ -43,6 +59,73 @@
return GatewayType.Exclusive;
}
+ @Override
+ public FlowHandler getFlowHandler()
+ {
+ FlowHandler handler = super.getFlowHandler();
+ if (handler == null && getGates().size() > 1)
+ {
+ handler = new FlowHandler()
+ {
+ public void execute(FlowScheduler scheduler, Token token)
+ {
+ Gate selectedGate = null;
+ for (Gate auxGate : getGates())
+ {
+ SequenceFlow seqFlow = auxGate.getOutgoingSequenceFlow();
+ if (seqFlow.getConditionType() == ConditionType.Expression)
+ {
+ Expression expr = seqFlow.getConditionExpression();
+ if (expr.getExpressionLanguage() == ExpressionLanguage.MVEL)
+ {
+ String mvel = expr.getExpressionBody();
+ ExecutionContext exContext = token.getExecutionContext();
+ Map<String, Object> vars = new HashMap<String, Object>();
+ for (Key key : exContext.getAttachmentKeys())
+ {
+ String name = key.getNamePart();
+ Object value = exContext.getAttachment(name);
+ vars.put(name, value);
+ }
+ Boolean result = (Boolean)MVEL.eval(mvel, vars);
+ if (result == true)
+ {
+ selectedGate = auxGate;
+ break;
+ }
+ }
+ else
+ {
+ throw new IllegalStateException("Unsupported expression language: " + expr.getExpressionLanguage());
+ }
+ }
+ }
+
+ // Fallback to the default gate if there is one
+ if (selectedGate == null)
+ {
+ for (Gate auxGate : getGates())
+ {
+ SequenceFlow seqFlow = auxGate.getOutgoingSequenceFlow();
+ if (seqFlow.getConditionType() == ConditionType.Default)
+ {
+ selectedGate = auxGate;
+ break;
+ }
+ }
+ }
+
+ if (selectedGate == null)
+ throw new IllegalStateException("Cannot select applicable gate for: " + token);
+
+ Tuple tuple = new Tuple(selectedGate.getOutgoingSequenceFlow(), token);
+ scheduler.scheduleTuple(tuple);
+ }
+ };
+ }
+ return handler;
+ }
+
public String toString()
{
return "ExclusiveGateway[" + getName() + "]";
Deleted: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ExecutionHandlerImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ExecutionHandlerImpl.java 2008-07-28 14:22:17 UTC (rev 1737)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ExecutionHandlerImpl.java 2008-07-28 15:46:17 UTC (rev 1738)
@@ -1,50 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.bpm.model.internal;
-
-//$Id$
-
-import org.jboss.bpm.runtime.ExecutionHandler;
-import org.jboss.bpm.runtime.Token;
-
-/**
- * Implement to make the FlowObject executable
- *
- * @author thomas.diesler at jboss.com
- * @since 08-Jul-2008
- */
-public class ExecutionHandlerImpl extends HandlerImpl implements ExecutionHandler
-{
- private ExecutionHandler handler;
-
- /**
- * Execute this flow object
- */
- public void execute(Token token)
- {
- if (handler == null)
- {
- handler = newInstance(ExecutionHandler.class);
- }
- handler.execute(token);
- }
-}
\ No newline at end of file
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ExpressionImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ExpressionImpl.java 2008-07-28 14:22:17 UTC (rev 1737)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ExpressionImpl.java 2008-07-28 15:46:17 UTC (rev 1738)
@@ -42,7 +42,7 @@
this.body = body;
}
- public ExpressionImpl(String body, ExpressionLanguage lang)
+ public ExpressionImpl(ExpressionLanguage lang, String body)
{
this.body = body;
this.lang = lang;
Deleted: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/FlowHandlerImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/FlowHandlerImpl.java 2008-07-28 14:22:17 UTC (rev 1737)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/FlowHandlerImpl.java 2008-07-28 15:46:17 UTC (rev 1738)
@@ -1,48 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.bpm.model.internal;
-
-//$Id$
-
-import org.jboss.bpm.runtime.FlowHandler;
-import org.jboss.bpm.runtime.FlowScheduler;
-import org.jboss.bpm.runtime.Token;
-
-/**
- * Implement to handle the outgoing Flows for an FlowObject
- *
- * @author thomas.diesler at jboss.com
- * @since 08-Jul-2008
- */
-public class FlowHandlerImpl extends HandlerImpl implements FlowHandler
-{
- private FlowHandler handler;
-
- public void execute(FlowScheduler scheduler, Token token)
- {
- if (handler == null)
- {
- handler = newInstance(FlowHandler.class);
- }
- handler.execute(scheduler, token);
- }
-}
\ No newline at end of file
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/FlowObjectImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/FlowObjectImpl.java 2008-07-28 14:22:17 UTC (rev 1737)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/FlowObjectImpl.java 2008-07-28 15:46:17 UTC (rev 1738)
@@ -33,6 +33,7 @@
import org.jboss.bpm.model.Process;
import org.jboss.bpm.model.SingleInFlowSupport;
import org.jboss.bpm.model.SingleOutFlowSupport;
+import org.jboss.bpm.runtime.Executable;
import org.jboss.bpm.runtime.ExecutionHandler;
import org.jboss.bpm.runtime.FlowHandler;
import org.jboss.bpm.runtime.SignalHandler;
@@ -46,7 +47,7 @@
* @author thomas.diesler at jboss.com
* @since 08-Jul-2008
*/
-public abstract class FlowObjectImpl extends GraphicalElementImpl implements FlowObject, HandlerSetterSupport
+public abstract class FlowObjectImpl extends GraphicalElementImpl implements FlowObject, HandlerSetterSupport, Executable
{
private static final long serialVersionUID = 1L;
@@ -86,11 +87,7 @@
public void execute(Token token)
{
- ExecutionHandler handler = getExecutionHandler();
- if (handler != null)
- {
- handler.execute(token);
- }
+ // noting to do
}
@Override
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/GateImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/GateImpl.java 2008-07-28 14:22:17 UTC (rev 1737)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/GateImpl.java 2008-07-28 15:46:17 UTC (rev 1738)
@@ -27,9 +27,11 @@
import org.jboss.bpm.NotImplementedException;
import org.jboss.bpm.model.Assignment;
+import org.jboss.bpm.model.Expression;
import org.jboss.bpm.model.Gate;
import org.jboss.bpm.model.Gateway;
import org.jboss.bpm.model.SequenceFlow;
+import org.jboss.bpm.model.SequenceFlow.ConditionType;
/**
* A {@link Gate} associated with a {@link Gateway}.
@@ -46,6 +48,11 @@
seqFlow = new SequenceFlowImpl(targetName);
}
+ public GateImpl(String targetName, ConditionType type, Expression expr)
+ {
+ seqFlow = new SequenceFlowImpl(targetName, type, expr);
+ }
+
public SequenceFlow getOutgoingSequenceFlow()
{
return seqFlow;
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/GatewayBuilderImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/GatewayBuilderImpl.java 2008-07-28 14:22:17 UTC (rev 1737)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/GatewayBuilderImpl.java 2008-07-28 15:46:17 UTC (rev 1738)
@@ -26,6 +26,8 @@
import org.jboss.bpm.model.Gate;
import org.jboss.bpm.model.Gateway;
import org.jboss.bpm.model.GatewayBuilder;
+import org.jboss.bpm.model.Expression.ExpressionLanguage;
+import org.jboss.bpm.model.SequenceFlow.ConditionType;
/**
* The GatewayBuilder can be used to build a {@link Gateway} dynamically.
@@ -49,6 +51,20 @@
return this;
}
+ public GatewayBuilder addConditionalGate(String targetName, ExpressionLanguage lang, String body)
+ {
+ gate = new GateImpl(targetName, ConditionType.Expression, new ExpressionImpl(lang, body));
+ getGateway().addGate(gate);
+ return this;
+ }
+
+ public GatewayBuilder addDefaultGate(String targetName)
+ {
+ gate = new GateImpl(targetName, ConditionType.Default, null);
+ getGateway().addGate(gate);
+ return this;
+ }
+
private GatewayImpl getGateway()
{
if (flowObject instanceof Gateway == false)
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/GatewayImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/GatewayImpl.java 2008-07-28 14:22:17 UTC (rev 1737)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/GatewayImpl.java 2008-07-28 15:46:17 UTC (rev 1738)
@@ -29,11 +29,12 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.bpm.NotImplementedException;
import org.jboss.bpm.model.Flow;
import org.jboss.bpm.model.FlowObject;
import org.jboss.bpm.model.Gate;
import org.jboss.bpm.model.Gateway;
+import org.jboss.bpm.model.InputSet;
+import org.jboss.bpm.model.OutputSet;
import org.jboss.bpm.model.Signal;
import org.jboss.bpm.runtime.ExecutionHandler;
import org.jboss.bpm.runtime.FlowHandler;
@@ -95,7 +96,7 @@
{
handler = new ExecutionHandler()
{
- public void execute(Token token)
+ public void execute(Token token, InputSet inputSet, OutputSet outputSet)
{
log.debug("Nothing to do in gateway: " + getName());
}
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/InputSetImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/InputSetImpl.java 2008-07-28 14:22:17 UTC (rev 1737)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/InputSetImpl.java 2008-07-28 15:46:17 UTC (rev 1738)
@@ -32,6 +32,7 @@
import org.jboss.bpm.model.ArtifactOutput;
import org.jboss.bpm.model.InputSet;
import org.jboss.bpm.model.Property;
+import org.jboss.bpm.runtime.MutablePropertySupport;
/**
* An InputSet, which is used in the definition of common attributes for Activities and for attributes of a Process
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/IntermediateEventImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/IntermediateEventImpl.java 2008-07-28 14:22:17 UTC (rev 1737)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/IntermediateEventImpl.java 2008-07-28 15:46:17 UTC (rev 1738)
@@ -27,7 +27,9 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.bpm.model.Event;
import org.jboss.bpm.model.Flow;
+import org.jboss.bpm.model.InputSet;
import org.jboss.bpm.model.IntermediateEvent;
+import org.jboss.bpm.model.OutputSet;
import org.jboss.bpm.model.Signal;
import org.jboss.bpm.runtime.ExecutionHandler;
import org.jboss.bpm.runtime.FlowHandler;
@@ -90,7 +92,7 @@
{
handler = new ExecutionHandler()
{
- public void execute(Token token)
+ public void execute(Token token, InputSet inputSet, OutputSet outputSet)
{
log.debug("Nothing to do in event");
}
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/MessageBuilderImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/MessageBuilderImpl.java 2008-07-28 14:22:17 UTC (rev 1737)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/MessageBuilderImpl.java 2008-07-28 15:46:17 UTC (rev 1738)
@@ -25,11 +25,10 @@
import org.jboss.bpm.model.Message;
import org.jboss.bpm.model.MessageBuilder;
-import org.jboss.bpm.model.Process;
import org.jboss.bpm.model.Property;
/**
- * The ProcessBuilder can be used to dynamically build a {@link Process}.
+ * A MessageBuilder can be used to build a {@link Message} dynamically.
*
* @author thomas.diesler at jboss.com
* @since 08-Jul-2008
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/MessageImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/MessageImpl.java 2008-07-28 14:22:17 UTC (rev 1737)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/MessageImpl.java 2008-07-28 15:46:17 UTC (rev 1738)
@@ -30,6 +30,7 @@
import org.jboss.bpm.model.Participant;
import org.jboss.bpm.model.Property;
import org.jboss.bpm.model.PropertySupport;
+import org.jboss.bpm.runtime.MutablePropertySupport;
//$Id$
Deleted: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/MutablePropertySupport.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/MutablePropertySupport.java 2008-07-28 14:22:17 UTC (rev 1737)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/MutablePropertySupport.java 2008-07-28 15:46:17 UTC (rev 1738)
@@ -1,41 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.bpm.model.internal;
-
-import org.jboss.bpm.model.Property;
-import org.jboss.bpm.model.PropertySupport;
-
-//$Id$
-
-/**
- * Mutable property support
- *
- * @author thomas.diesler at jboss.com
- * @since 21-Jul-2008
- */
-public interface MutablePropertySupport extends PropertySupport
-{
- /**
- * Add a property
- */
- void addProperty(Property prop);
-}
\ No newline at end of file
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/OutputSetImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/OutputSetImpl.java 2008-07-28 14:22:17 UTC (rev 1737)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/OutputSetImpl.java 2008-07-28 15:46:17 UTC (rev 1738)
@@ -31,6 +31,7 @@
import org.jboss.bpm.model.ArtifactOutput;
import org.jboss.bpm.model.OutputSet;
import org.jboss.bpm.model.Property;
+import org.jboss.bpm.runtime.MutablePropertySupport;
/**
* An OuputSet, which is used in the definition of common attributes for Activities and for attributes of a Process
Added: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/PropertyBuilderFactoryImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/PropertyBuilderFactoryImpl.java (rev 0)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/PropertyBuilderFactoryImpl.java 2008-07-28 15:46:17 UTC (rev 1738)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bpm.model.internal;
+
+//$Id$
+
+import org.jboss.bpm.model.PropertyBuilder;
+import org.jboss.bpm.model.PropertyBuilderFactory;
+
+/**
+ * A Factory for the {@link PropertyBuilder}.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+public class PropertyBuilderFactoryImpl extends PropertyBuilderFactory
+{
+ @Override
+ public PropertyBuilder newPropertyBuilder()
+ {
+ return new PropertyBuilderImpl();
+ }
+}
\ No newline at end of file
Property changes on: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/PropertyBuilderFactoryImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/PropertyBuilderImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/PropertyBuilderImpl.java (rev 0)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/PropertyBuilderImpl.java 2008-07-28 15:46:17 UTC (rev 1738)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bpm.model.internal;
+
+//$Id$
+
+import org.jboss.bpm.model.Property;
+import org.jboss.bpm.model.PropertyBuilder;
+
+/**
+ * A PropertyBuilder can be used to build a {@link Property} dynamically.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+public class PropertyBuilderImpl implements PropertyBuilder
+{
+ public Property newProperty(String name, String value)
+ {
+ return new PropertyImpl(name, new ExpressionImpl(value));
+ }
+}
\ No newline at end of file
Property changes on: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/PropertyBuilderImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ReceiveTaskImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ReceiveTaskImpl.java 2008-07-28 14:22:17 UTC (rev 1737)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ReceiveTaskImpl.java 2008-07-28 15:46:17 UTC (rev 1738)
@@ -30,7 +30,9 @@
import org.jboss.bpm.NotImplementedException;
import org.jboss.bpm.ProcessTimeoutException;
import org.jboss.bpm.model.Expression;
+import org.jboss.bpm.model.InputSet;
import org.jboss.bpm.model.Message;
+import org.jboss.bpm.model.OutputSet;
import org.jboss.bpm.model.Process;
import org.jboss.bpm.model.Property;
import org.jboss.bpm.model.ReceiveTask;
@@ -111,50 +113,41 @@
}
@Override
- public ExecutionHandler getExecutionHandler()
+ public void execute(Token token)
{
- final Task task = this;
- ExecutionHandler handler = super.getExecutionHandler();
- if (handler == null)
+ // Wait for the message to arrive
+ long now = System.currentTimeMillis();
+ long until = now + RECEIVE_TIMEOUT;
+ while (messages.size() == 0 && now < until)
{
- handler = new ExecutionHandler()
+ try
{
- public void execute(Token token)
- {
- // Wait for the message to arrive
- long now = System.currentTimeMillis();
- long until = now + RECEIVE_TIMEOUT;
- while (messages.size() == 0 && now < until)
- {
- try
- {
- Thread.currentThread().sleep(500);
- now = System.currentTimeMillis();
- }
- catch (InterruptedException ex)
- {
- log.error("ReceiveTask interrupted" + ex.toString());
- }
- }
-
- // Timeout if the message did not arrive
- if (messages.size() == 0)
- throw new ProcessTimeoutException("Message receive timeout in: " + task);
-
- // Copy the expected properties from the
- // received message to the execution context
- ExecutionContext exContext = token.getExecutionContext();
- Message msg = messages.remove(0);
- for (Property prop : messageRef.getProperties())
- {
- String key = prop.getName();
- Expression value = msg.getProperty(key).getValue();
- exContext.addAttachment(key, value);
- }
- }
- };
+ Thread.currentThread().sleep(500);
+ now = System.currentTimeMillis();
+ }
+ catch (InterruptedException ex)
+ {
+ log.error("ReceiveTask interrupted" + ex.toString());
+ }
}
- return handler;
+
+ // Timeout if the message did not arrive
+ if (messages.size() == 0)
+ throw new ProcessTimeoutException("Message receive timeout in: " + this);
+
+ // Copy the expected properties from the
+ // received message to the execution context
+ Message msg = messages.remove(0);
+ ExecutionContext exContext = token.getExecutionContext();
+ for (Property prop : messageRef.getProperties())
+ {
+ String key = prop.getName();
+ Expression value = msg.getProperty(key).getValue();
+ exContext.addAttachment(key, value);
+ }
+
+ // Call default execute
+ super.execute(token);
}
@Override
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/SendTaskImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/SendTaskImpl.java 2008-07-28 14:22:17 UTC (rev 1737)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/SendTaskImpl.java 2008-07-28 15:46:17 UTC (rev 1738)
@@ -24,14 +24,14 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.bpm.InvalidProcessException;
-import org.jboss.bpm.model.Expression;
+import org.jboss.bpm.model.InputSet;
import org.jboss.bpm.model.Message;
import org.jboss.bpm.model.MessageBuilder;
import org.jboss.bpm.model.MessageBuilderFactory;
+import org.jboss.bpm.model.OutputSet;
import org.jboss.bpm.model.Process;
import org.jboss.bpm.model.Property;
import org.jboss.bpm.model.SendTask;
-import org.jboss.bpm.runtime.ExecutionContext;
import org.jboss.bpm.runtime.ExecutionHandler;
import org.jboss.bpm.runtime.Token;
@@ -86,7 +86,7 @@
{
handler = new ExecutionHandler()
{
- public void execute(Token token)
+ public void execute(Token token, InputSet inputSet, OutputSet outputSet)
{
MessageBuilderFactory factory = MessageBuilderFactory.newInstance();
MessageBuilder msgBuilder = factory.newMessageBuilder();
@@ -94,18 +94,14 @@
// Copy the properties from the execution context
// to the send message
- ExecutionContext exContext = token.getExecutionContext();
- for (Property prop : messageRef.getProperties())
+ for (Property auxProp : messageRef.getProperties())
{
- String key = prop.getName();
- Object att = exContext.getAttachment(key);
- if (att == null)
- throw new IllegalStateException("Cannot obtain expression: " + key);
- if (att instanceof Expression == false)
- throw new IllegalStateException("Value is not an expression: " + att);
+ String key = auxProp.getName();
+ Property prop = inputSet.getProperty(key);
+ if (prop == null)
+ throw new IllegalStateException("Cannot obtain property: " + key);
- Expression value = (Expression)att;
- msgBuilder.addProperty(key, value.getExpressionBody());
+ msgBuilder.addProperty(key, prop.getValue().getExpressionBody());
}
Message msg = msgBuilder.getMessage();
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/SequenceFlowImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/SequenceFlowImpl.java 2008-07-28 14:22:17 UTC (rev 1737)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/SequenceFlowImpl.java 2008-07-28 15:46:17 UTC (rev 1738)
@@ -23,32 +23,40 @@
//$Id$
-import org.jboss.bpm.NotImplementedException;
import org.jboss.bpm.model.Expression;
-import org.jboss.bpm.model.GraphicalElement;
import org.jboss.bpm.model.SequenceFlow;
/**
- * A Sequence Flow is a solid graphical line that is used to show the order that Activities will be performed in a Process. Each Flow has only one source and only one
- * target.
+ * A Sequence Flow is a solid graphical line that is used to show the order that Activities will be performed in a Process.
+ * Each Flow has only one source and only one target.
*
* @author thomas.diesler at jboss.com
* @since 08-Jul-2008
*/
public class SequenceFlowImpl extends FlowImpl implements SequenceFlow
{
+ private ConditionType conditionType = ConditionType.None;
+ private Expression conditionExpression;
+
public SequenceFlowImpl(String targetName)
{
super(targetName);
}
- public Expression getConditionExpression()
+ public SequenceFlowImpl(String targetName, ConditionType type, Expression expr)
{
- throw new NotImplementedException();
+ super(targetName);
+ this.conditionType = type;
+ this.conditionExpression = expr;
}
public ConditionType getConditionType()
{
- throw new NotImplementedException();
+ return conditionType;
}
+
+ public Expression getConditionExpression()
+ {
+ return conditionExpression;
+ }
}
\ No newline at end of file
Deleted: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/SignalHandlerImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/SignalHandlerImpl.java 2008-07-28 14:22:17 UTC (rev 1737)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/SignalHandlerImpl.java 2008-07-28 15:46:17 UTC (rev 1738)
@@ -1,56 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.bpm.model.internal;
-
-//$Id$
-
-import org.jboss.bpm.model.Signal;
-import org.jboss.bpm.runtime.SignalHandler;
-
-/**
- * Implement to get signals on enter and exit.
- *
- * @author thomas.diesler at jboss.com
- * @since 08-Jul-2008
- */
-public class SignalHandlerImpl extends HandlerImpl implements SignalHandler
-{
- private SignalHandler handler;
-
- public Signal getEnterSignal()
- {
- if (handler == null)
- {
- handler = newInstance(SignalHandler.class);
- }
- return handler.getEnterSignal();
- }
-
- public Signal getExitSignal()
- {
- if (handler == null)
- {
- handler = newInstance(SignalHandler.class);
- }
- return handler.getExitSignal();
- }
-}
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/StartEventImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/StartEventImpl.java 2008-07-28 14:22:17 UTC (rev 1737)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/StartEventImpl.java 2008-07-28 15:46:17 UTC (rev 1738)
@@ -30,6 +30,8 @@
import org.jboss.bpm.NotImplementedException;
import org.jboss.bpm.model.EventDetail;
import org.jboss.bpm.model.Flow;
+import org.jboss.bpm.model.InputSet;
+import org.jboss.bpm.model.OutputSet;
import org.jboss.bpm.model.Signal;
import org.jboss.bpm.model.StartEvent;
import org.jboss.bpm.runtime.ExecutionHandler;
@@ -75,7 +77,7 @@
{
handler = new ExecutionHandler()
{
- public void execute(Token token)
+ public void execute(Token token, InputSet inputSet, OutputSet outputSet)
{
log.debug("Nothing to do in start-event");
}
Modified: jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/airticket/AirticketTest.java
===================================================================
--- jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/airticket/AirticketTest.java 2008-07-28 14:22:17 UTC (rev 1737)
+++ jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/airticket/AirticketTest.java 2008-07-28 15:46:17 UTC (rev 1738)
@@ -114,7 +114,8 @@
// Build the Validate Gateway
GatewayBuilder gatewayBuilder = procBuilder.addGateway("ValidateGateway", GatewayType.Exclusive);
- gatewayBuilder.addGate("CheckAvailabilityTask").addGate("SendInvalidTask");
+ gatewayBuilder.addConditionalGate("CheckAvailabilityTask", ExpressionLanguage.MVEL, "isReqDataValid == true").
+ addDefaultGate("SendInvalidTask");
// Build the CheckAvailability Task
taskBuilder = procBuilder.addTask("CheckAvailabilityTask", TaskType.None);
Modified: jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/task/TaskA.java
===================================================================
--- jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/task/TaskA.java 2008-07-28 14:22:17 UTC (rev 1737)
+++ jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/task/TaskA.java 2008-07-28 15:46:17 UTC (rev 1738)
@@ -23,7 +23,11 @@
// $Id$
-import org.jboss.bpm.runtime.ExecutionContext;
+import org.jboss.bpm.model.InputSet;
+import org.jboss.bpm.model.OutputSet;
+import org.jboss.bpm.model.Property;
+import org.jboss.bpm.model.PropertyBuilder;
+import org.jboss.bpm.model.PropertyBuilderFactory;
import org.jboss.bpm.runtime.ExecutionHandler;
import org.jboss.bpm.runtime.Token;
@@ -35,9 +39,10 @@
*/
public class TaskA implements ExecutionHandler
{
- public void execute(Token token)
+ public void execute(Token token, InputSet inputSet, OutputSet outputSet)
{
- ExecutionContext ctx = token.getExecutionContext();
- ctx.addAttachment(String.class, "Task: TaskA");
+ PropertyBuilder builder = PropertyBuilderFactory.newInstance().newPropertyBuilder();
+ Property prop = builder.newProperty("SomeString", "Task: TaskA");
+ outputSet.addProperty(prop);
}
}
Modified: jbossbpm/spec/trunk/modules/testsuite/src/test/resources/jbpm-beans.xml
===================================================================
--- jbossbpm/spec/trunk/modules/testsuite/src/test/resources/jbpm-beans.xml 2008-07-28 14:22:17 UTC (rev 1737)
+++ jbossbpm/spec/trunk/modules/testsuite/src/test/resources/jbpm-beans.xml 2008-07-28 15:46:17 UTC (rev 1738)
@@ -13,6 +13,7 @@
<!-- The Builder Factories -->
<bean name="jBPMProcessBuilderFactory" class="org.jboss.bpm.model.internal.ProcessBuilderFactoryImpl"/>
<bean name="jBPMMessageBuilderFactory" class="org.jboss.bpm.model.internal.MessageBuilderFactoryImpl"/>
+ <bean name="jBPMPropertyBuilderFactory" class="org.jboss.bpm.model.internal.PropertyBuilderFactoryImpl"/>
<!-- The ProcessManager -->
<bean name="jBPMProcessManager" class="org.jboss.bpm.client.internal.ProcessManagerImpl">
More information about the jbpm-commits
mailing list