[jboss-svn-commits] JBL Code SVN: r17637 - in labs/jbossrules/trunk/drools-core: src/main/java/org/drools and 35 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Jan 8 20:33:21 EST 2008


Author: KrisVerlaenen
Date: 2008-01-08 20:33:20 -0500 (Tue, 08 Jan 2008)
New Revision: 17637

Added:
   labs/jbossrules/trunk/drools-core/repository/
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/RuleFlowGroupListener.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/event/RuleFlowEventSupport.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/event/RuleFlowStartedEvent.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/ParameterDefinition.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/Process.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/Variable.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/VariableScope.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/Work.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/WorkDefinition.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/WorkDefinitionExtension.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/DataType.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/DataTypeFactory.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/InstanceDataTypeFactory.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/NewInstanceDataTypeFactory.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/BooleanDataType.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/FloatDataType.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/IntegerDataType.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/ListDataType.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/StringDataType.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/UndefinedDataType.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/ParameterDefinitionImpl.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/ProcessImpl.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/VariableImpl.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/VariableScopeImpl.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/WorkDefinitionExtensionImpl.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/WorkDefinitionImpl.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/WorkImpl.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/validation/
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/validation/ProcessValidationError.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/validation/ProcessValidator.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/validation/impl/
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/validation/impl/ProcessValidationErrorImpl.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/ProcessInstance.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/ProcessInstanceFactory.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/VariableScopeInstance.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/WorkItem.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/WorkItemHandler.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/WorkItemListener.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/WorkItemManager.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/impl/
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/impl/ProcessInstanceImpl.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/impl/VariableScopeInstanceImpl.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/impl/WorkItemImpl.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/impl/demo/
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/impl/demo/DoNothingWorkItemHandler.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/impl/demo/SystemOutWorkItemHandler.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/impl/demo/UIWorkItemHandler.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/impl/demo/UIWorkItemHandlerDialog.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/validation/
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/validation/RuleFlowProcessValidator.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/RuleFlowProcessInstanceFactory.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/Connection.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/Constraint.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/Node.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/NodeContainer.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/WorkflowProcess.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/impl/
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/impl/ConnectionImpl.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/impl/ConstraintImpl.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/impl/DroolsConsequenceAction.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/impl/NodeContainerImpl.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/impl/NodeImpl.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/impl/WorkflowProcessImpl.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/node/
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/node/ActionNode.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/node/CompositeNode.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/node/EndNode.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/node/Join.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/node/MilestoneNode.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/node/RuleSetNode.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/node/SequenceNode.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/node/Split.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/node/StartNode.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/node/SubProcessNode.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/node/WorkItemNode.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/NodeInstance.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/NodeInstanceContainer.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/WorkflowProcessInstance.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/ConstraintEvaluator.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/NodeInstanceFactory.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/NodeInstanceFactoryRegistry.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/NodeInstanceImpl.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/ReturnValueConstraintEvaluator.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/RuleConstraintEvaluator.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/WorkflowProcessInstanceImpl.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/factory/
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/factory/CreateNewNodeFactory.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/factory/ReuseNodeFactory.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/ActionNodeInstance.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/CompositeNodeInstance.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/EndNodeInstance.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/JoinInstance.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/MilestoneNodeInstance.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/RuleSetNodeInstance.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/SplitInstance.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/StartNodeInstance.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/SubProcessNodeInstance.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/WorkItemNodeInstance.java
   labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/
   labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/
   labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/node/
   labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/node/EndNodeInstanceTest.java
   labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/node/MockNode.java
   labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/node/MockNodeInstance.java
   labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/node/MockNodeInstanceFactory.java
   labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/node/ProcessNodeInstanceFactoryTest.java
   labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/node/StartNodeInstanceTest.java
Removed:
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/event/RuleFlowEventSupport.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/event/RuleFlowStartedEvent.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/ParameterDefinitionImpl.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/ProcessImpl.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/WorkDefinitionExtensionImpl.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/WorkDefinitionImpl.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/WorkImpl.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/impl/ProcessInstanceImpl.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/impl/SystemOutWorkItemHandler.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/impl/UIWorkItemHandler.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/impl/UIWorkItemHandlerDialog.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/impl/WorkItemImpl.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/core/
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/datatype/
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/instance/
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/ActionNode.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/Connection.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/Constraint.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/EndNode.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/Join.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/MilestoneNode.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/Node.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/RuleFlowProcess.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/RuleFlowProcessValidationError.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/RuleFlowProcessValidator.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/RuleSetNode.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/Split.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/StartNode.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/SubFlowNode.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/Variable.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/WorkItemNode.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/RuleFlowNodeInstance.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/RuleFlowProcessInstance.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/ActionNodeInstanceImpl.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/EndNodeInstanceImpl.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/MilestoneNodeInstanceImpl.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/ProcessNodeInstanceFactory.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/ProcessNodeInstanceFactoryRegistry.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/RuleFlowJoinInstanceImpl.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/RuleFlowNodeInstanceImpl.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/RuleFlowProcessInstanceImpl.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/RuleFlowSequenceNodeInstanceImpl.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/RuleFlowSplitInstanceImpl.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/StartNodeInstanceImpl.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/SubFlowNodeInstanceImpl.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/TaskNodeInstanceImpl.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/factories/CreateNewNodeFactory.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/factories/ReuseNodeFactory.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/factories/RuleSetNodeFactory.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/nodes/
   labs/jbossrules/trunk/drools-core/src/test/java/org/drools/ruleflow/
   labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/EndNodeInstanceImplTest.java
   labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/MockEndNode.java
   labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/MockEndNodeInstance.java
   labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/MockEndNodeInstanceFactory.java
   labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/MockNode.java
   labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/MockNodeInstance.java
   labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/MockNodeInstanceFactory.java
   labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/ProcessNodeInstanceFactoryTest.java
   labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/StartNodeInstanceImplTest.java
Modified:
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ProcessIntegrationException.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/RuleBaseConfiguration.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/WorkingMemory.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/audit/WorkingMemoryLogger.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalRuleBase.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalRuleFlowGroup.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalWorkingMemory.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/RuleFlowGroupImpl.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/event/RuleFlowCompletedEvent.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/event/RuleFlowEvent.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/event/RuleFlowNodeTriggeredEvent.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/Package.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/PackageCompilationData.java
   labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/RuleFlowGroupTest.java
Log:
JBRULES-1408: Refactoring of ruleflow to act as a pluggable process engine

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ProcessIntegrationException.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ProcessIntegrationException.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ProcessIntegrationException.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -16,8 +16,8 @@
  * limitations under the License.
  */
 
+import org.drools.process.core.Process;
 import org.drools.rule.Rule;
-import  org.drools.ruleflow.common.core.Process;
 
 /**
  * Indicates an error integrating a <code>Process</code> or <code>Package</code>

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/RuleBaseConfiguration.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/RuleBaseConfiguration.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/RuleBaseConfiguration.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -27,15 +27,15 @@
 import org.drools.common.AgendaGroupFactory;
 import org.drools.common.ArrayAgendaGroupFactory;
 import org.drools.common.PriorityQueueAgendaGroupFactory;
-import org.drools.ruleflow.core.Node;
-import org.drools.ruleflow.instance.impl.ProcessNodeInstanceFactory;
-import org.drools.ruleflow.instance.impl.ProcessNodeInstanceFactoryRegistry;
 import org.drools.spi.ConflictResolver;
 import org.drools.spi.ConsequenceExceptionHandler;
 import org.drools.temporal.SessionClock;
 import org.drools.temporal.SessionPseudoClock;
 import org.drools.util.ChainedProperties;
 import org.drools.util.ConfFileUtils;
+import org.drools.workflow.core.Node;
+import org.drools.workflow.instance.impl.NodeInstanceFactory;
+import org.drools.workflow.instance.impl.NodeInstanceFactoryRegistry;
 import org.mvel.MVEL;
 
 /**
@@ -110,7 +110,7 @@
     private Map                                shadowProxyExcludes;
     private static final String                STAR             = "*";
 
-    private ProcessNodeInstanceFactoryRegistry processNodeInstanceFactoryRegistry;
+    private NodeInstanceFactoryRegistry processNodeInstanceFactoryRegistry;
 
     private transient ClassLoader              classLoader;
 
@@ -476,7 +476,7 @@
         this.sequentialAgenda = sequentialAgenda;
     }
 
-    public ProcessNodeInstanceFactoryRegistry getProcessNodeInstanceFactoryRegistry() {
+    public NodeInstanceFactoryRegistry getProcessNodeInstanceFactoryRegistry() {
         if ( this.processNodeInstanceFactoryRegistry == null ) {
             initProcessNodeInstanceFactoryRegistry();
         }
@@ -485,7 +485,7 @@
     }
 
     private void initProcessNodeInstanceFactoryRegistry() {
-        this.processNodeInstanceFactoryRegistry = new ProcessNodeInstanceFactoryRegistry();
+        this.processNodeInstanceFactoryRegistry = new NodeInstanceFactoryRegistry();
 
         // split on each space
         String locations[] = this.chainedProperties.getProperty( "processNodeInstanceFactoryRegistry",
@@ -514,11 +514,11 @@
                                                                                   null,
                                                                                   RuleBaseConfiguration.class ) );
         
-        Map<Class< ? extends Node>, ProcessNodeInstanceFactory> map = (Map<Class< ? extends Node>, ProcessNodeInstanceFactory>) MVEL.eval( content,
+        Map<Class< ? extends Node>, NodeInstanceFactory> map = (Map<Class< ? extends Node>, NodeInstanceFactory>) MVEL.eval( content,
                                                                                                                                            new HashMap() );
 
         if ( map != null ) {
-            for ( Entry<Class< ? extends Node>, ProcessNodeInstanceFactory> entry : map.entrySet() ) {
+            for ( Entry<Class< ? extends Node>, NodeInstanceFactory> entry : map.entrySet() ) {
                 this.processNodeInstanceFactoryRegistry.register( entry.getKey(),
                                                                   entry.getValue() );
             }

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/WorkingMemory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/WorkingMemory.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/WorkingMemory.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -18,14 +18,14 @@
 
 import java.util.Collection;
 import java.util.Iterator;
+import java.util.Map;
 
-import org.drools.ruleflow.common.instance.ProcessInstance;
-import org.drools.ruleflow.common.instance.WorkItemManager;
+import org.drools.process.instance.ProcessInstance;
+import org.drools.process.instance.WorkItemManager;
 import org.drools.spi.AgendaFilter;
 import org.drools.spi.AgendaGroup;
 import org.drools.spi.AsyncExceptionHandler;
 import org.drools.spi.GlobalResolver;
-import org.drools.temporal.SessionClock;
 
 /**
  * A knowledge session for a <code>RuleBase</code>.
@@ -341,6 +341,11 @@
     ProcessInstance startProcess(String processId);
 
     /**
+     * Starts a new process instance for the process with the given id. 
+     */
+    ProcessInstance startProcess(String processId, Map<String, Object> parameters);
+
+    /**
      * Returns the list of process instances of this working memory.
      * This list is unmodifiable.
      * @return the list of process instances

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/audit/WorkingMemoryLogger.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/audit/WorkingMemoryLogger.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/audit/WorkingMemoryLogger.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -389,7 +389,7 @@
                                             WorkingMemory workingMemory) {
         filterLogEvent(new RuleFlowNodeLogEvent(LogEvent.BEFORE_RULEFLOW_NODE_TRIGGERED,
                 event.getRuleFlowNodeInstance().getId() + "",
-                event.getRuleFlowNodeInstance().getProcessInstance().getRuleFlowProcess().getNode(event.getRuleFlowNodeInstance().getNodeId()).getName(),
+                event.getRuleFlowNodeInstance().getNode().getName(),
                 event.getRuleFlowProcessInstance().getProcess().getId(), event
                         .getRuleFlowProcessInstance().getProcess().getName()));
     }
@@ -398,7 +398,7 @@
                                            WorkingMemory workingMemory) {
         filterLogEvent(new RuleFlowNodeLogEvent(LogEvent.AFTER_RULEFLOW_NODE_TRIGGERED,
                 event.getRuleFlowNodeInstance().getId() + "",
-                event.getRuleFlowNodeInstance().getProcessInstance().getRuleFlowProcess().getNode(event.getRuleFlowNodeInstance().getNodeId()).getName(),
+                event.getRuleFlowNodeInstance().getNode().getName(),
                 event.getRuleFlowProcessInstance().getProcess().getId(), event
                         .getRuleFlowProcessInstance().getProcess().getName()));
     }

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -48,6 +48,7 @@
 import org.drools.reteoo.ReteooStatefulSession;
 import org.drools.objenesis.Objenesis;
 import org.drools.objenesis.ObjenesisStd;
+import org.drools.process.core.Process;
 import org.drools.rule.CompositePackageClassLoader;
 import org.drools.rule.ImportDeclaration;
 import org.drools.rule.InvalidPatternException;
@@ -55,7 +56,6 @@
 import org.drools.rule.Package;
 import org.drools.rule.PackageCompilationData;
 import org.drools.rule.Rule;
-import org.drools.ruleflow.common.core.Process;
 import org.drools.spi.ExecutorServiceFactory;
 import org.drools.spi.FactHandleFactory;
 import org.drools.util.ObjectHashSet;

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -55,6 +55,10 @@
 import org.drools.event.WorkingMemoryEventListener;
 import org.drools.event.WorkingMemoryEventSupport;
 import org.drools.facttemplates.Fact;
+import org.drools.process.core.Process;
+import org.drools.process.instance.ProcessInstance;
+import org.drools.process.instance.ProcessInstanceFactory;
+import org.drools.process.instance.WorkItemManager;
 import org.drools.reteoo.ClassObjectTypeConf;
 import org.drools.reteoo.FactTemplateTypeConf;
 import org.drools.reteoo.LIANodePropagation;
@@ -63,12 +67,9 @@
 import org.drools.rule.EntryPoint;
 import org.drools.rule.Rule;
 import org.drools.rule.TimeMachine;
-import org.drools.ruleflow.common.core.Process;
-import org.drools.ruleflow.common.instance.ProcessInstance;
-import org.drools.ruleflow.common.instance.WorkItemManager;
 import org.drools.ruleflow.core.RuleFlowProcess;
 import org.drools.ruleflow.instance.RuleFlowProcessInstance;
-import org.drools.ruleflow.instance.impl.RuleFlowProcessInstanceImpl;
+import org.drools.ruleflow.instance.RuleFlowProcessInstanceFactory;
 import org.drools.spi.Activation;
 import org.drools.spi.AgendaFilter;
 import org.drools.spi.AgendaGroup;
@@ -128,7 +129,7 @@
 
     protected AgendaEventSupport                         agendaEventSupport                            = new AgendaEventSupport();
 
-    protected RuleFlowEventSupport                       ruleFlowEventSupport                          = new RuleFlowEventSupport();
+    protected RuleFlowEventSupport                workflowEventSupport                          = new RuleFlowEventSupport();
 
     /** The <code>RuleBase</code> with which this memory is associated. */
     protected transient InternalRuleBase                 ruleBase;
@@ -163,7 +164,9 @@
 
     private int                                          processCounter;
 
-    private WorkItemManager                              taskInstanceManager;
+    private WorkItemManager                              workItemManager;
+    
+    private Map<String, ProcessInstanceFactory>          processInstanceFactories                      = new HashMap();
 
     private TimeMachine                                  timeMachine                                   = new TimeMachine();
 
@@ -216,7 +219,9 @@
             this.discardOnLogicalOverride = false;
         }
 
-        this.taskInstanceManager = new WorkItemManager( this );
+        this.workItemManager = new WorkItemManager( this );
+        this.processInstanceFactories.put(
+            RuleFlowProcess.RULEFLOW_TYPE, new RuleFlowProcessInstanceFactory());
 
         this.typeConfMap = new HashMap<EntryPoint, Map<Object, ObjectTypeConf>>();
     }
@@ -238,7 +243,7 @@
     }
 
     public void setRuleFlowEventSupport(RuleFlowEventSupport ruleFlowEventSupport) {
-        this.ruleFlowEventSupport = ruleFlowEventSupport;
+        this.workflowEventSupport = ruleFlowEventSupport;
     }
 
     public boolean isSequential() {
@@ -309,7 +314,7 @@
     public void addEventListener(final RuleFlowEventListener listener) {
         try {
             this.lock.lock();
-            this.ruleFlowEventSupport.addEventListener( listener );
+            this.workflowEventSupport.addEventListener( listener );
         } finally {
             this.lock.unlock();
         }
@@ -318,7 +323,7 @@
     public void removeEventListener(final RuleFlowEventListener listener) {
         try {
             this.lock.lock();
-            this.ruleFlowEventSupport.removeEventListener( listener );
+            this.workflowEventSupport.removeEventListener( listener );
         } finally {
             this.lock.unlock();
         }
@@ -327,7 +332,7 @@
     public List getRuleFlowEventListeners() {
         try {
             this.lock.lock();
-            return this.ruleFlowEventSupport.getEventListeners();
+            return this.workflowEventSupport.getEventListeners();
         } finally {
             this.lock.unlock();
         }
@@ -1502,7 +1507,7 @@
     }
 
     public RuleFlowEventSupport getRuleFlowEventSupport() {
-        return this.ruleFlowEventSupport;
+        return this.workflowEventSupport;
     }
 
     /**
@@ -1552,27 +1557,36 @@
     }
 
     public ProcessInstance startProcess(final String processId) {
+        return startProcess(processId, null);
+    }
+    
+    public ProcessInstance startProcess(String processId, Map<String, Object> parameters) {
         final Process process = ((InternalRuleBase) getRuleBase()).getProcess( processId );
         if ( process == null ) {
             throw new IllegalArgumentException( "Unknown process ID: " + processId );
         }
-        if ( process instanceof RuleFlowProcess ) {
-            final RuleFlowProcessInstance processInstance = new RuleFlowProcessInstanceImpl();
-            processInstance.setWorkingMemory( this );
-            processInstance.setProcess( process );
-            processInstance.setId( ++processCounter );
-            processInstances.put( new Long( processInstance.getId() ),
-                                  processInstance );
-            getRuleFlowEventSupport().fireBeforeRuleFlowProcessStarted( processInstance,
-                                                                        this );
-            processInstance.start();
-            getRuleFlowEventSupport().fireAfterRuleFlowProcessStarted( processInstance,
-                                                                       this );
+        ProcessInstanceFactory factory = processInstanceFactories.get(process.getType());
+        if (factory == null) {
+            throw new IllegalArgumentException( "Could not create process instance for type: " + process.getType() );
+        }
+        ProcessInstance processInstance = factory.createProcessInstance();
+        processInstance.setWorkingMemory( this );
+        processInstance.setProcess( process );
+        processInstance.setId( ++processCounter );
+        processInstances.put( new Long( processInstance.getId() ),
+                              processInstance );
+        if (parameters != null) {
+            for (Map.Entry<String, Object> entry: parameters.entrySet()) {
+                processInstance.setVariable(entry.getKey(), entry.getValue());
+            }
+        }
+        getRuleFlowEventSupport().fireBeforeRuleFlowProcessStarted( processInstance,
+                                                                    this );
+        processInstance.start();
+        getRuleFlowEventSupport().fireAfterRuleFlowProcessStarted( processInstance,
+                                                                   this );
 
-            return processInstance;
-        } else {
-            throw new IllegalArgumentException( "Unknown process type: " + process.getClass() );
-        }
+        return processInstance;
     }
 
     public Collection getProcessInstances() {
@@ -1586,9 +1600,13 @@
     public void removeProcessInstance(ProcessInstance processInstance) {
         processInstances.remove( processInstance );
     }
+    
+    public void registerProcessInstanceFactory(String type, ProcessInstanceFactory processInstanceFactory) {
+        processInstanceFactories.put(type, processInstanceFactory);
+    }
 
     public WorkItemManager getWorkItemManager() {
-        return taskInstanceManager;
+        return workItemManager;
     }
 
     public List iterateObjectsToList() {

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalRuleBase.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalRuleBase.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalRuleBase.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -24,12 +24,12 @@
 import org.drools.RuleBaseConfiguration;
 import org.drools.StatefulSession;
 import org.drools.objenesis.Objenesis;
+import org.drools.process.core.Process;
 import org.drools.reteoo.Rete;
 import org.drools.reteoo.ReteooWorkingMemory;
 import org.drools.rule.CompositePackageClassLoader;
 import org.drools.rule.MapBackedClassLoader;
 import org.drools.rule.Package;
-import org.drools.ruleflow.common.core.Process;
 import org.drools.spi.FactHandleFactory;
 import org.drools.spi.PropagationContext;
 

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalRuleFlowGroup.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalRuleFlowGroup.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalRuleFlowGroup.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,12 +1,9 @@
 package org.drools.common;
 
-import org.drools.ruleflow.instance.RuleFlowProcessInstance;
 import org.drools.spi.Activation;
 import org.drools.spi.RuleFlowGroup;
 
-public interface InternalRuleFlowGroup
-    extends
-    RuleFlowGroup {
+public interface InternalRuleFlowGroup extends RuleFlowGroup {
 
 	void setWorkingMemory(InternalWorkingMemory workingMemory);
 	
@@ -33,8 +30,8 @@
 
     boolean isActive();
 
-    void triggerCompleted();
+    void addRuleFlowGroupListener(RuleFlowGroupListener listener);
     
-    RuleFlowProcessInstance getProcessInstance();
+    void removeRuleFlowGroupListener(RuleFlowGroupListener listener);
     
 }

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalWorkingMemory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalWorkingMemory.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalWorkingMemory.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -9,12 +9,13 @@
 import org.drools.event.AgendaEventSupport;
 import org.drools.event.RuleFlowEventSupport;
 import org.drools.event.WorkingMemoryEventSupport;
+import org.drools.process.instance.ProcessInstance;
+import org.drools.process.instance.ProcessInstanceFactory;
 import org.drools.reteoo.LIANodePropagation;
 import org.drools.reteoo.ObjectTypeConf;
 import org.drools.rule.EntryPoint;
 import org.drools.rule.Rule;
 import org.drools.rule.TimeMachine;
-import org.drools.ruleflow.common.instance.ProcessInstance;
 import org.drools.spi.Activation;
 import org.drools.spi.FactHandleFactory;
 import org.drools.spi.PropagationContext;
@@ -36,6 +37,8 @@
     public void setAgendaEventSupport(AgendaEventSupport agendaEventSupport);
 
     public void setRuleFlowEventSupport(RuleFlowEventSupport ruleFlowEventSupport);
+    
+    public void registerProcessInstanceFactory(String type, ProcessInstanceFactory nodeInstanceFactory);
 
     public Object getNodeMemory(NodeMemory node);
 

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/RuleFlowGroupImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/RuleFlowGroupImpl.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/RuleFlowGroupImpl.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -16,8 +16,9 @@
  * limitations under the License.
  */
 
-import org.drools.ruleflow.instance.RuleFlowNodeInstance;
-import org.drools.ruleflow.instance.impl.RuleFlowSequenceNodeInstanceImpl;
+import java.util.ArrayList;
+import java.util.List;
+
 import org.drools.spi.Activation;
 import org.drools.util.Iterator;
 import org.drools.util.LinkedList;
@@ -36,9 +37,7 @@
  * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
  *
  */
-public class RuleFlowGroupImpl extends RuleFlowSequenceNodeInstanceImpl
-    implements
-    InternalRuleFlowGroup {
+public class RuleFlowGroupImpl implements InternalRuleFlowGroup {
 
     private static final long     serialVersionUID = 400L;
 
@@ -47,6 +46,7 @@
     private boolean               active           = false;
     private final LinkedList      list;
     private boolean               autoDeactivate   = true;
+    private List<RuleFlowGroupListener> listeners;
 
     /**
      * Construct a <code>RuleFlowGroupImpl</code> with the given name.
@@ -102,9 +102,7 @@
                     activation.getActivationGroupNode().getActivationGroup().removeActivation( activation );
                 }
             }
-            if ( getProcessInstance() != null ) {
-                triggerCompleted();
-            }
+            notifyRuleFlowGroupListeners();
             ((EventSupport) this.workingMemory).getRuleFlowEventSupport()
                     .fireAfterRuleFlowGroupDeactivated(this, this.workingMemory);
         }
@@ -165,7 +163,28 @@
             }
         }
     }
+    
+    public void addRuleFlowGroupListener(RuleFlowGroupListener listener) {
+        if (listeners == null) {
+            listeners = new ArrayList<RuleFlowGroupListener>();
+        }
+        listeners.add(listener);
+    }
 
+    public void removeRuleFlowGroupListener(RuleFlowGroupListener listener) {
+        if (listeners == null) {
+            listeners.remove(listener);
+        }
+    }
+    
+    public void notifyRuleFlowGroupListeners() {
+        if (listeners != null) {
+            for (java.util.Iterator<RuleFlowGroupListener> iterator = listeners.iterator(); iterator.hasNext(); ) {
+                iterator.next().ruleFlowGroupDeactivated();
+            }
+        }
+    }
+
     public boolean isEmpty() {
         return this.list.isEmpty();
     }
@@ -194,13 +213,8 @@
         return this.name.hashCode();
     }
 
-    public void internalTrigger(final RuleFlowNodeInstance parent) {
-        setActive( true );
-    }
-
-    public static class DeactivateCallback
-        implements
-        WorkingMemoryAction {
+    public static class DeactivateCallback implements WorkingMemoryAction {
+        private static final long serialVersionUID = 400L;
         private final InternalRuleFlowGroup ruleFlowGroup;
 
         public DeactivateCallback(InternalRuleFlowGroup ruleFlowGroup) {
@@ -209,9 +223,9 @@
 
         public void execute(InternalWorkingMemory workingMemory) {
             // check whether ruleflow group is still empty first
-            if ( this.ruleFlowGroup.isEmpty() ) {
+            if (this.ruleFlowGroup.isEmpty()) {
                 // deactivate ruleflow group
-                this.ruleFlowGroup.setActive( false );
+                this.ruleFlowGroup.setActive(false);
             }
         }
     }

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/RuleFlowGroupListener.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/RuleFlowGroupListener.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/RuleFlowGroupListener.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,7 @@
+package org.drools.common;
+
+public interface RuleFlowGroupListener {
+
+    void ruleFlowGroupDeactivated();
+    
+}

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/event/RuleFlowCompletedEvent.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/event/RuleFlowCompletedEvent.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/event/RuleFlowCompletedEvent.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-import org.drools.ruleflow.instance.RuleFlowProcessInstance;
+import org.drools.process.instance.ProcessInstance;
 
 /**
  * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
@@ -25,11 +25,11 @@
 
     private static final long serialVersionUID = 400L;
 
-    public RuleFlowCompletedEvent(final RuleFlowProcessInstance instance) {
+    public RuleFlowCompletedEvent(final ProcessInstance instance) {
         super( instance );
     }
 
     public String toString() {
-        return "==>[RuleFlowCompleted(name=" + getRuleFlowProcessInstance().getRuleFlowProcess().getName() + "; id=" + getRuleFlowProcessInstance().getRuleFlowProcess().getId() + ")]";
+        return "==>[ProcessCompleted(name=" + getRuleFlowProcessInstance().getProcess().getName() + "; id=" + getRuleFlowProcessInstance().getProcess().getId() + ")]";
     }
 }
\ No newline at end of file

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/event/RuleFlowEvent.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/event/RuleFlowEvent.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/event/RuleFlowEvent.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -18,7 +18,7 @@
 
 import java.util.EventObject;
 
-import org.drools.ruleflow.instance.RuleFlowProcessInstance;
+import org.drools.process.instance.ProcessInstance;
 
 /**
  * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
@@ -27,12 +27,12 @@
 
     private static final long serialVersionUID = 400L;
 
-    public RuleFlowEvent(final RuleFlowProcessInstance instance) {
+    public RuleFlowEvent(final ProcessInstance instance) {
         super( instance );
     }
 
-    public RuleFlowProcessInstance getRuleFlowProcessInstance() {
-        return (RuleFlowProcessInstance) getSource();
+    public ProcessInstance getRuleFlowProcessInstance() {
+        return (ProcessInstance) getSource();
     }
 
 }
\ No newline at end of file

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/event/RuleFlowEventSupport.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/event/RuleFlowEventSupport.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/event/RuleFlowEventSupport.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,222 +0,0 @@
-package org.drools.event;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.drools.common.InternalWorkingMemory;
-import org.drools.ruleflow.instance.RuleFlowNodeInstance;
-import org.drools.ruleflow.instance.RuleFlowProcessInstance;
-import org.drools.spi.RuleFlowGroup;
-
-/**
- * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
- */
-public class RuleFlowEventSupport
-    implements
-    Serializable {
-
-    private static final long serialVersionUID = 400L;
-    private final List        listeners        = Collections.synchronizedList( new ArrayList() );
-
-    public RuleFlowEventSupport() {
-    }
-
-    public void addEventListener(final RuleFlowEventListener listener) {
-        if ( !this.listeners.contains( listener ) ) {
-            this.listeners.add( listener );
-        }
-    }
-
-    public void removeEventListener(final RuleFlowEventListener listener) {
-        this.listeners.remove( listener );
-    }
-
-    public List getEventListeners() {
-        return Collections.unmodifiableList( this.listeners );
-    }
-
-    public int size() {
-        return this.listeners.size();
-    }
-
-    public boolean isEmpty() {
-        return this.listeners.isEmpty();
-    }
-
-    public void fireBeforeRuleFlowProcessStarted(
-            final RuleFlowProcessInstance instance,
-            final InternalWorkingMemory workingMemory) {
-        if (this.listeners.isEmpty()) {
-            return;
-        }
-
-        final RuleFlowStartedEvent event = new RuleFlowStartedEvent(instance);
-
-        for (int i = 0, size = this.listeners.size(); i < size; i++) {
-            ((RuleFlowEventListener) this.listeners.get(i))
-                    .beforeRuleFlowStarted(event, workingMemory);
-        }
-    }
-
-    public void fireAfterRuleFlowProcessStarted(
-            final RuleFlowProcessInstance instance,
-            final InternalWorkingMemory workingMemory) {
-        if (this.listeners.isEmpty()) {
-            return;
-        }
-
-        final RuleFlowStartedEvent event = new RuleFlowStartedEvent(instance);
-
-        for (int i = 0, size = this.listeners.size(); i < size; i++) {
-            ((RuleFlowEventListener) this.listeners.get(i))
-                    .afterRuleFlowStarted(event, workingMemory);
-        }
-    }
-
-    public void fireBeforeRuleFlowProcessCompleted(
-            final RuleFlowProcessInstance instance,
-            final InternalWorkingMemory workingMemory) {
-        if (this.listeners.isEmpty()) {
-            return;
-        }
-
-        final RuleFlowCompletedEvent event = new RuleFlowCompletedEvent(
-                instance);
-
-        for (int i = 0, size = this.listeners.size(); i < size; i++) {
-            ((RuleFlowEventListener) this.listeners.get(i))
-                    .beforeRuleFlowCompleted(event, workingMemory);
-        }
-    }
-
-    public void fireAfterRuleFlowProcessCompleted(
-            final RuleFlowProcessInstance instance,
-            final InternalWorkingMemory workingMemory) {
-        if (this.listeners.isEmpty()) {
-            return;
-        }
-
-        final RuleFlowCompletedEvent event = new RuleFlowCompletedEvent(
-                instance);
-
-        for (int i = 0, size = this.listeners.size(); i < size; i++) {
-            ((RuleFlowEventListener) this.listeners.get(i))
-                    .afterRuleFlowCompleted(event, workingMemory);
-        }
-    }
-
-    public void fireBeforeRuleFlowGroupActivated(
-            final RuleFlowGroup ruleFlowGroup,
-            final InternalWorkingMemory workingMemory) {
-        if (this.listeners.isEmpty()) {
-            return;
-        }
-
-        final RuleFlowGroupActivatedEvent event = new RuleFlowGroupActivatedEvent(
-                ruleFlowGroup);
-
-        for (int i = 0, size = this.listeners.size(); i < size; i++) {
-            ((RuleFlowEventListener) this.listeners.get(i))
-                    .beforeRuleFlowGroupActivated(event, workingMemory);
-        }
-    }
-
-    public void fireAfterRuleFlowGroupActivated(
-            final RuleFlowGroup ruleFlowGroup,
-            final InternalWorkingMemory workingMemory) {
-        if (this.listeners.isEmpty()) {
-            return;
-        }
-
-        final RuleFlowGroupActivatedEvent event = new RuleFlowGroupActivatedEvent(
-                ruleFlowGroup);
-
-        for (int i = 0, size = this.listeners.size(); i < size; i++) {
-            ((RuleFlowEventListener) this.listeners.get(i))
-                    .afterRuleFlowGroupActivated(event, workingMemory);
-        }
-    }
-
-    public void fireBeforeRuleFlowGroupDeactivated(
-            final RuleFlowGroup ruleFlowGroup,
-            final InternalWorkingMemory workingMemory) {
-        if (this.listeners.isEmpty()) {
-            return;
-        }
-
-        final RuleFlowGroupDeactivatedEvent event = new RuleFlowGroupDeactivatedEvent(
-                ruleFlowGroup);
-
-        for (int i = 0, size = this.listeners.size(); i < size; i++) {
-            ((RuleFlowEventListener) this.listeners.get(i))
-                    .beforeRuleFlowGroupDeactivated(event, workingMemory);
-        }
-    }
-
-    public void fireAfterRuleFlowGroupDeactivated(
-            final RuleFlowGroup ruleFlowGroup,
-            final InternalWorkingMemory workingMemory) {
-        if (this.listeners.isEmpty()) {
-            return;
-        }
-
-        final RuleFlowGroupDeactivatedEvent event = new RuleFlowGroupDeactivatedEvent(
-                ruleFlowGroup);
-
-        for (int i = 0, size = this.listeners.size(); i < size; i++) {
-            ((RuleFlowEventListener) this.listeners.get(i))
-                    .afterRuleFlowGroupDeactivated(event, workingMemory);
-        }
-    }
-
-    public void fireBeforeRuleFlowNodeTriggered(
-            final RuleFlowNodeInstance ruleFlowNodeInstance,
-            final InternalWorkingMemory workingMemory) {
-        if (this.listeners.isEmpty()) {
-            return;
-        }
-
-        final RuleFlowNodeTriggeredEvent event = new RuleFlowNodeTriggeredEvent(
-                ruleFlowNodeInstance);
-
-        for (int i = 0, size = this.listeners.size(); i < size; i++) {
-            ((RuleFlowEventListener) this.listeners.get(i))
-                    .beforeRuleFlowNodeTriggered(event, workingMemory);
-        }
-    }
-
-    public void fireAfterRuleFlowNodeTriggered(
-            final RuleFlowNodeInstance ruleFlowNodeInstance,
-            final InternalWorkingMemory workingMemory) {
-        if (this.listeners.isEmpty()) {
-            return;
-        }
-
-        final RuleFlowNodeTriggeredEvent event = new RuleFlowNodeTriggeredEvent(
-                ruleFlowNodeInstance);
-
-        for (int i = 0, size = this.listeners.size(); i < size; i++) {
-            ((RuleFlowEventListener) this.listeners.get(i))
-                    .afterRuleFlowNodeTriggered(event, workingMemory);
-        }
-    }
-
-}
\ No newline at end of file

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/event/RuleFlowEventSupport.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/event/RuleFlowEventSupport.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/event/RuleFlowEventSupport.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,223 @@
+package org.drools.event;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.drools.common.InternalWorkingMemory;
+import org.drools.process.instance.ProcessInstance;
+import org.drools.spi.RuleFlowGroup;
+import org.drools.workflow.instance.NodeInstance;
+import org.drools.workflow.instance.WorkflowProcessInstance;
+
+/**
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class RuleFlowEventSupport implements Serializable {
+    
+    // TODO separate out process level stuff
+
+    private static final long serialVersionUID = 400L;
+    private final List        listeners        = Collections.synchronizedList( new ArrayList() );
+
+    public RuleFlowEventSupport() {
+    }
+
+    public void addEventListener(final RuleFlowEventListener listener) {
+        if ( !this.listeners.contains( listener ) ) {
+            this.listeners.add( listener );
+        }
+    }
+
+    public void removeEventListener(final RuleFlowEventListener listener) {
+        this.listeners.remove( listener );
+    }
+
+    public List getEventListeners() {
+        return Collections.unmodifiableList( this.listeners );
+    }
+
+    public int size() {
+        return this.listeners.size();
+    }
+
+    public boolean isEmpty() {
+        return this.listeners.isEmpty();
+    }
+
+    public void fireBeforeRuleFlowProcessStarted(
+            final ProcessInstance instance,
+            final InternalWorkingMemory workingMemory) {
+        if (this.listeners.isEmpty()) {
+            return;
+        }
+
+        final RuleFlowStartedEvent event = new RuleFlowStartedEvent(instance);
+
+        for (int i = 0, size = this.listeners.size(); i < size; i++) {
+            ((RuleFlowEventListener) this.listeners.get(i))
+                    .beforeRuleFlowStarted(event, workingMemory);
+        }
+    }
+
+    public void fireAfterRuleFlowProcessStarted(
+            final ProcessInstance instance,
+            final InternalWorkingMemory workingMemory) {
+        if (this.listeners.isEmpty()) {
+            return;
+        }
+
+        final RuleFlowStartedEvent event = new RuleFlowStartedEvent(instance);
+
+        for (int i = 0, size = this.listeners.size(); i < size; i++) {
+            ((RuleFlowEventListener) this.listeners.get(i))
+                    .afterRuleFlowStarted(event, workingMemory);
+        }
+    }
+
+    public void fireBeforeRuleFlowProcessCompleted(
+            final WorkflowProcessInstance instance,
+            final InternalWorkingMemory workingMemory) {
+        if (this.listeners.isEmpty()) {
+            return;
+        }
+
+        final RuleFlowCompletedEvent event = new RuleFlowCompletedEvent(
+                instance);
+
+        for (int i = 0, size = this.listeners.size(); i < size; i++) {
+            ((RuleFlowEventListener) this.listeners.get(i))
+                    .beforeRuleFlowCompleted(event, workingMemory);
+        }
+    }
+
+    public void fireAfterRuleFlowProcessCompleted(
+            final WorkflowProcessInstance instance,
+            final InternalWorkingMemory workingMemory) {
+        if (this.listeners.isEmpty()) {
+            return;
+        }
+
+        final RuleFlowCompletedEvent event = new RuleFlowCompletedEvent(
+                instance);
+
+        for (int i = 0, size = this.listeners.size(); i < size; i++) {
+            ((RuleFlowEventListener) this.listeners.get(i))
+                    .afterRuleFlowCompleted(event, workingMemory);
+        }
+    }
+
+    public void fireBeforeRuleFlowGroupActivated(
+            final RuleFlowGroup ruleFlowGroup,
+            final InternalWorkingMemory workingMemory) {
+        if (this.listeners.isEmpty()) {
+            return;
+        }
+
+        final RuleFlowGroupActivatedEvent event = new RuleFlowGroupActivatedEvent(
+                ruleFlowGroup);
+
+        for (int i = 0, size = this.listeners.size(); i < size; i++) {
+            ((RuleFlowEventListener) this.listeners.get(i))
+                    .beforeRuleFlowGroupActivated(event, workingMemory);
+        }
+    }
+
+    public void fireAfterRuleFlowGroupActivated(
+            final RuleFlowGroup ruleFlowGroup,
+            final InternalWorkingMemory workingMemory) {
+        if (this.listeners.isEmpty()) {
+            return;
+        }
+
+        final RuleFlowGroupActivatedEvent event = new RuleFlowGroupActivatedEvent(
+                ruleFlowGroup);
+
+        for (int i = 0, size = this.listeners.size(); i < size; i++) {
+            ((RuleFlowEventListener) this.listeners.get(i))
+                    .afterRuleFlowGroupActivated(event, workingMemory);
+        }
+    }
+
+    public void fireBeforeRuleFlowGroupDeactivated(
+            final RuleFlowGroup ruleFlowGroup,
+            final InternalWorkingMemory workingMemory) {
+        if (this.listeners.isEmpty()) {
+            return;
+        }
+
+        final RuleFlowGroupDeactivatedEvent event = new RuleFlowGroupDeactivatedEvent(
+                ruleFlowGroup);
+
+        for (int i = 0, size = this.listeners.size(); i < size; i++) {
+            ((RuleFlowEventListener) this.listeners.get(i))
+                    .beforeRuleFlowGroupDeactivated(event, workingMemory);
+        }
+    }
+
+    public void fireAfterRuleFlowGroupDeactivated(
+            final RuleFlowGroup ruleFlowGroup,
+            final InternalWorkingMemory workingMemory) {
+        if (this.listeners.isEmpty()) {
+            return;
+        }
+
+        final RuleFlowGroupDeactivatedEvent event = new RuleFlowGroupDeactivatedEvent(
+                ruleFlowGroup);
+
+        for (int i = 0, size = this.listeners.size(); i < size; i++) {
+            ((RuleFlowEventListener) this.listeners.get(i))
+                    .afterRuleFlowGroupDeactivated(event, workingMemory);
+        }
+    }
+
+    public void fireBeforeRuleFlowNodeTriggered(
+            final NodeInstance ruleFlowNodeInstance,
+            final InternalWorkingMemory workingMemory) {
+        if (this.listeners.isEmpty()) {
+            return;
+        }
+
+        final RuleFlowNodeTriggeredEvent event = new RuleFlowNodeTriggeredEvent(
+                ruleFlowNodeInstance);
+
+        for (int i = 0, size = this.listeners.size(); i < size; i++) {
+            ((RuleFlowEventListener) this.listeners.get(i))
+                    .beforeRuleFlowNodeTriggered(event, workingMemory);
+        }
+    }
+
+    public void fireAfterRuleFlowNodeTriggered(
+            final NodeInstance ruleFlowNodeInstance,
+            final InternalWorkingMemory workingMemory) {
+        if (this.listeners.isEmpty()) {
+            return;
+        }
+
+        final RuleFlowNodeTriggeredEvent event = new RuleFlowNodeTriggeredEvent(
+                ruleFlowNodeInstance);
+
+        for (int i = 0, size = this.listeners.size(); i < size; i++) {
+            ((RuleFlowEventListener) this.listeners.get(i))
+                    .afterRuleFlowNodeTriggered(event, workingMemory);
+        }
+    }
+
+}
\ No newline at end of file

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/event/RuleFlowNodeTriggeredEvent.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/event/RuleFlowNodeTriggeredEvent.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/event/RuleFlowNodeTriggeredEvent.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-import org.drools.ruleflow.instance.RuleFlowNodeInstance;
+import org.drools.workflow.instance.NodeInstance;
 
 /**
  * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
@@ -25,19 +25,19 @@
 
     private static final long serialVersionUID = 400L;
     
-    private RuleFlowNodeInstance nodeInstance;
+    private NodeInstance nodeInstance;
 
-    public RuleFlowNodeTriggeredEvent(final RuleFlowNodeInstance nodeInstance) {
+    public RuleFlowNodeTriggeredEvent(final NodeInstance nodeInstance) {
         super( nodeInstance.getProcessInstance() );
         this.nodeInstance = nodeInstance;
     }
     
-    public RuleFlowNodeInstance getRuleFlowNodeInstance() {
+    public NodeInstance getRuleFlowNodeInstance() {
         return nodeInstance;
     }
 
     public String toString() {
-        return "==>[RuleFlowNodeTriggered(nodeId=" + nodeInstance.getNodeId() + "; id=" + nodeInstance.getId() 
-            + "; processName=" + getRuleFlowProcessInstance().getRuleFlowProcess().getName() + "; processId=" + getRuleFlowProcessInstance().getRuleFlowProcess().getId() + ")]";
+        return "==>[WorkflowNodeTriggered(nodeId=" + nodeInstance.getNodeId() + "; id=" + nodeInstance.getId() 
+            + "; processName=" + getRuleFlowProcessInstance().getProcess().getName() + "; processId=" + getRuleFlowProcessInstance().getProcess().getId() + ")]";
     }
 }
\ No newline at end of file

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/event/RuleFlowStartedEvent.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/event/RuleFlowStartedEvent.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/event/RuleFlowStartedEvent.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,35 +0,0 @@
-package org.drools.event;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import org.drools.ruleflow.instance.RuleFlowProcessInstance;
-
-/**
- * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
- */
-public class RuleFlowStartedEvent extends RuleFlowEvent {
-
-    private static final long serialVersionUID = 400L;
-
-    public RuleFlowStartedEvent(final RuleFlowProcessInstance instance) {
-        super( instance );
-    }
-
-    public String toString() {
-        return "==>[RuleFlowStarted(name=" + getRuleFlowProcessInstance().getRuleFlowProcess().getName() + "; id=" + getRuleFlowProcessInstance().getRuleFlowProcess().getId() + ")]";
-    }
-}
\ No newline at end of file

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/event/RuleFlowStartedEvent.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/event/RuleFlowStartedEvent.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/event/RuleFlowStartedEvent.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,35 @@
+package org.drools.event;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.process.instance.ProcessInstance;
+
+/**
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class RuleFlowStartedEvent extends RuleFlowEvent {
+
+    private static final long serialVersionUID = 400L;
+
+    public RuleFlowStartedEvent(final ProcessInstance instance) {
+        super( instance );
+    }
+
+    public String toString() {
+        return "==>[ProcessStarted(name=" + getRuleFlowProcessInstance().getProcess().getName() + "; id=" + getRuleFlowProcessInstance().getProcess().getId() + ")]";
+    }
+}
\ No newline at end of file

Copied: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/ParameterDefinition.java (from rev 17570, labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/core/ParameterDefinition.java)
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/ParameterDefinition.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/ParameterDefinition.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,17 @@
+package org.drools.process.core;
+
+import org.drools.process.core.datatype.DataType;
+
+/**
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public interface ParameterDefinition {
+    
+    String getName();
+    void setName(String name);
+    
+    DataType getType();
+    void setType(DataType type);
+    
+}

Copied: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/Process.java (from rev 17570, labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/core/Process.java)
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/Process.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/Process.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,96 @@
+package org.drools.process.core;
+
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Represents a some process definition.
+ * A process has a name and a unique id.
+ * When a new version of a process is created, the name stays the same,
+ * but the id and the version of the process should be different.
+ * Different types of processes could be defined (like RuleFlow).
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public interface Process extends VariableScope {
+
+    /**
+     * Sets the id of this process.
+     * The id should uniquely identify this process.
+     * @param id the id of the process
+     */
+    void setId(String id);
+
+    /**
+     * Returns the id of this process.
+     * @return the id of this process
+     */
+    String getId();
+
+    /**
+     * Sets the name of this process.
+     * @param name the name of this process
+     */
+    void setName(String name);
+
+    /**
+     * Returns the name of this process.
+     * If no name is specified, null is returned.
+     * @return the name of this process
+     */
+    String getName();
+
+    /**
+     * Sets the version of this process.
+     * @param version the version of this process
+     */
+    void setVersion(String version);
+
+    /**
+     * Returns the version of this process.
+     * If no version is specified, null is returned.
+     * @return the version of this process
+     */
+    String getVersion();
+
+    /**
+     * Sets the type of this process.
+     * @param type the type of this process
+     */
+    void setType(String type);
+
+    /**
+     * Returns the type of this process.
+     * @return the type of this process
+     */
+    String getType();
+    
+    /**
+     * Sets the package name of this RuleFlow process
+     * 
+     * @param packageName	the package name of this RuleFlow process
+     */
+    void setPackageName(String packageName);
+
+    /**
+     * Returns the package name of this RuleFlow process
+     * 
+     * @return	the package name of this RuleFlow process
+     */
+    String getPackageName();
+
+}

Copied: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/Variable.java (from rev 17570, labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/Variable.java)
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/Variable.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/Variable.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,44 @@
+package org.drools.process.core;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.Serializable;
+
+import org.drools.process.core.datatype.DataType;
+
+/**
+ * Represents a global variable used in a RuleFlow.
+ * A variable has a name (should be unique for this process), a datatype
+ * and possibly an initial value.  
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public interface Variable {
+
+    String getName();
+
+    void setName(String name);
+
+    DataType getType();
+
+    void setType(DataType type);
+
+    Serializable getValue();
+
+    void setValue(Serializable value);
+
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/VariableScope.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/VariableScope.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/VariableScope.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,34 @@
+package org.drools.process.core;
+
+import java.util.List;
+
+
+/**
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public interface VariableScope {
+
+    /**
+     * Returns the variables used in this scope
+     * 
+     * @return  a list of variables of this scope
+     */
+    List<Variable> getVariables();
+
+    /**
+     * Returns the names of the variables used in this scope
+     * 
+     * @return  the variable names of this scope
+     */
+    String[] getVariableNames();
+    
+    /**
+     * Sets the variables used in this scope
+     * 
+     * @param variables the variables
+     * @throws IllegalArugmentException if <code>variables</code> is null
+     */
+    void setVariables(List<Variable> variables);
+    
+}

Copied: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/Work.java (from rev 17570, labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/core/Work.java)
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/Work.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/Work.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,19 @@
+package org.drools.process.core;
+
+import java.util.Map;
+
+/**
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public interface Work {
+
+    void setName(String name);
+    String getName();
+    
+    void setParameter(String name, Object value);
+    void setParameters(Map<String, Object> parameters);
+    Object getParameter(String name);
+    Map<String, Object> getParameters();
+
+}

Copied: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/WorkDefinition.java (from rev 17570, labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/core/WorkDefinition.java)
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/WorkDefinition.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/WorkDefinition.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,21 @@
+package org.drools.process.core;
+
+import java.util.Set;
+
+/**
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public interface WorkDefinition {
+    
+    String getName();
+    
+    Set<ParameterDefinition> getParameters();
+    String[] getParameterNames();
+    ParameterDefinition getParameter(String name);
+    
+    Set<ParameterDefinition> getResults();
+    String[] getResultNames();
+    ParameterDefinition getResult(String name);
+    
+}

Copied: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/WorkDefinitionExtension.java (from rev 17570, labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/core/WorkDefinitionExtension.java)
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/WorkDefinitionExtension.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/WorkDefinitionExtension.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,15 @@
+package org.drools.process.core;
+
+/**
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public interface WorkDefinitionExtension {
+    
+    String getDisplayName();
+    
+    String getExplanationText();
+    
+    String getIcon();
+
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/DataType.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/DataType.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/DataType.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,33 @@
+package org.drools.process.core.datatype;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.Serializable;
+
+/**
+ * Abstract representation of a datatype.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public interface DataType extends Serializable {
+
+    /**
+     * Returns true if the given value is a valid value of this data type.
+     */
+    boolean verifyDataType(Object value);
+
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/DataTypeFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/DataTypeFactory.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/DataTypeFactory.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,31 @@
+package org.drools.process.core.datatype;
+
+import java.io.Serializable;
+
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * A factory for creating a datatype.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public interface DataTypeFactory extends Serializable {
+
+    DataType createDataType();
+
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/InstanceDataTypeFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/InstanceDataTypeFactory.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/InstanceDataTypeFactory.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,55 @@
+package org.drools.process.core.datatype.impl;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.process.core.datatype.DataType;
+import org.drools.process.core.datatype.DataTypeFactory;
+
+/**
+ * A data type factory that always returns the same instance of a given class.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class InstanceDataTypeFactory implements DataTypeFactory {
+
+    private static final long serialVersionUID = 400L;
+    
+    private Class<?> dataTypeClass;
+    private DataType instance;
+
+    public InstanceDataTypeFactory(final Class<?> dataTypeClass) {
+        this.dataTypeClass = dataTypeClass;
+    }
+
+    public DataType createDataType() {
+        if (this.instance == null) {
+            try {
+                this.instance = (DataType) this.dataTypeClass.newInstance();
+            } catch (final IllegalAccessException e) {
+                throw new RuntimeException(
+                        "Could not create data type for class "
+                                + this.dataTypeClass, e);
+            } catch (final InstantiationException e) {
+                throw new RuntimeException(
+                        "Could not create data type for class "
+                                + this.dataTypeClass, e);
+            }
+        }
+        return this.instance;
+    }
+
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/NewInstanceDataTypeFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/NewInstanceDataTypeFactory.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/NewInstanceDataTypeFactory.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,49 @@
+package org.drools.process.core.datatype.impl;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.process.core.datatype.DataType;
+import org.drools.process.core.datatype.DataTypeFactory;
+
+/**
+ * A data type factory that always returns a new instance of a given class.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class NewInstanceDataTypeFactory implements DataTypeFactory {
+
+    private static final long serialVersionUID = 400L;
+    
+    private Class<? extends DataType> dataTypeClass;
+
+    public NewInstanceDataTypeFactory(final Class<? extends DataType> dataTypeClass) {
+        this.dataTypeClass = dataTypeClass;
+    }
+
+    public DataType createDataType() {
+        try {
+            return this.dataTypeClass.newInstance();
+        } catch (final IllegalAccessException e) {
+            throw new RuntimeException("Could not create data type for class "
+                    + this.dataTypeClass, e);
+        } catch (final InstantiationException e) {
+            throw new RuntimeException("Could not create data type for class "
+                    + this.dataTypeClass, e);
+        }
+    }
+
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/BooleanDataType.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/BooleanDataType.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/BooleanDataType.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,38 @@
+package org.drools.process.core.datatype.impl.type;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.process.core.datatype.DataType;
+
+/**
+ * Representation of a boolean datatype.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public final class BooleanDataType
+    implements
+    DataType {
+
+    private static final long serialVersionUID = 400L;
+
+    public boolean verifyDataType(final Object value) {
+        if ( value instanceof Boolean ) {
+            return true;
+        }
+        return false;
+    }
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/FloatDataType.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/FloatDataType.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/FloatDataType.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,41 @@
+package org.drools.process.core.datatype.impl.type;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.process.core.datatype.DataType;
+
+/**
+ * Representation of a float datatype.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public final class FloatDataType
+    implements
+    DataType {
+
+    private static final long serialVersionUID = 400L;
+
+    public boolean verifyDataType(final Object value) {
+        if ( value instanceof Float ) {
+            return true;
+        } else if ( value == null ) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/IntegerDataType.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/IntegerDataType.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/IntegerDataType.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,41 @@
+package org.drools.process.core.datatype.impl.type;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.process.core.datatype.DataType;
+
+/**
+ * Representation of an integer datatype.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class IntegerDataType
+    implements
+    DataType {
+
+    private static final long serialVersionUID = 400L;
+
+    public boolean verifyDataType(final Object value) {
+        if ( value instanceof Integer ) {
+            return true;
+        } else if ( value == null ) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/ListDataType.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/ListDataType.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/ListDataType.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,59 @@
+package org.drools.process.core.datatype.impl.type;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.Serializable;
+import java.util.Iterator;
+import java.util.List;
+
+import org.drools.process.core.datatype.DataType;
+
+/**
+ * Representation of a list datatype.
+ * All elements in the list must have the same datatype.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ListDataType implements DataType, Serializable {
+
+    private static final long serialVersionUID = 400L;
+
+    private DataType dataType;
+
+    public void setDataType(final DataType dataType) {
+        this.dataType = dataType;
+    }
+
+    public DataType getDataType() {
+        return this.dataType;
+    }
+
+    public boolean verifyDataType(final Object value) {
+        if (value == null) {
+            return true;
+        }
+        if (value instanceof List) {
+            for (final Iterator<?> it = ((List<?>) value).iterator(); it.hasNext();) {
+                if (!this.dataType.verifyDataType(it.next())) {
+                    return false;
+                }
+            }
+            return true;
+        }
+        return false;
+    }
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/StringDataType.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/StringDataType.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/StringDataType.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,41 @@
+package org.drools.process.core.datatype.impl.type;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.process.core.datatype.DataType;
+
+/**
+ * Representation of a string datatype.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class StringDataType
+    implements
+    DataType {
+
+    private static final long serialVersionUID = 400L;
+
+    public boolean verifyDataType(final Object value) {
+        if ( value instanceof String ) {
+            return true;
+        } else if ( value == null ) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/UndefinedDataType.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/UndefinedDataType.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/datatype/impl/type/UndefinedDataType.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,44 @@
+package org.drools.process.core.datatype.impl.type;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.process.core.datatype.DataType;
+
+/**
+ * Representation of an undefined datatype.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public final class UndefinedDataType implements DataType {
+
+    private static final long serialVersionUID = 400L;
+    private static UndefinedDataType instance;
+
+    public static UndefinedDataType getInstance() {
+        if (instance == null) {
+            instance = new UndefinedDataType();
+        }
+        return instance;
+    }
+
+    public boolean verifyDataType(final Object value) {
+        if (value == null) {
+            return true;
+        }
+        return false;
+    }
+}

Copied: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl (from rev 17570, labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/core/impl)

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/ParameterDefinitionImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/core/impl/ParameterDefinitionImpl.java	2008-01-05 14:13:22 UTC (rev 17570)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/ParameterDefinitionImpl.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,45 +0,0 @@
-package org.drools.ruleflow.common.core.impl;
-
-import java.io.Serializable;
-
-import org.drools.ruleflow.common.core.ParameterDefinition;
-import org.drools.ruleflow.common.datatype.DataType;
-
-public class ParameterDefinitionImpl implements ParameterDefinition, Serializable {
-   
-    private static final long serialVersionUID = 3977297720245237814L;
-   
-    private String name;
-    private DataType type;
-    
-    public ParameterDefinitionImpl(String name, DataType type) {
-        setName(name);
-        setType(type);
-    }
-    
-    public String getName() {
-        return name;
-    }
-    
-    public void setName(String name) {
-        if (name == null) {
-            throw new IllegalArgumentException("Name cannot be null");
-        }
-        this.name = name;
-    }
-    
-    public DataType getType() {
-        return type;
-    }
-    
-    public void setType(DataType type) {
-        if (type == null) {
-            throw new IllegalArgumentException("Data type cannot be null");
-        }
-        this.type = type;
-    }
-    
-    public String toString() {
-        return name;
-    }
-}
\ No newline at end of file

Copied: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/ParameterDefinitionImpl.java (from rev 17634, labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/core/impl/ParameterDefinitionImpl.java)
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/ParameterDefinitionImpl.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/ParameterDefinitionImpl.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,49 @@
+package org.drools.process.core.impl;
+
+import java.io.Serializable;
+
+import org.drools.process.core.ParameterDefinition;
+import org.drools.process.core.datatype.DataType;
+
+/**
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ParameterDefinitionImpl implements ParameterDefinition, Serializable {
+   
+    private static final long serialVersionUID = 400L;
+   
+    private String name;
+    private DataType type;
+    
+    public ParameterDefinitionImpl(String name, DataType type) {
+        setName(name);
+        setType(type);
+    }
+    
+    public String getName() {
+        return name;
+    }
+    
+    public void setName(String name) {
+        if (name == null) {
+            throw new IllegalArgumentException("Name cannot be null");
+        }
+        this.name = name;
+    }
+    
+    public DataType getType() {
+        return type;
+    }
+    
+    public void setType(DataType type) {
+        if (type == null) {
+            throw new IllegalArgumentException("Data type cannot be null");
+        }
+        this.type = type;
+    }
+    
+    public String toString() {
+        return name;
+    }
+}
\ No newline at end of file

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/ProcessImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/core/impl/ProcessImpl.java	2008-01-05 14:13:22 UTC (rev 17570)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/ProcessImpl.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,88 +0,0 @@
-package org.drools.ruleflow.common.core.impl;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import java.io.Serializable;
-
-/**
- * Default implementation of a Process
- * 
- * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
- */
-public class ProcessImpl
-    implements
-    org.drools.ruleflow.common.core.Process,
-    Serializable {
-    private static final long serialVersionUID = 400L;
-
-    private String            id;
-    private String            name;
-    private String            version;
-    private String            type;
-    private String			  packageName;
-
-    public void setId(final String id) {
-        this.id = id;
-    }
-
-    public String getId() {
-        return this.id;
-    }
-
-    public void setName(final String name) {
-        this.name = name;
-    }
-
-    public String getName() {
-        return this.name;
-    }
-
-    public void setVersion(final String version) {
-        this.version = version;
-    }
-
-    public String getVersion() {
-        return this.version;
-    }
-
-    public String getType() {
-        return this.type;
-    }
-
-    public void setType(final String type) {
-        this.type = type;
-    }
-
-	public String getPackageName() {
-		return packageName;
-	}
-
-	public void setPackageName(String packageName) {
-		this.packageName = packageName;
-	}
-
-    public boolean equals(final Object o) {
-        if ( o instanceof ProcessImpl ) {
-            return ((ProcessImpl) o).getName().equals( this.name ) && ((ProcessImpl) o).getVersion().equals( this.version );
-        }
-        return false;
-    }
-
-    public int hashCode() {
-        return this.name.hashCode() + 3 * this.version.hashCode();
-    }
-}
\ No newline at end of file

Copied: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/ProcessImpl.java (from rev 17634, labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/core/impl/ProcessImpl.java)
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/ProcessImpl.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/ProcessImpl.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,104 @@
+package org.drools.process.core.impl;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.Serializable;
+import java.util.List;
+
+import org.drools.process.core.Process;
+import org.drools.process.core.Variable;
+import org.drools.process.core.VariableScope;
+
+/**
+ * Default implementation of a Process
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ProcessImpl implements Process, Serializable {
+    
+    private static final long serialVersionUID = 400L;
+
+    private String            id;
+    private String            name;
+    private String            version;
+    private String            type;
+    private String			  packageName;
+    private VariableScope     variableScope = new VariableScopeImpl();
+
+    public void setId(final String id) {
+        this.id = id;
+    }
+
+    public String getId() {
+        return this.id;
+    }
+
+    public void setName(final String name) {
+        this.name = name;
+    }
+
+    public String getName() {
+        return this.name;
+    }
+
+    public void setVersion(final String version) {
+        this.version = version;
+    }
+
+    public String getVersion() {
+        return this.version;
+    }
+
+    public String getType() {
+        return this.type;
+    }
+
+    public void setType(final String type) {
+        this.type = type;
+    }
+
+	public String getPackageName() {
+		return packageName;
+	}
+
+	public void setPackageName(String packageName) {
+		this.packageName = packageName;
+	}
+
+    public List<Variable> getVariables() {
+        return variableScope.getVariables();
+    }
+
+    public void setVariables(final List<Variable> variables) {
+        variableScope.setVariables(variables);
+    }
+
+    public String[] getVariableNames() {
+        return variableScope.getVariableNames();
+    }
+
+    public boolean equals(final Object o) {
+        if ( o instanceof ProcessImpl ) {
+            return ((ProcessImpl) o).getName().equals( this.name ) && ((ProcessImpl) o).getVersion().equals( this.version );
+        }
+        return false;
+    }
+
+    public int hashCode() {
+        return this.name.hashCode() + 3 * this.version.hashCode();
+    }
+}
\ No newline at end of file

Copied: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/VariableImpl.java (from rev 17570, labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/VariableImpl.java)
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/VariableImpl.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/VariableImpl.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,81 @@
+package org.drools.process.core.impl;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.Serializable;
+
+import org.drools.process.core.Variable;
+import org.drools.process.core.datatype.DataType;
+import org.drools.process.core.datatype.impl.type.UndefinedDataType;
+
+/**
+ * Default implementation of a variable.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class VariableImpl implements Variable, Serializable {
+
+    private static final long serialVersionUID = 400L;
+
+    private String            name;
+    private DataType         type;
+    private Serializable      value;
+
+    public VariableImpl() {
+        this.type = UndefinedDataType.getInstance();
+    }
+
+    public String getName() {
+        return this.name;
+    }
+
+    public void setName(final String name) {
+        this.name = name;
+    }
+
+    public DataType getType() {
+        return this.type;
+    }
+
+    public void setType(final DataType type) {
+        if ( type == null ) {
+            throw new IllegalArgumentException( "type is null" );
+        }
+        this.type = type;
+    }
+
+    public Serializable getValue() {
+        return this.value;
+    }
+
+    public void setValue(final Serializable value) {
+        if ( this.type.verifyDataType( value ) ) {
+            this.value = value;
+        } else {
+            final StringBuffer sb = new StringBuffer();
+            sb.append( "Value <" );
+            sb.append( value );
+            sb.append( "> is not valid for datatype: " );
+            sb.append( this.type );
+            throw new IllegalArgumentException( sb.toString() );
+        }
+    }
+
+    public String toString() {
+        return this.name;
+    }
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/VariableScopeImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/VariableScopeImpl.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/VariableScopeImpl.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,45 @@
+package org.drools.process.core.impl;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.drools.process.core.Variable;
+import org.drools.process.core.VariableScope;
+
+/**
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class VariableScopeImpl implements VariableScope, Serializable {
+
+    private static final long serialVersionUID = 400L;
+    
+    private List<Variable> variables;
+    
+    public VariableScopeImpl() {
+        this.variables = new ArrayList<Variable>();
+    }
+
+    public List<Variable> getVariables() {
+        return this.variables;
+    }
+
+    public void setVariables(final List<Variable> variables) {
+        if ( variables == null ) {
+            throw new IllegalArgumentException( "Variables is null" );
+        }
+        this.variables = variables;
+    }
+
+    public String[] getVariableNames() {
+        final String[] result = new String[this.variables.size()];
+        if (this.variables != null) {
+            for ( int i = 0; i < this.variables.size(); i++ ) {
+                result[i] = ((Variable) this.variables.get( i )).getName();
+            }
+        }
+        return result;
+    }
+
+}

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/WorkDefinitionExtensionImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/core/impl/WorkDefinitionExtensionImpl.java	2008-01-05 14:13:22 UTC (rev 17570)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/WorkDefinitionExtensionImpl.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,35 +0,0 @@
-package org.drools.ruleflow.common.core.impl;
-
-import org.drools.ruleflow.common.core.WorkDefinitionExtension;
-
-public class WorkDefinitionExtensionImpl extends WorkDefinitionImpl implements WorkDefinitionExtension {
-    
-    private String displayName;
-    private String explanationText;
-    private String icon;
-    
-    public String getDisplayName() {
-        return displayName;
-    }
-    
-    public void setDisplayName(String displayName) {
-        this.displayName = displayName;
-    }
-
-    public String getExplanationText() {
-        return explanationText;
-    }
-    
-    public void setExplanationText(String explanationText) {
-        this.explanationText = explanationText;
-    }
-
-    public String getIcon() {
-        return icon;
-    }
-    
-    public void setIcon(String icon) {
-        this.icon = icon;
-    }
-    
-}

Copied: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/WorkDefinitionExtensionImpl.java (from rev 17634, labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/core/impl/WorkDefinitionExtensionImpl.java)
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/WorkDefinitionExtensionImpl.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/WorkDefinitionExtensionImpl.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,41 @@
+package org.drools.process.core.impl;
+
+import org.drools.process.core.WorkDefinitionExtension;
+
+/**
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class WorkDefinitionExtensionImpl extends WorkDefinitionImpl implements WorkDefinitionExtension {
+    
+    private static final long serialVersionUID = 400L;
+    
+    private String displayName;
+    private String explanationText;
+    private String icon;
+    
+    public String getDisplayName() {
+        return displayName;
+    }
+    
+    public void setDisplayName(String displayName) {
+        this.displayName = displayName;
+    }
+
+    public String getExplanationText() {
+        return explanationText;
+    }
+    
+    public void setExplanationText(String explanationText) {
+        this.explanationText = explanationText;
+    }
+
+    public String getIcon() {
+        return icon;
+    }
+    
+    public void setIcon(String icon) {
+        this.icon = icon;
+    }
+    
+}

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/WorkDefinitionImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/core/impl/WorkDefinitionImpl.java	2008-01-05 14:13:22 UTC (rev 17570)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/WorkDefinitionImpl.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,87 +0,0 @@
-package org.drools.ruleflow.common.core.impl;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import org.drools.ruleflow.common.core.ParameterDefinition;
-import org.drools.ruleflow.common.core.WorkDefinition;
-
-public class WorkDefinitionImpl implements WorkDefinition {
-    
-    private static final long serialVersionUID = 3977861786923710777L;
-    
-    private String name;
-    private Map parameters = new HashMap();
-    private Map results = new HashMap();
-
-    public String getName() {
-        return name;
-    }
-    
-    public void setName(String name) {
-        this.name = name;
-    }
-    
-    public Set getParameters() {
-    	return new HashSet(parameters.values());        
-    }
-    
-    public void setParameters(Set parameters) {
-        this.parameters.clear();
-        Iterator iterator = parameters.iterator();
-        while (iterator.hasNext()) {
-        	addParameter((ParameterDefinition) iterator.next());
-        }        
-    }
-    
-    public void addParameter(ParameterDefinition parameter) {
-    	parameters.put(parameter.getName(), parameter);
-    }
-    
-    public void removeParameter(String name) {
-        parameters.remove(name);
-    }
-    
-    public String[] getParameterNames() {
-        return (String[]) parameters.keySet().toArray(new String[parameters.size()]);
-    }
-    
-    public ParameterDefinition getParameter(String name) {
-        return (ParameterDefinition) parameters.get(name);
-    }
-    
-    public Set getResults() {
-    	return new HashSet(results.values());
-    }
-    
-    public void setResults(Set results) {
-    	this.results.clear();
-        Iterator it = results.iterator();
-        while (it.hasNext()) {
-        	addResult((ParameterDefinition) it.next());
-        }   
-    }
-    
-    public void addResult(ParameterDefinition result) {
-        results.put(result.getName(), result);
-    }
-    
-    public void removeResult(String name) {
-        results.remove(name);
-    }
-    
-    public String[] getResultNames() {
-        return (String[]) results.keySet().toArray(new String[results.size()]);
-    }
-    
-    public ParameterDefinition getResult(String name) {
-        return (ParameterDefinition) results.get(name);
-    }
-    
-    public String toString() {
-        return name;
-    }
-}

Copied: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/WorkDefinitionImpl.java (from rev 17634, labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/core/impl/WorkDefinitionImpl.java)
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/WorkDefinitionImpl.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/WorkDefinitionImpl.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,92 @@
+package org.drools.process.core.impl;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.drools.process.core.ParameterDefinition;
+import org.drools.process.core.WorkDefinition;
+
+/**
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class WorkDefinitionImpl implements WorkDefinition, Serializable {
+    
+    private static final long serialVersionUID = 400L;
+    
+    private String name;
+    private Map<String, ParameterDefinition> parameters = new HashMap<String, ParameterDefinition>();
+    private Map<String, ParameterDefinition> results = new HashMap<String, ParameterDefinition>();
+
+    public String getName() {
+        return name;
+    }
+    
+    public void setName(String name) {
+        this.name = name;
+    }
+    
+    public Set<ParameterDefinition> getParameters() {
+    	return new HashSet<ParameterDefinition>(parameters.values());        
+    }
+    
+    public void setParameters(Set<ParameterDefinition> parameters) {
+        this.parameters.clear();
+        Iterator<ParameterDefinition> iterator = parameters.iterator();
+        while (iterator.hasNext()) {
+        	addParameter(iterator.next());
+        }        
+    }
+    
+    public void addParameter(ParameterDefinition parameter) {
+    	parameters.put(parameter.getName(), parameter);
+    }
+    
+    public void removeParameter(String name) {
+        parameters.remove(name);
+    }
+    
+    public String[] getParameterNames() {
+        return parameters.keySet().toArray(new String[parameters.size()]);
+    }
+    
+    public ParameterDefinition getParameter(String name) {
+        return parameters.get(name);
+    }
+    
+    public Set<ParameterDefinition> getResults() {
+    	return new HashSet<ParameterDefinition>(results.values());
+    }
+    
+    public void setResults(Set<ParameterDefinition> results) {
+    	this.results.clear();
+        Iterator<ParameterDefinition> it = results.iterator();
+        while (it.hasNext()) {
+        	addResult(it.next());
+        }   
+    }
+    
+    public void addResult(ParameterDefinition result) {
+        results.put(result.getName(), result);
+    }
+    
+    public void removeResult(String name) {
+        results.remove(name);
+    }
+    
+    public String[] getResultNames() {
+        return results.keySet().toArray(new String[results.size()]);
+    }
+    
+    public ParameterDefinition getResult(String name) {
+        return results.get(name);
+    }
+    
+    public String toString() {
+        return name;
+    }
+}

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/WorkImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/core/impl/WorkImpl.java	2008-01-05 14:13:22 UTC (rev 17570)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/WorkImpl.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,50 +0,0 @@
-package org.drools.ruleflow.common.core.impl;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.drools.ruleflow.common.core.Work;
-
-public class WorkImpl implements Work {
-    
-    private String name;
-    private Map parameters = new HashMap();
-    
-    public void setName(String name) {
-        this.name = name;
-    }
-    
-    public String getName() {
-        return name;
-    }
-    
-    public void setParameter(String name, Object value) {
-    	if (name == null) {
-    		throw new NullPointerException("Parameter name is null");
-    	}
-		parameters.put(name, value);
-    }
-    
-    public void setParameters(Map parameters) {
-        if (parameters == null) {
-            throw new NullPointerException();
-        }
-        this.parameters = new HashMap(parameters);
-    }
-    
-    public Object getParameter(String name) {
-        if (name == null) {
-            throw new NullPointerException("Parameter name is null");
-        }
-        return parameters.get(name);
-    }
-    
-    public Map getParameters() {
-        return Collections.unmodifiableMap(parameters);
-    }
-    
-    public String toString() {
-        return "Task " + name;
-    }
-}

Copied: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/WorkImpl.java (from rev 17634, labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/core/impl/WorkImpl.java)
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/WorkImpl.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/impl/WorkImpl.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,57 @@
+package org.drools.process.core.impl;
+
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.drools.process.core.Work;
+
+/**
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class WorkImpl implements Work, Serializable {
+    
+    private static final long serialVersionUID = 400L;
+    
+    private String name;
+    private Map<String, Object> parameters = new HashMap<String, Object>();
+    
+    public void setName(String name) {
+        this.name = name;
+    }
+    
+    public String getName() {
+        return name;
+    }
+    
+    public void setParameter(String name, Object value) {
+    	if (name == null) {
+    		throw new NullPointerException("Parameter name is null");
+    	}
+		parameters.put(name, value);
+    }
+    
+    public void setParameters(Map<String, Object> parameters) {
+        if (parameters == null) {
+            throw new NullPointerException();
+        }
+        this.parameters = new HashMap<String, Object>(parameters);
+    }
+    
+    public Object getParameter(String name) {
+        if (name == null) {
+            throw new NullPointerException("Parameter name is null");
+        }
+        return parameters.get(name);
+    }
+    
+    public Map<String, Object> getParameters() {
+        return Collections.unmodifiableMap(parameters);
+    }
+    
+    public String toString() {
+        return "Work " + name;
+    }
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/validation/ProcessValidationError.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/validation/ProcessValidationError.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/validation/ProcessValidationError.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,32 @@
+package org.drools.process.core.validation;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.process.core.Process;
+
+/**
+ * Represents a RuleFlow validation error. 
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public interface ProcessValidationError {
+
+    Process getProcess();
+    
+    String getMessage();
+    
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/validation/ProcessValidator.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/validation/ProcessValidator.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/validation/ProcessValidator.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,30 @@
+package org.drools.process.core.validation;
+
+import org.drools.process.core.Process;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * A validator for validating a RuleFlow process. 
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public interface ProcessValidator {
+
+    ProcessValidationError[] validateProcess(Process process);
+
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/validation/impl/ProcessValidationErrorImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/validation/impl/ProcessValidationErrorImpl.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/core/validation/impl/ProcessValidationErrorImpl.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,28 @@
+package org.drools.process.core.validation.impl;
+
+import org.drools.process.core.Process;
+import org.drools.process.core.validation.ProcessValidationError;
+
+public class ProcessValidationErrorImpl implements ProcessValidationError {
+
+    private Process process;
+    private String message;
+    
+    public ProcessValidationErrorImpl(Process process, String message) {
+        this.process = process;
+        this.message = message;
+    }
+    
+    public String getMessage() {
+        return message;
+    }
+
+    public Process getProcess() {
+        return process;
+    }
+    
+    public String toString() {
+        return "Process '" + process.getName() + "' [" + process.getId() + "]: " + getMessage();
+    }
+
+}

Copied: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/ProcessInstance.java (from rev 17570, labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/instance/ProcessInstance.java)
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/ProcessInstance.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/ProcessInstance.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,53 @@
+package org.drools.process.instance;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.common.InternalWorkingMemory;
+import org.drools.process.core.Process;
+
+/**
+ * A process instance is the representation of a process during its execution.
+ * It contains all the runtime status information about the running process.
+ * A process can have multiple instances.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public interface ProcessInstance extends VariableScopeInstance, WorkItemListener {
+
+    int STATE_PENDING   = 0;
+    int STATE_ACTIVE    = 1;
+    int STATE_COMPLETED = 2;
+    int STATE_ABORTED   = 3;
+    int STATE_SUSPENDED = 4;
+
+    void setId(long id);
+
+    long getId();
+
+    void setProcess(Process process);
+
+    Process getProcess();
+
+    void setState(int state);
+
+    int getState();
+    
+    void setWorkingMemory(InternalWorkingMemory workingMemory);
+    
+    void start();
+
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/ProcessInstanceFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/ProcessInstanceFactory.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/ProcessInstanceFactory.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,11 @@
+package org.drools.process.instance;
+
+/**
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public interface ProcessInstanceFactory {
+    
+    ProcessInstance createProcessInstance();
+
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/VariableScopeInstance.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/VariableScopeInstance.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/VariableScopeInstance.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,17 @@
+package org.drools.process.instance;
+
+import java.util.Map;
+
+/**
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public interface VariableScopeInstance {
+
+    Map<String, Object> getVariables();
+    
+    Object getVariable(String name);
+    
+    void setVariable(String name, Object value);
+
+}

Copied: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/WorkItem.java (from rev 17570, labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/instance/WorkItem.java)
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/WorkItem.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/WorkItem.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,30 @@
+package org.drools.process.instance;
+
+import java.util.Map;
+
+/**
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public interface WorkItem {
+	
+	int PENDING = 0;
+	int ACTIVE = 1;
+	int COMPLETED = 2;
+	int ABORTED = 3;
+
+    long getId();
+    
+    String getName();
+    
+    int getState();
+    
+    Object getParameter(String name);
+    Map<String, Object> getParameters();
+    
+    Object getResult(String name);
+    Map<String, Object> getResults();
+
+    long getProcessInstanceId();
+
+}

Copied: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/WorkItemHandler.java (from rev 17570, labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/instance/WorkItemHandler.java)
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/WorkItemHandler.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/WorkItemHandler.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,13 @@
+package org.drools.process.instance;
+
+/**
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public interface WorkItemHandler {
+    
+    void executeWorkItem(WorkItem workItem, WorkItemManager manager);
+    
+    void abortWorkItem(WorkItem workItem, WorkItemManager manager);
+
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/WorkItemListener.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/WorkItemListener.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/WorkItemListener.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,9 @@
+package org.drools.process.instance;
+
+public interface WorkItemListener {
+
+    void workItemCompleted(WorkItem workItem);
+    
+    void workItemAborted(WorkItem workItem);
+    
+}

Copied: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/WorkItemManager.java (from rev 17570, labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/instance/WorkItemManager.java)
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/WorkItemManager.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/WorkItemManager.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,82 @@
+package org.drools.process.instance;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.drools.WorkingMemory;
+import org.drools.process.instance.impl.WorkItemImpl;
+
+/**
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class WorkItemManager implements Serializable {
+
+    private static final long serialVersionUID = 400L;
+    
+    private long workItemCounter; 
+	private Map<Long, WorkItem> workItems = new HashMap<Long, WorkItem>();
+	private WorkingMemory workingMemory;
+	private Map<String, WorkItemHandler> workItemHandlers = new HashMap<String, WorkItemHandler>();
+	
+	public WorkItemManager(WorkingMemory workingMemory) {
+	    this.workingMemory = workingMemory;
+	}
+	
+	public void executeWorkItem(WorkItem workItem) {
+	    ((WorkItemImpl) workItem).setId(++workItemCounter);
+	    workItems.put(new Long(workItem.getId()), workItem);
+	    WorkItemHandler handler = (WorkItemHandler) this.workItemHandlers.get(workItem.getName());
+	    if (handler != null) {
+	        handler.executeWorkItem(workItem, this);
+	    } else {
+	        System.err.println("Could not find work item handler for " + workItem.getName());
+	    }
+	}
+	
+	public Set<WorkItem> getWorkItems() {
+	    return new HashSet<WorkItem>(workItems.values());
+
+	}
+	
+    public void completeWorkItem(long id, Map<String, Object> results) {
+        WorkItemImpl workItem = (WorkItemImpl) workItems.get(new Long(id));
+        if (workItem == null) {
+            throw new IllegalArgumentException(
+                "Could not find work item with id " + id);
+        }
+        workItem.setResults(results);
+        ProcessInstance processInstance = workingMemory.getProcessInstance(workItem.getProcessInstanceId());
+        if (processInstance == null) {
+            throw new IllegalArgumentException(
+                "Could not find processInstance with id " + workItem.getProcessInstanceId());
+        }
+        workItem.setState(WorkItem.COMPLETED);
+        processInstance.workItemCompleted(workItem);
+        workItems.remove(new Long(id));
+    }
+    
+    public void abortWorkItem(long id) {
+        WorkItemImpl workItem = (WorkItemImpl) workItems.get(new Long(id));
+        if (workItem == null) {
+            throw new IllegalArgumentException(
+                "Could not find work item with id " + id);
+        }
+        ProcessInstance processInstance = workingMemory.getProcessInstance(workItem.getProcessInstanceId());
+        if (processInstance == null) {
+            throw new IllegalArgumentException(
+                "Could not find processInstance with id " + workItem.getProcessInstanceId());
+        }
+        workItem.setState(WorkItem.ABORTED);
+        processInstance.workItemAborted(workItem);
+        workItems.remove(new Long(id));
+    }
+    
+    public void registerWorkItemHandler(String workItemName, WorkItemHandler handler) {
+        this.workItemHandlers.put(workItemName, handler);
+    }
+
+}

Copied: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/impl (from rev 17570, labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/instance/impl)

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/impl/ProcessInstanceImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/instance/impl/ProcessInstanceImpl.java	2008-01-05 14:13:22 UTC (rev 17570)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/impl/ProcessInstanceImpl.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,75 +0,0 @@
-package org.drools.ruleflow.common.instance.impl;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import org.drools.ruleflow.common.core.Process;
-import org.drools.ruleflow.common.instance.WorkItem;
-
-/**
- * Default implementation of a process instance.
- * 
- * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
- */
-public abstract class ProcessInstanceImpl
-    implements
-    org.drools.ruleflow.common.instance.ProcessInstance {
-
-    private long     id;
-    private Process process;
-    private int      state = STATE_PENDING;
-
-    public void setId(final long id) {
-        this.id = id;
-    }
-
-    public long getId() {
-        return this.id;
-    }
-
-    public void setProcess(final Process process) {
-        this.process = process;
-    }
-
-    public Process getProcess() {
-        return this.process;
-    }
-
-    public void setState(final int state) {
-        this.state = state;
-    }
-
-    public int getState() {
-        return this.state;
-    }
-    
-    public void taskCompleted(WorkItem taskInstance) {
-    }
-
-    public void taskAborted(WorkItem taskInstance) {
-    }
-
-    public String toString() {
-        final StringBuffer b = new StringBuffer( "ProcessInstance " );
-        b.append( getId() );
-        b.append( " [processId=" );
-        b.append( this.process.getId() );
-        b.append( ",state=" );
-        b.append( this.state );
-        b.append( "]" );
-        return b.toString();
-    }
-}

Copied: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/impl/ProcessInstanceImpl.java (from rev 17634, labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/instance/impl/ProcessInstanceImpl.java)
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/impl/ProcessInstanceImpl.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/impl/ProcessInstanceImpl.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,101 @@
+package org.drools.process.instance.impl;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.Serializable;
+import java.util.Map;
+
+import org.drools.process.core.Process;
+import org.drools.process.instance.ProcessInstance;
+import org.drools.process.instance.VariableScopeInstance;
+import org.drools.process.instance.WorkItem;
+
+/**
+ * Default implementation of a process instance.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public abstract class ProcessInstanceImpl implements ProcessInstance, Serializable {
+
+    private long id;
+    private Process process;
+    private int state = STATE_PENDING;
+    private VariableScopeInstance variableScopeInstance = new VariableScopeInstanceImpl();
+
+    public void setId(final long id) {
+        this.id = id;
+    }
+
+    public long getId() {
+        return this.id;
+    }
+
+    public void setProcess(final Process process) {
+        this.process = process;
+    }
+
+    public Process getProcess() {
+        return this.process;
+    }
+
+    public void setState(final int state) {
+        this.state = state;
+    }
+
+    public int getState() {
+        return this.state;
+    }
+    
+    public void workItemCompleted(WorkItem taskInstance) {
+    }
+
+    public void workItemAborted(WorkItem taskInstance) {
+    }
+
+    public Object getVariable(String name) {
+        return variableScopeInstance.getVariable(name);
+    }
+
+    public Map<String, Object> getVariables() {
+        return variableScopeInstance.getVariables();
+    }
+
+    public void setVariable(String name, Object value) {
+        variableScopeInstance.setVariable(name, value);
+    }
+    
+    public void start() {
+        if ( getState() != ProcessInstanceImpl.STATE_PENDING ) {
+            throw new IllegalArgumentException( "A process instance can only be started once" );
+        }
+        setState( ProcessInstanceImpl.STATE_ACTIVE );
+        internalStart();
+    }
+    
+    protected abstract void internalStart();
+
+    public String toString() {
+        final StringBuffer b = new StringBuffer( "ProcessInstance " );
+        b.append( getId() );
+        b.append( " [processId=" );
+        b.append( this.process.getId() );
+        b.append( ",state=" );
+        b.append( this.state );
+        b.append( "]" );
+        return b.toString();
+    }
+}

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/impl/SystemOutWorkItemHandler.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/instance/impl/SystemOutWorkItemHandler.java	2008-01-05 14:13:22 UTC (rev 17570)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/impl/SystemOutWorkItemHandler.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,19 +0,0 @@
-package org.drools.ruleflow.common.instance.impl;
-
-import org.drools.ruleflow.common.instance.WorkItem;
-import org.drools.ruleflow.common.instance.WorkItemHandler;
-import org.drools.ruleflow.common.instance.WorkItemManager;
-
-public class SystemOutWorkItemHandler implements WorkItemHandler {
-
-    public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {
-        System.out.println("Executing work item " + workItem);
-        manager.completeWorkItem(workItem.getId(), null);
-    }
-
-    public void abortWorkItem(WorkItem workItem, WorkItemManager manager) {
-        System.out.println("Aborting work item " + workItem);
-        manager.abortWorkItem(workItem.getId());
-    }
-
-}

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/impl/UIWorkItemHandler.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/instance/impl/UIWorkItemHandler.java	2008-01-05 14:13:22 UTC (rev 17570)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/impl/UIWorkItemHandler.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,164 +0,0 @@
-package org.drools.ruleflow.common.instance.impl;
-
-import java.awt.BorderLayout;
-import java.awt.Dimension;
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.Insets;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.swing.JButton;
-import javax.swing.JFrame;
-import javax.swing.JList;
-import javax.swing.JPanel;
-import javax.swing.ListSelectionModel;
-import javax.swing.WindowConstants;
-import javax.swing.event.ListSelectionEvent;
-import javax.swing.event.ListSelectionListener;
-
-import org.drools.ruleflow.common.instance.WorkItem;
-import org.drools.ruleflow.common.instance.WorkItemHandler;
-import org.drools.ruleflow.common.instance.WorkItemManager;
-
-public class UIWorkItemHandler extends JFrame implements WorkItemHandler {
-
-    private Map taskInstances = new HashMap();
-    private JList taskInstancesList;
-    private JButton selectButton;
-    
-    public UIWorkItemHandler() {
-        setSize(new Dimension(400, 300));
-        setTitle("Work Items");
-        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
-        initializeComponent();
-    }
-    
-    private void initializeComponent() {
-        JPanel panel = new JPanel();
-        panel.setLayout(new GridBagLayout());
-        getRootPane().setLayout(new BorderLayout());
-        getRootPane().add(panel, BorderLayout.CENTER);
-        
-        taskInstancesList = new JList();
-        taskInstancesList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
-        taskInstancesList.addMouseListener(new MouseAdapter() {
-            public void mouseClicked(MouseEvent e) {
-                if (e.getClickCount() == 2) {
-                    select();
-                }
-            }
-        });
-        taskInstancesList.addListSelectionListener(new ListSelectionListener() {
-            public void valueChanged(ListSelectionEvent e) {
-                selectButton.setEnabled(getSelectedTaskInstance() != null);
-            }
-        });
-        reloadTaskInstancesList();
-        GridBagConstraints c = new GridBagConstraints();
-        c.weightx = 1;
-        c.weighty = 1;
-        c.fill = GridBagConstraints.BOTH;
-        c.insets = new Insets(5, 5, 5, 5);
-        panel.add(taskInstancesList, c);
-        
-        selectButton = new JButton("Select");
-        selectButton.setEnabled(false);
-        selectButton.addActionListener(new ActionListener() {
-            public void actionPerformed(ActionEvent event) {
-                select();
-            }
-        });
-        c = new GridBagConstraints();
-        c.gridy = 1;
-        c.weightx = 1;
-        c.anchor = GridBagConstraints.EAST;
-        c.insets = new Insets(5, 5, 5, 5);
-        panel.add(selectButton, c);
-    }
-    
-    private void select() {
-        WorkItem taskInstance = getSelectedTaskInstance();
-        if (taskInstance != null) {
-            UIWorkItemHandlerDialog dialog = new UIWorkItemHandlerDialog(UIWorkItemHandler.this, taskInstance);
-            dialog.setVisible(true);
-        }
-    }
-    
-    public WorkItem getSelectedTaskInstance() {
-        int index = taskInstancesList.getSelectedIndex();
-        if (index != -1) {
-            Object selected = taskInstancesList.getModel().getElementAt(index);
-            if (selected instanceof TaskInstanceWrapper) {
-                return ((TaskInstanceWrapper) selected).getTaskInstance();
-            }
-        }
-        return null;
-    }
-    
-    private void reloadTaskInstancesList() {
-        List result = new ArrayList();
-        for (Iterator iterator = taskInstances.keySet().iterator(); iterator.hasNext(); ) {
-            WorkItem taskInstance = (WorkItem) iterator.next();
-            result.add(new TaskInstanceWrapper(taskInstance));
-        }
-        taskInstancesList.setListData(result.toArray());
-    }
-    
-    public void complete(WorkItem taskInstance, Map results) {
-        WorkItemManager manager = (WorkItemManager) taskInstances.get(taskInstance);
-        if (manager != null) {
-            manager.completeWorkItem(taskInstance.getId(), results);
-            taskInstances.remove(taskInstance);
-            reloadTaskInstancesList();
-        }
-        selectButton.setEnabled(getSelectedTaskInstance() != null);
-    }
-    
-    public void abort(WorkItem taskInstance) {
-        WorkItemManager manager = (WorkItemManager) taskInstances.get(taskInstance);
-        if (manager != null) {
-            manager.abortWorkItem(taskInstance.getId());
-            taskInstances.remove(taskInstance);
-            reloadTaskInstancesList();
-        }
-        selectButton.setEnabled(getSelectedTaskInstance() != null);
-    }
-    
-    public void abortWorkItem(WorkItem taskInstance,
-            WorkItemManager manager) {
-        taskInstances.remove(taskInstance);
-        reloadTaskInstancesList();
-    }
-
-    public void executeWorkItem(WorkItem taskInstance,
-            WorkItemManager manager) {
-        taskInstances.put(taskInstance, manager);
-        reloadTaskInstancesList();
-    }
-
-    private class TaskInstanceWrapper {
-        
-        private WorkItem taskInstance;
-        
-        public TaskInstanceWrapper(WorkItem taskInstance) {
-            this.taskInstance = taskInstance;
-        }
-        
-        public WorkItem getTaskInstance() {
-            return taskInstance;
-        }
-        
-        public String toString() {
-            return taskInstance.getName() + " [" + taskInstance.getId() + "]";
-        }
-    }
-    
-}

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/impl/UIWorkItemHandlerDialog.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/instance/impl/UIWorkItemHandlerDialog.java	2008-01-05 14:13:22 UTC (rev 17570)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/impl/UIWorkItemHandlerDialog.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,98 +0,0 @@
-package org.drools.ruleflow.common.instance.impl;
-
-import java.awt.BorderLayout;
-import java.awt.Dimension;
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.Insets;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.swing.JButton;
-import javax.swing.JDialog;
-import javax.swing.JPanel;
-import javax.swing.JTextArea;
-
-import org.drools.ruleflow.common.instance.WorkItem;
-
-public class UIWorkItemHandlerDialog extends JDialog {
-    
-    private UIWorkItemHandler handler;
-    private WorkItem taskInstance;
-    private JButton completeButton;
-    private JButton abortButton;
-    
-    public UIWorkItemHandlerDialog(UIWorkItemHandler handler, WorkItem taskInstance) {
-        super(handler, "Execute Work Item", true);
-        this.handler = handler;
-        this.taskInstance = taskInstance;
-        setSize(new Dimension(400, 300));
-        initializeComponent();
-    }
-
-    private void initializeComponent() {
-        JPanel panel = new JPanel();
-        panel.setLayout(new GridBagLayout());
-        getRootPane().setLayout(new BorderLayout());
-        getRootPane().add(panel, BorderLayout.CENTER);
-        
-        JTextArea params = new JTextArea();
-        params.setText(getParameters());
-        params.setEditable(false);
-        GridBagConstraints c = new GridBagConstraints();
-        c.weightx = 1;
-        c.weighty = 1;
-        c.gridwidth = 2;
-        c.fill = GridBagConstraints.BOTH;
-        c.insets = new Insets(5, 5, 5, 5);
-        panel.add(params, c);
-        
-        completeButton = new JButton("Complete");
-        completeButton.addActionListener(new ActionListener() {
-            public void actionPerformed(ActionEvent event) {
-                complete();
-            }
-        });
-        c = new GridBagConstraints();
-        c.gridy = 1;
-        c.weightx = 1;
-        c.anchor = GridBagConstraints.EAST;
-        c.insets = new Insets(5, 5, 5, 5);
-        panel.add(completeButton, c);
-
-        abortButton = new JButton("Abort");
-        abortButton.addActionListener(new ActionListener() {
-            public void actionPerformed(ActionEvent event) {
-                abort();
-            }
-        });
-        c = new GridBagConstraints();
-        c.gridx = 1;
-        c.gridy = 1;
-        c.insets = new Insets(5, 5, 5, 5);
-        panel.add(abortButton, c);
-    }
-    
-    private String getParameters() {
-        String result = "";
-        if (taskInstance.getParameters() != null) {
-            for (Iterator iterator = taskInstance.getParameters().entrySet().iterator(); iterator.hasNext(); ) {
-                Map.Entry entry = (Map.Entry) iterator.next();
-                result += entry.getKey() + " = " + entry.getValue() + "\n";
-            }
-        }
-        return result;
-    }
-    
-    private void complete() {
-        handler.complete(taskInstance, null);
-        dispose();
-    }
-    
-    private void abort() {
-        handler.abort(taskInstance);
-        dispose();
-    }
-}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/impl/VariableScopeInstanceImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/impl/VariableScopeInstanceImpl.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/impl/VariableScopeInstanceImpl.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,36 @@
+package org.drools.process.instance.impl;
+
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.drools.process.instance.VariableScopeInstance;
+
+/**
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class VariableScopeInstanceImpl implements VariableScopeInstance, Serializable {
+
+    private static final long serialVersionUID = 400L;
+    
+    private Map<String, Object> variables = new HashMap<String, Object>();
+
+    public Object getVariable(String name) {
+        return variables.get(name);
+    }
+
+    public Map<String, Object> getVariables() {
+        return Collections.unmodifiableMap(variables);
+    }
+
+    public void setVariable(String name, Object value) {
+        if (name == null) {
+            throw new IllegalArgumentException(
+                "The name of a variable may not be null!");
+        }
+        variables.put(name, value);
+    }
+    
+}

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/impl/WorkItemImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/instance/impl/WorkItemImpl.java	2008-01-05 14:13:22 UTC (rev 17570)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/impl/WorkItemImpl.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,100 +0,0 @@
-package org.drools.ruleflow.common.instance.impl;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.drools.ruleflow.common.instance.WorkItem;
-
-public class WorkItemImpl implements WorkItem {
-
-	private long id;
-    private String name;
-    private int state = 0;
-    private Map parameters = new HashMap();
-    private Map results = new HashMap();
-    private long processInstanceId;
-    
-    public void setId(long id) {
-        this.id = id;
-    }
-    
-    public long getId() {
-        return id;
-    }
-    
-    public void setName(String name) {
-        this.name = name;
-    }
-    
-    public String getName() {
-        return name;
-    }
-    
-    public void setState(int state) {
-        this.state = state;
-    }
-    
-    public int getState() {
-        return state;
-    }
-    
-    public void setParameters(Map parameters) {
-        this.parameters = parameters;
-    }
-    
-    public Object getParameter(String name) {
-        return parameters.get(name);
-    }
-    
-    public Map getParameters() {
-        return parameters;
-    }
-    
-    public void setResults(Map results) {
-        this.results = results;
-    }
-    
-    public void setResult(String name, Object value) {
-        results.put(name, value);
-    }
-    
-    public Object getResult(String name) {
-        return results.get(name);
-    }
-    
-    public Map getResults() {
-        return results;
-    }
-    
-    public void setProcessInstanceId(long processInstanceId) {
-        this.processInstanceId = processInstanceId;
-    }
-    
-    public long getProcessInstanceId() {
-        return processInstanceId;
-    }
-    
-    public String toString() {
-    	StringBuilder b = new StringBuilder("WorkItem ");
-    	b.append(id);
-    	b.append(" [name=");
-    	b.append(name);
-    	b.append(", state=");
-    	b.append(state);
-    	b.append(", processInstanceId=");
-    	b.append(processInstanceId);
-        b.append(", parameters{");
-    	for (Iterator iterator = parameters.entrySet().iterator(); iterator.hasNext(); ) {
-    	    Map.Entry entry = (Map.Entry) iterator.next();
-    	    b.append(entry.getKey());
-    	    b.append("=");
-    	    b.append(entry.getValue());
-    	    if (iterator.hasNext()) {
-    	        b.append(", ");
-    	    }
-    	}
-        b.append("}]");
-    	return b.toString();
-    }
-}
\ No newline at end of file

Copied: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/impl/WorkItemImpl.java (from rev 17634, labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/common/instance/impl/WorkItemImpl.java)
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/impl/WorkItemImpl.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/impl/WorkItemImpl.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,114 @@
+package org.drools.process.instance.impl;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.drools.process.instance.WorkItem;
+
+/**
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class WorkItemImpl implements WorkItem, Serializable {
+
+    private static final long serialVersionUID = 400L;
+    
+    private long id;
+    private String name;
+    private int state = 0;
+    private Map<String, Object> parameters = new HashMap<String, Object>();
+    private Map<String, Object> results = new HashMap<String, Object>();
+    private long processInstanceId;
+    
+    public void setId(long id) {
+        this.id = id;
+    }
+    
+    public long getId() {
+        return id;
+    }
+    
+    public void setName(String name) {
+        this.name = name;
+    }
+    
+    public String getName() {
+        return name;
+    }
+    
+    public void setState(int state) {
+        this.state = state;
+    }
+    
+    public int getState() {
+        return state;
+    }
+    
+    public void setParameters(Map<String, Object> parameters) {
+        for (Iterator<Map.Entry<String, Object>> iterator = parameters.entrySet().iterator(); iterator.hasNext(); ) {
+            Map.Entry<String, Object> entry = iterator.next();
+            setParameter(entry.getKey(), entry.getValue());
+        }
+    }
+    
+    public void setParameter(String name, Object value) {
+        this.parameters.put(name, value);
+    }
+    
+    public Object getParameter(String name) {
+        return parameters.get(name);
+    }
+    
+    public Map<String, Object> getParameters() {
+        return parameters;
+    }
+    
+    public void setResults(Map<String, Object> results) {
+        this.results = results;
+    }
+    
+    public void setResult(String name, Object value) {
+        results.put(name, value);
+    }
+    
+    public Object getResult(String name) {
+        return results.get(name);
+    }
+    
+    public Map<String, Object> getResults() {
+        return results;
+    }
+    
+    public void setProcessInstanceId(long processInstanceId) {
+        this.processInstanceId = processInstanceId;
+    }
+    
+    public long getProcessInstanceId() {
+        return processInstanceId;
+    }
+    
+    public String toString() {
+    	StringBuilder b = new StringBuilder("WorkItem ");
+    	b.append(id);
+    	b.append(" [name=");
+    	b.append(name);
+    	b.append(", state=");
+    	b.append(state);
+    	b.append(", processInstanceId=");
+    	b.append(processInstanceId);
+        b.append(", parameters{");
+    	for (Iterator<Map.Entry<String, Object>> iterator = parameters.entrySet().iterator(); iterator.hasNext(); ) {
+    	    Map.Entry<String, Object> entry = iterator.next();
+    	    b.append(entry.getKey());
+    	    b.append("=");
+    	    b.append(entry.getValue());
+    	    if (iterator.hasNext()) {
+    	        b.append(", ");
+    	    }
+    	}
+        b.append("}]");
+    	return b.toString();
+    }
+}
\ No newline at end of file

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/impl/demo/DoNothingWorkItemHandler.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/impl/demo/DoNothingWorkItemHandler.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/impl/demo/DoNothingWorkItemHandler.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,19 @@
+package org.drools.process.instance.impl.demo;
+
+import org.drools.process.instance.WorkItem;
+import org.drools.process.instance.WorkItemHandler;
+import org.drools.process.instance.WorkItemManager;
+
+/**
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class DoNothingWorkItemHandler implements WorkItemHandler {
+
+    public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {
+    }
+
+    public void abortWorkItem(WorkItem workItem, WorkItemManager manager) {
+    }
+
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/impl/demo/SystemOutWorkItemHandler.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/impl/demo/SystemOutWorkItemHandler.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/impl/demo/SystemOutWorkItemHandler.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,23 @@
+package org.drools.process.instance.impl.demo;
+
+import org.drools.process.instance.WorkItem;
+import org.drools.process.instance.WorkItemHandler;
+import org.drools.process.instance.WorkItemManager;
+
+/**
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class SystemOutWorkItemHandler implements WorkItemHandler {
+
+    public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {
+        System.out.println("Executing work item " + workItem);
+        manager.completeWorkItem(workItem.getId(), null);
+    }
+
+    public void abortWorkItem(WorkItem workItem, WorkItemManager manager) {
+        System.out.println("Aborting work item " + workItem);
+        manager.abortWorkItem(workItem.getId());
+    }
+
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/impl/demo/UIWorkItemHandler.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/impl/demo/UIWorkItemHandler.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/impl/demo/UIWorkItemHandler.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,168 @@
+package org.drools.process.instance.impl.demo;
+
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JList;
+import javax.swing.JPanel;
+import javax.swing.ListSelectionModel;
+import javax.swing.WindowConstants;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+
+import org.drools.process.instance.WorkItem;
+import org.drools.process.instance.WorkItemHandler;
+import org.drools.process.instance.WorkItemManager;
+
+/**
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class UIWorkItemHandler extends JFrame implements WorkItemHandler {
+
+    private static final long serialVersionUID = 400L;
+    
+    private Map<WorkItem, WorkItemManager> workItems = new HashMap<WorkItem, WorkItemManager>();
+    private JList workItemsList;
+    private JButton selectButton;
+    
+    public UIWorkItemHandler() {
+        setSize(new Dimension(400, 300));
+        setTitle("Work Items");
+        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
+        initializeComponent();
+    }
+    
+    private void initializeComponent() {
+        JPanel panel = new JPanel();
+        panel.setLayout(new GridBagLayout());
+        getRootPane().setLayout(new BorderLayout());
+        getRootPane().add(panel, BorderLayout.CENTER);
+        
+        workItemsList = new JList();
+        workItemsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+        workItemsList.addMouseListener(new MouseAdapter() {
+            public void mouseClicked(MouseEvent e) {
+                if (e.getClickCount() == 2) {
+                    select();
+                }
+            }
+        });
+        workItemsList.addListSelectionListener(new ListSelectionListener() {
+            public void valueChanged(ListSelectionEvent e) {
+                selectButton.setEnabled(getSelectedWorkItem() != null);
+            }
+        });
+        reloadWorkItemsList();
+        GridBagConstraints c = new GridBagConstraints();
+        c.weightx = 1;
+        c.weighty = 1;
+        c.fill = GridBagConstraints.BOTH;
+        c.insets = new Insets(5, 5, 5, 5);
+        panel.add(workItemsList, c);
+        
+        selectButton = new JButton("Select");
+        selectButton.setEnabled(false);
+        selectButton.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent event) {
+                select();
+            }
+        });
+        c = new GridBagConstraints();
+        c.gridy = 1;
+        c.weightx = 1;
+        c.anchor = GridBagConstraints.EAST;
+        c.insets = new Insets(5, 5, 5, 5);
+        panel.add(selectButton, c);
+    }
+    
+    private void select() {
+        WorkItem workItem = getSelectedWorkItem();
+        if (workItem != null) {
+            UIWorkItemHandlerDialog dialog = new UIWorkItemHandlerDialog(UIWorkItemHandler.this, workItem);
+            dialog.setVisible(true);
+        }
+    }
+    
+    public WorkItem getSelectedWorkItem() {
+        int index = workItemsList.getSelectedIndex();
+        if (index != -1) {
+            Object selected = workItemsList.getModel().getElementAt(index);
+            if (selected instanceof WorkItemWrapper) {
+                return ((WorkItemWrapper) selected).getWorkItem();
+            }
+        }
+        return null;
+    }
+    
+    private void reloadWorkItemsList() {
+        List<WorkItemWrapper> result = new ArrayList<WorkItemWrapper>();
+        for (Iterator<WorkItem> iterator = workItems.keySet().iterator(); iterator.hasNext(); ) {
+            WorkItem workItem = iterator.next();
+            result.add(new WorkItemWrapper(workItem));
+        }
+        workItemsList.setListData(result.toArray());
+    }
+    
+    public void complete(WorkItem workItem, Map<String, Object> results) {
+        WorkItemManager manager = workItems.get(workItem);
+        if (manager != null) {
+            manager.completeWorkItem(workItem.getId(), results);
+            workItems.remove(workItem);
+            reloadWorkItemsList();
+        }
+        selectButton.setEnabled(getSelectedWorkItem() != null);
+    }
+    
+    public void abort(WorkItem workItem) {
+        WorkItemManager manager = workItems.get(workItem);
+        if (manager != null) {
+            manager.abortWorkItem(workItem.getId());
+            workItems.remove(workItem);
+            reloadWorkItemsList();
+        }
+        selectButton.setEnabled(getSelectedWorkItem() != null);
+    }
+    
+    public void abortWorkItem(WorkItem workItem, WorkItemManager manager) {
+        workItems.remove(workItem);
+        reloadWorkItemsList();
+    }
+
+    public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {
+        workItems.put(workItem, manager);
+        reloadWorkItemsList();
+    }
+
+    private class WorkItemWrapper {
+        
+        private WorkItem workItem;
+        
+        public WorkItemWrapper(WorkItem workItem) {
+            this.workItem = workItem;
+        }
+        
+        public WorkItem getWorkItem() {
+            return workItem;
+        }
+        
+        public String toString() {
+            return workItem.getName() + " [" + workItem.getId() + "]";
+        }
+    }
+    
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/impl/demo/UIWorkItemHandlerDialog.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/impl/demo/UIWorkItemHandlerDialog.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/instance/impl/demo/UIWorkItemHandlerDialog.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,104 @@
+package org.drools.process.instance.impl.demo;
+
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JPanel;
+import javax.swing.JTextArea;
+
+import org.drools.process.instance.WorkItem;
+
+/**
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class UIWorkItemHandlerDialog extends JDialog {
+    
+    private static final long serialVersionUID = 400L;
+    
+    private UIWorkItemHandler handler;
+    private WorkItem workItem;
+    private JButton completeButton;
+    private JButton abortButton;
+    
+    public UIWorkItemHandlerDialog(UIWorkItemHandler handler, WorkItem workItem) {
+        super(handler, "Execute Work Item", true);
+        this.handler = handler;
+        this.workItem = workItem;
+        setSize(new Dimension(400, 300));
+        initializeComponent();
+    }
+
+    private void initializeComponent() {
+        JPanel panel = new JPanel();
+        panel.setLayout(new GridBagLayout());
+        getRootPane().setLayout(new BorderLayout());
+        getRootPane().add(panel, BorderLayout.CENTER);
+        
+        JTextArea params = new JTextArea();
+        params.setText(getParameters());
+        params.setEditable(false);
+        GridBagConstraints c = new GridBagConstraints();
+        c.weightx = 1;
+        c.weighty = 1;
+        c.gridwidth = 2;
+        c.fill = GridBagConstraints.BOTH;
+        c.insets = new Insets(5, 5, 5, 5);
+        panel.add(params, c);
+        
+        completeButton = new JButton("Complete");
+        completeButton.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent event) {
+                complete();
+            }
+        });
+        c = new GridBagConstraints();
+        c.gridy = 1;
+        c.weightx = 1;
+        c.anchor = GridBagConstraints.EAST;
+        c.insets = new Insets(5, 5, 5, 5);
+        panel.add(completeButton, c);
+
+        abortButton = new JButton("Abort");
+        abortButton.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent event) {
+                abort();
+            }
+        });
+        c = new GridBagConstraints();
+        c.gridx = 1;
+        c.gridy = 1;
+        c.insets = new Insets(5, 5, 5, 5);
+        panel.add(abortButton, c);
+    }
+    
+    private String getParameters() {
+        String result = "";
+        if (workItem.getParameters() != null) {
+            for (Iterator<Map.Entry<String, Object>> iterator = workItem.getParameters().entrySet().iterator(); iterator.hasNext(); ) {
+                Map.Entry<String, Object> entry = iterator.next();
+                result += entry.getKey() + " = " + entry.getValue() + "\n";
+            }
+        }
+        return result;
+    }
+    
+    private void complete() {
+        handler.complete(workItem, null);
+        dispose();
+    }
+    
+    private void abort() {
+        handler.abort(workItem);
+        dispose();
+    }
+}

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/Package.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/Package.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/Package.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -35,7 +35,7 @@
 
 import org.drools.common.DroolsObjectInputStream;
 import org.drools.facttemplates.FactTemplate;
-import org.drools.ruleflow.common.core.Process;
+import org.drools.process.core.Process;
 import org.drools.util.StringUtils;
 
 /**

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/PackageCompilationData.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/PackageCompilationData.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/PackageCompilationData.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -38,14 +38,14 @@
 import org.drools.RuntimeDroolsException;
 import org.drools.base.accumulators.JavaAccumulatorFunctionExecutor;
 import org.drools.common.DroolsObjectInputStream;
-import org.drools.ruleflow.core.impl.ActionNodeImpl;
-import org.drools.ruleflow.core.impl.ReturnValueConstraintEvaluator;
 import org.drools.spi.Accumulator;
 import org.drools.spi.Consequence;
 import org.drools.spi.EvalExpression;
 import org.drools.spi.PredicateExpression;
 import org.drools.spi.ReturnValueEvaluator;
 import org.drools.spi.ReturnValueExpression;
+import org.drools.workflow.core.node.ActionNode;
+import org.drools.workflow.instance.impl.ReturnValueConstraintEvaluator;
 
 public class PackageCompilationData
     implements
@@ -268,8 +268,8 @@
             ((Rule) invoker).setConsequence( (Consequence) clazz.newInstance() );
         } else if ( invoker instanceof JavaAccumulatorFunctionExecutor ) {
             ((JavaAccumulatorFunctionExecutor) invoker).setExpression( (ReturnValueExpression) clazz.newInstance() );
-        } else if ( invoker instanceof ActionNodeImpl ) {
-            ((ActionNodeImpl) invoker).setAction( clazz.newInstance() );
+        } else if ( invoker instanceof ActionNode ) {
+            ((ActionNode) invoker).setAction( clazz.newInstance() );
         } else if ( invoker instanceof ReturnValueConstraintEvaluator ) {
             ((ReturnValueConstraintEvaluator) invoker).setEvaluator( (ReturnValueEvaluator) clazz.newInstance() );
         }

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/ActionNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/ActionNode.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/ActionNode.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,57 +0,0 @@
-package org.drools.ruleflow.core;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Represents an actino in a RuleFlow.
- * An action represents the task that should be performed
- * when executing this node.
- * 
- * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
- */
-public interface ActionNode
-    extends
-    Node {
-
-    /**
-     * Returns the incoming connection of the ActionNode.
-     * 
-     * @return the incoming connection of the ActionNode.
-     */
-    Connection getFrom();
-
-    /**
-     * Returns the outgoing connection of the ActionNode.
-     * 
-     * @return the outgoing connection of the ActionNode.
-     */
-    Connection getTo();
-
-    /**
-     * Returns the action of the ActionNode.
-     * 
-     * @return the action of the ActionNode.
-     */
-    Object getAction();
-
-    /**
-     * Sets the action of the ActionNode.
-     * 
-     * @param constraint	The action of the ActionNode
-     */
-    void setAction(Object action);
-}

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/Connection.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/Connection.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/Connection.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,58 +0,0 @@
-package org.drools.ruleflow.core;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Represents a connection between two nodes in a RuleFlow. 
- * 
- * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
- */
-public interface Connection {
-
-    /**
-     * The connection type
-     */
-    int TYPE_NORMAL = 1;
-    int TYPE_ABORT  = 2;
-
-    /**
-     * Returns the from node of the connection.
-     * @return the from node of the connection.
-     */
-    Node getFrom();
-
-    /**
-     * Returns the to node of the connection
-     * @return the to node of the connection
-     */
-    Node getTo();
-
-    /**
-     * Returns the connection type
-     * @return the connection type
-     */
-    int getType();
-
-    /**
-     * Destroys the connection. This method also removes the
-     * connection on the <code>to</code> and <code>from</code> nodes.
-     * Onces a connection is destroyed, all methods throw
-     * an <code>IllegalStateException</code>.
-     */
-    void terminate();
-
-}

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/Constraint.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/Constraint.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/Constraint.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,98 +0,0 @@
-package org.drools.ruleflow.core;
-
-import org.drools.ruleflow.nodes.split.ConstraintEvaluator;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Represents a constraint in a RuleFlow.
- * Can be used to specify conditions in (X)OR-splits. 
- * 
- * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
- */
-public interface Constraint {
-    /**
-     * Typically this method returns the constraint as a String
-     * @return the constraint
-     */
-    String getConstraint();
-
-    /**
-     * Method for setting the constraint
-     * @param constraint 	the constraint
-     */
-    void setConstraint(String constraint);
-
-    /**
-     * Returns the name of the constraint
-     * @return the name of the constraint
-     */
-    String getName();
-
-    /**
-     * Sets the name of the constraint
-     * @param name	the name of the constraint
-     */
-    void setName(String name);
-
-    /**
-     * Returns the priority of the constraint
-     * 
-     * @return the priority of the constraint
-     */
-    int getPriority();
-
-    /**
-     * Method for setting the priority of the constraint
-     * 
-     * @param priority	the priority of the constraint
-     */
-    void setPriority(int priority);
-
-    /**
-     * Returns the type of the constraint,
-     * e.g. "code" or "rule"
-     * 
-     * @return the type of the constraint
-     */
-    String getType();
-
-    /**
-     * Method for setting the type of the constraint,
-     * e.g. "code" or "rule"
-     * 
-     * @param type  the type of the constraint
-     */
-    void setType(String type);
-
-    /**
-     * Returns the dialect of the constraint,
-     * e.g. "mvel" or "java"
-     * 
-     * @return the dialect of the constraint
-     */
-    String getDialect();
-
-    /**
-     * Method for setting the dialect of the constraint,
-     * e.g. "mvel" or "java"
-     * 
-     * @param type  the dialect of the constraint
-     */
-    void setDialect(String dialect);
-
-}

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/EndNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/EndNode.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/EndNode.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,35 +0,0 @@
-package org.drools.ruleflow.core;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Represents an end node in a RuleFlow. 
- * An end node has one incoming and no outgoing connections.
- * 
- * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
- */
-public interface EndNode
-    extends
-    Node {
-
-    /**
-     * Convenience method for returning the incoming <code>IConnection</code>.
-     * @return the incoming <code>IConnection</code>
-     */
-    Connection getFrom();
-
-}

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/Join.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/Join.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/Join.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,73 +0,0 @@
-package org.drools.ruleflow.core;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Represents a join node in a RuleFlow. 
- * A join is a special kind of node with multiple incoming connections and
- * one outgoing connection.  The type of join decides when the outgoing
- * connections will be triggered (based on which incoming connections have
- * been triggered).
- * 
- * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
- */
-public interface Join
-    extends
-    Node {
-
-    int TYPE_UNDEFINED     = 0;
-    /**
-     * The outgoing connection of a join of this type is triggered
-     * when all its incoming connections have been triggered.
-     */
-    int TYPE_AND           = 1;
-    /**
-     * The outgoing connection of a join of this type is triggered
-     * when one of its incoming connections has been triggered.
-     */
-    int TYPE_XOR           = 2;
-    /**
-     * The outgoing connection of a join of this type is triggered
-     * when one of its incoming connections has been triggered. It then
-     * waits until all other incoming connections have been triggered
-     * before allowing 
-     */
-    int TYPE_DISCRIMINATOR = 3;
-
-    /**
-     * Sets the type of the join.
-     * 
-     * @param type	The type of the join
-     * @throws IllegalArgumentException if type is null
-     */
-    void setType(int type);
-
-    /**
-     * Returns the type of the join.
-     * 
-     * @return the type of the join.
-     */
-    int getType();
-
-    /**
-     * Convenience method for returning the outgoing connection of the join
-     * 
-     * @return the outgoing connection of the join
-     */
-    Connection getTo();
-
-}

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/MilestoneNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/MilestoneNode.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/MilestoneNode.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,57 +0,0 @@
-package org.drools.ruleflow.core;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Represents a milestone in a RuleFlow.
- * A milestone has an associated constraint.
- * Flow will only continue if this constraint has been satisfied.  
- * 
- * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
- */
-public interface MilestoneNode
-    extends
-    Node {
-
-    /**
-     * Returns the incoming connection of the MilestoneNode.
-     * 
-     * @return the incoming connection of the MilestoneNode.
-     */
-    Connection getFrom();
-
-    /**
-     * Returns the outgoing connection of the MilestoneNode.
-     * 
-     * @return the outgoing connection of the MilestoneNode.
-     */
-    Connection getTo();
-
-    /**
-     * Returns the constraint of the MilestoneNode.
-     * 
-     * @return the constraint of the MilestoneNode.
-     */
-    String getConstraint();
-
-    /**
-     * Sets the constraint of the MilestoneNode.
-     * 
-     * @param constraint	The constraint of the MilestoneNode
-     */
-    void setConstraint(String constraint);
-}

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/Node.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/Node.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/Node.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,71 +0,0 @@
-package org.drools.ruleflow.core;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import java.io.Serializable;
-import java.util.List;
-
-/**
- * Represents a node in a RuleFlow. 
- * 
- * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
- */
-public interface Node
-    extends
-    Serializable {
-
-    /**
-     * Returns the id of the node
-     * 
-     * @return the id of the node
-     */
-    long getId();
-
-    /**
-     * Method for setting the id of the node
-     * 
-     * @param id	the id of the node
-     */
-    void setId(long id);
-
-    /**
-     * Returns the name of the node
-     * 
-     * @return the name of the node
-     */
-    String getName();
-
-    /**
-     * Method for setting the name of the node
-     * 
-     * @param name 	the name of the node
-     */
-    void setName(String name);
-
-    /**
-     * Returns the incoming connections
-     * @return the incoming connections 
-     */
-    List getIncomingConnections();
-
-    /**
-     * Returns the outgoing connections
-     * @return the outgoing connections 
-     */
-    List getOutgoingConnections();
-
-}

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/RuleFlowProcess.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/RuleFlowProcess.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/RuleFlowProcess.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,132 +0,0 @@
-package org.drools.ruleflow.core;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import java.util.List;
-import java.util.Map;
-
-import org.drools.ruleflow.common.core.Process;
-
-/**
- * Represents a RuleFlow process. 
- * 
- * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
- */
-public interface RuleFlowProcess
-    extends
-    Process {
-
-    /**
-     * Returns the start node of this RuleFlow process.
-     * 
-     * @return	the start node
-     */
-    StartNode getStart();
-
-    /**
-     * Returns the nodes of this RuleFlow process.
-     * 
-     * @return	the nodes of this RuleFlow process
-     */
-    Node[] getNodes();
-
-    /**
-     * Returns the node with the given id
-     * 
-     * @param id	the node id
-     * @return	the node with the given id
-     * @throws IllegalArgumentException if an unknown id is passed
-     */
-    Node getNode(long id);
-
-    /**
-     * Method for adding a node to this RuleFlow process. 
-     * Note that the node will get an id unique for this process.
-     * 
-     * @param node	the node to be added
-     * @throws IllegalArgumentException if <code>node</code> is null 
-     */
-    void addNode(Node node);
-
-    /**
-     * Method for removing a node from this RuleFlow process
-     * 
-     * @param node	the node to be removed
-     * @throws IllegalArgumentException if <code>node</code> is null or unknown
-     */
-    void removeNode(Node node);
-
-    /**
-     * Returns the variables used in this RuleFlow process
-     * 
-     * @return	a list of variables of this RuleFlow process
-     */
-    List getVariables();
-
-    /**
-     * Sets the variables used in this RuleFlow process
-     * 
-     * @param variables	the variables
-     * @throws IllegalArugmentException if <code>variables</code> is null
-     */
-    void setVariables(List variables);
-
-    /**
-     * Returns the names of the variables used in this RuleFlow process
-     * 
-     * @return	the variable names of this RuleFlow process
-     */
-    String[] getVariableNames();
-    
-    /**
-     * Returns the imports of this RuleFlow process.
-     * They are defined as a List of fully qualified class names.
-     * 
-     * @return	the imports of this RuleFlow process
-     */
-    List getImports();
-    
-    /**
-     * Sets the imports of this RuleFlow process
-     * 
-     * @param imports	the imports as a List of fully qualified class names
-     */
-    void setImports(List imports);
-
-    /**
-     * Returns the globals of this RuleFlow process.
-     * They are defined as a Map with the name as key and the type as value.
-     * 
-     * @return	the imports of this RuleFlow process
-     */
-    Map getGlobals();
-    
-    /**
-     * Sets the imports of this RuleFlow process
-     * 
-     * @param imports	the globals as a Map with the name as key and the type as value
-     */
-    void setGlobals(Map globals);
-
-    /**
-     * Returns the names of the globals used in this RuleFlow process
-     * 
-     * @return	the names of the globals of this RuleFlow process
-     */
-    String[] getGlobalNames();
-    
-}

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/RuleFlowProcessValidationError.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/RuleFlowProcessValidationError.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/RuleFlowProcessValidationError.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,61 +0,0 @@
-package org.drools.ruleflow.core;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Represents a RuleFlow validation error. 
- * 
- * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
- */
-public interface RuleFlowProcessValidationError {
-
-    String NO_PROCESS_NAME                              = "RuleFlow process has no name.";
-    String NO_PROCESS_ID                                = "RuleFlow process has no id.";
-    String NO_START_NODE                                = "RuleFlow process has no start node.";
-    String NO_PACKAGE_NAME                              = "RuleFlow process has no package name.";
-    String START_NODE_WITHOUT_OUTGOING_NODES            = "Start node has no outgoing connection.";
-    String END_NODE_HAS_NO_INCOMING_CONNECTIONS         = "End node has no incoming connection.";
-    String NO_END_NODE                                  = "No end node found.";
-    String RULE_SET_NODE_WITHOUT_INCOMING_CONNECTIONS   = "RuleSet node has no incoming connection.";
-    String RULE_SET_NODE_WITHOUT_OUTGOING_CONNECTIONS   = "RuleSet node has no outgoing connection.";
-    String RULE_SET_NODE_WITHOUT_RULE_SET_GROUP         = "RuleSet node has no ruleflow-group specified.";
-    String SPLIT_WITHOUT_TYPE                           = "Split node has no type.";
-    String SPLIT_WITHOUT_INCOMING_CONNECTION            = "Split node has no incoming connection.";
-    String SPLIT_NOT_ENOUGH_OUTGOING_CONNECTIONS        = "Split node does not have enough outgoing connections.";
-    String SPLIT_OUTGOING_CONNECTION_WITHOUT_CONSTRAINT = "An outgoing connection of a split node has no constraint.";
-    String JOIN_WITHOUT_TYPE                            = "Join node has no type.";
-    String JOIN_NOT_ENOUGH_INCOMING_CONNECTIONS         = "Join node does not have enough incoming connections.";
-    String JOIN_WITHOUT_OUTGOING_CONNECTION             = "Join node has no outgoing connection.";
-    String VARIABLE_WITHOUT_TYPE                        = "A variable has no type.";
-    String ALL_NODES_CONNECTED_TO_START                 = "A node is not connected to the start node.";
-    String MILESTONE_NODE_WITHOUT_INCOMING_CONNECTIONS  = "Milestone node has no incoming connection.";
-    String MILESTONE_NODE_WITHOUT_OUTGOING_CONNECTIONS  = "Milestone node has no outgoing connection.";
-    String MILESTONE_WITHOUT_CONSTRAINT                 = "A milestone node has no constraint.";
-    String SUBFLOW_NODE_WITHOUT_INCOMING_CONNECTIONS    = "SubFlow node has no incoming connection.";
-    String SUBFLOW_NODE_WITHOUT_OUTGOING_CONNECTIONS    = "SubFlow node has no outgoing connection.";
-    String SUBFLOW_WITHOUT_PROCESS_ID                   = "A SubFlow node has no process id.";
-    String ACTION_NODE_WITHOUT_INCOMING_CONNECTIONS     = "Action node has no incoming connection.";
-    String ACTION_NODE_WITHOUT_OUTGOING_CONNECTIONS     = "Action node has no outgoing connection.";
-    String ACTION_NODE_WITHOUT_ACTION                   = "An Action node has no action.";
-    String ACTION_NODE_WITH_INVALID_ACTION              = "An Action node has an invalid action.";
-    String TASK_NODE_WITHOUT_INCOMING_CONNECTIONS       = "Task node has no incoming connection.";
-    String TASK_NODE_WITHOUT_OUTGOING_CONNECTIONS       = "Task node has no outgoing connection.";
-    String TASK_NODE_WITHOUT_TASK                       = "A Task node has no task.";
-    String TASK_NODE_WITH_INVALID_TASK                  = "A Task node has an invalid task.";
-
-    String getType();
-}

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/RuleFlowProcessValidator.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/RuleFlowProcessValidator.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/RuleFlowProcessValidator.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,28 +0,0 @@
-package org.drools.ruleflow.core;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * A validator for validating a RuleFlow process. 
- * 
- * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
- */
-public interface RuleFlowProcessValidator {
-
-    RuleFlowProcessValidationError[] validateProcess(RuleFlowProcess process);
-
-}

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/RuleSetNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/RuleSetNode.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/RuleSetNode.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,56 +0,0 @@
-package org.drools.ruleflow.core;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Represents a node containing a set of rules in a RuleFlow. 
- * 
- * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
- */
-public interface RuleSetNode
-    extends
-    Node {
-
-    /**
-     * Returns the incoming connection of the RuleSetNode.
-     * 
-     * @return the incoming connection of the RuleSetNode.
-     */
-    Connection getFrom();
-
-    /**
-     * Returns the outgoing connection of the RuleSetNode.
-     * 
-     * @return the outgoing connection of the RuleSetNode.
-     */
-    Connection getTo();
-
-    /**
-     * Returns the ruleflow-group of the RuleSetNode.
-     * 
-     * @return the ruleflow-group of the RuleSetNode.
-     */
-    String getRuleFlowGroup();
-
-    /**
-     * Sets the ruleflow-group of the RuleSetNode.
-     * 
-     * @param ruleFlowGroup	The ruleflow-group of the RuleSetNode
-     * @throws IllegalArgumentException if type is null
-     */
-    void setRuleFlowGroup(String ruleFlowGroup);
-}

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/Split.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/Split.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/Split.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,117 +0,0 @@
-package org.drools.ruleflow.core;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import java.util.Map;
-
-/**
- * Represents a split node in a RuleFlow. 
- * A split is a special kind of node with one incoming connection and
- * multiple outgoing connections.  The type of split decides which of the
- * outgoing connections will be triggered when the incoming connection 
- * has been triggered.
- * 
- * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
- */
-public interface Split
-    extends
-    Node {
-
-    int TYPE_UNDEFINED = 0;
-    /**
-     * All outgoing connections of a split of this type are triggered
-     * when its incoming connection has been triggered.  A split of this
-     * type should have no constraints linked to any of its outgoing
-     * connections.
-     */
-    int TYPE_AND       = 1;
-    /**
-     * Exactly one outgoing connection of a split of this type is triggered
-     * when its incoming connection has been triggered.  Which connection
-     * is based on the constraints associated with each of the connections:
-     * the connection with the highest priority whose constraint is satisfied
-     * is triggered.  
-     */
-    int TYPE_XOR       = 2;
-    /**
-     * One or multiple outgoing connections of a split of this type are
-     * triggered when its incoming connection has been triggered.  Which
-     * connections is based on the constraints associated with each of the
-     * connections: all connections whose constraint is satisfied are
-     * triggered.  
-     */
-    int TYPE_OR        = 3;
-
-    /**
-     * Sets the type of the split.
-     * 
-     * @param type	The type of the split
-     * @throws IllegalArgumentException if type is null
-     */
-    void setType(int type);
-
-    /**
-     * Returns the type of the split.
-     * 
-     * @return the type of the split.
-     */
-    int getType();
-
-    /**
-     * Returns the corresponding constraint of the given outgoing connection
-     * 
-     * @param connection	the outgoing connection
-     * @return	the corresponding constraint of the given outgoing connection
-     * @throws IllegalArgumentException if <code>connection</code> is
-     * not a valid outgoing connection for this split
-     * @throws UnsupportedOperationException if this method is called
-     * on a split with split type of something else than XOR or OR
-     */
-    Constraint getConstraint(Connection connection);
-
-    /**
-     * Method for setting a constraint corresponding to the given
-     * outgoing connection
-     * 
-     * @param connection	the outgoing connection
-     * @param constraint	the constraint 
-     * @throws IllegalArgumentException if <code>connection</code> is
-     * not a valid outgoing connection for this split
-     * @throws UnsupportedOperationException if the split type is 
-     * something else than XOR or OR
-     */
-    void setConstraint(Connection connection,
-                       Constraint constraint);
-
-    /**
-     * Returns the constraints of the split.
-     * 
-     * @return a map containing for each connection the constraint associated with
-     * that connection, or null if no constraint has been specified yet for that connection
-     * @throws UnsupportedOperationException if this method is called
-     * on a split with split type of something else than XOR or OR
-     */
-    Map getConstraints();
-
-    /**
-     * Convenience method for returning the incoming connection of the split.
-     * 
-     * @return the incoming connection ot the split.
-     */
-    Connection getFrom();
-
-}

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/StartNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/StartNode.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/StartNode.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,35 +0,0 @@
-package org.drools.ruleflow.core;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Represents a start node in a RuleFlow. 
- * A start node has no incoming and one outgoing connection.
- * 
- * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
- */
-public interface StartNode
-    extends
-    Node {
-
-    /**
-     * Convenience method for returning the outgoing <code>IConnection</code>.
-     * @return the outgoing <code>IConnection</code>
-     */
-    Connection getTo();
-
-}

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/SubFlowNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/SubFlowNode.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/SubFlowNode.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,74 +0,0 @@
-package org.drools.ruleflow.core;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Represents a sub-flow in a RuleFlow.
- * The node will continue if the sub-flow has ended.
- * 
- * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
- */
-public interface SubFlowNode
-    extends
-    Node {
-
-    /**
-     * Returns the incoming connection of the SubFlowNode.
-     * 
-     * @return the incoming connection of the SubFlowNode.
-     */
-    Connection getFrom();
-
-    /**
-     * Returns the outgoing connection of the SubFlowNode.
-     * 
-     * @return the outgoing connection of the SubFlowNode.
-     */
-    Connection getTo();
-
-    /**
-     * Returns the process id of the SubFlowNode.
-     * 
-     * @return the process id of the SubFlowNode.
-     */
-    String getProcessId();
-
-    /**
-     * Sets the process id of the SubFlowNode.
-     * 
-     * @param processId	The process id of the SubFlowNode
-     */
-    void setProcessId(String processId);
-    
-    /**
-     * Sets whether this node should wait until the sub-flow has been
-     * completed.
-     * 
-     * @param waitForCompletion  whether this node should wait until the sub-flow has been completed
-     */
-    void setWaitForCompletion(boolean waitForCompletion);
-
-    /**
-     * Returns whether this node should wait until the sub-flow has been
-     * completed.
-     * 
-     * @return whether this node should wait until the sub-flow has been
-     * completed.
-     */
-    boolean isWaitForCompletion();
-
-}

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/Variable.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/Variable.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/Variable.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,44 +0,0 @@
-package org.drools.ruleflow.core;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import java.io.Serializable;
-
-import org.drools.ruleflow.common.datatype.DataType;
-
-/**
- * Represents a global variable used in a RuleFlow.
- * A variable has a name (should be unique for this process), a datatype
- * and possibly an initial value.  
- * 
- * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
- */
-public interface Variable {
-
-    String getName();
-
-    void setName(String name);
-
-    DataType getType();
-
-    void setType(DataType type);
-
-    Serializable getValue();
-
-    void setValue(Serializable value);
-
-}

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/WorkItemNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/WorkItemNode.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/WorkItemNode.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,57 +0,0 @@
-package org.drools.ruleflow.core;
-
-import org.drools.ruleflow.common.core.Work;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Represents a task in a RuleFlow.
- * 
- * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
- */
-public interface WorkItemNode
-    extends
-    Node {
-
-    /**
-     * Returns the incoming connection of the TaskNode.
-     * 
-     * @return the incoming connection of the TaskNode.
-     */
-    Connection getFrom();
-
-    /**
-     * Returns the outgoing connection of the TaskNode.
-     * 
-     * @return the outgoing connection of the TaskNode.
-     */
-    Connection getTo();
-
-    /**
-     * Returns the work of the WorkItemNode.
-     * 
-     * @return the work of the WorkItemNode.
-     */
-    Work getWork();
-
-    /**
-     * Sets the work of the WorkItemNode.
-     * 
-     * @param constraint	The work of the WorkItemNode
-     */
-    void setWork(Work work);
-}

Copied: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/validation/RuleFlowProcessValidator.java (from rev 17570, labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/RuleFlowProcessValidator.java)
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/validation/RuleFlowProcessValidator.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/validation/RuleFlowProcessValidator.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,323 @@
+package org.drools.ruleflow.core.validation;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.drools.process.core.Process;
+import org.drools.process.core.Variable;
+import org.drools.process.core.Work;
+import org.drools.process.core.validation.ProcessValidationError;
+import org.drools.process.core.validation.ProcessValidator;
+import org.drools.process.core.validation.impl.ProcessValidationErrorImpl;
+import org.drools.ruleflow.core.RuleFlowProcess;
+import org.drools.workflow.core.Connection;
+import org.drools.workflow.core.Node;
+import org.drools.workflow.core.impl.DroolsConsequenceAction;
+import org.drools.workflow.core.node.ActionNode;
+import org.drools.workflow.core.node.EndNode;
+import org.drools.workflow.core.node.Join;
+import org.drools.workflow.core.node.MilestoneNode;
+import org.drools.workflow.core.node.RuleSetNode;
+import org.drools.workflow.core.node.Split;
+import org.drools.workflow.core.node.StartNode;
+import org.drools.workflow.core.node.SubProcessNode;
+import org.drools.workflow.core.node.WorkItemNode;
+import org.mvel.ErrorDetail;
+import org.mvel.ExpressionCompiler;
+import org.mvel.ParserContext;
+
+/**
+ * Default implementation of a RuleFlow validator.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class RuleFlowProcessValidator implements ProcessValidator {
+    
+    // TODO: make this pluggable
+    // TODO: extract generic process stuff and generic workflow stuff
+
+    private static RuleFlowProcessValidator instance;
+
+    private RuleFlowProcessValidator() {
+    }
+
+    public static RuleFlowProcessValidator getInstance() {
+        if ( instance == null ) {
+            instance = new RuleFlowProcessValidator();
+        }
+        return instance;
+    }
+
+    public ProcessValidationError[] validateProcess(final RuleFlowProcess process) {
+        final List<ProcessValidationError> errors = new ArrayList<ProcessValidationError>();
+
+        if (process.getName() == null) {
+            errors.add(new ProcessValidationErrorImpl(process,
+                "Process has no name."));
+        }
+
+        if (process.getId() == null || "".equals(process.getId())) {
+            errors.add(new ProcessValidationErrorImpl(process,
+                "Process has no id."));
+        }
+
+        if ( process.getPackageName() == null || "".equals( process.getPackageName() ) ) {
+            errors.add(new ProcessValidationErrorImpl(process,
+                "Process has no package name."));
+        }
+
+        // check start node of process
+        if ( process.getStart() == null ) {
+            errors.add(new ProcessValidationErrorImpl(process,
+                "Process has no start node."));
+        }
+
+        boolean startNodeFound = false;
+        boolean endNodeFound = false;
+        final Node[] nodes = process.getNodes();
+        for ( int i = 0; i < nodes.length; i++ ) {
+            final Node node = nodes[i];
+            if (node instanceof StartNode) {
+                final StartNode startNode = (StartNode) node;
+                startNodeFound = true;
+                if (startNode.getTo() == null) {
+                    errors.add(new ProcessValidationErrorImpl(process,
+                        "Start node '" + node.getName() + "' [" + node.getId() + "] has no outgoing connection."));
+                }
+            } else if (node instanceof EndNode) {
+                final EndNode endNode = (EndNode) node;
+                endNodeFound = true;
+                if (endNode.getFrom() == null) {
+                    errors.add(new ProcessValidationErrorImpl(process,
+                        "End node '" + node.getName() + "' [" + node.getId() + "] has no incoming connection."));
+                }
+            } else if (node instanceof RuleSetNode) {
+                final RuleSetNode ruleSetNode = (RuleSetNode) node;
+                if (ruleSetNode.getFrom() == null) {
+                    errors.add(new ProcessValidationErrorImpl(process,
+                        "RuleSet node '" + node.getName() + "' [" + node.getId() + "] has no incoming connection."));
+                }
+                if (ruleSetNode.getTo() == null) {
+                    errors.add(new ProcessValidationErrorImpl(process,
+                        "RuleSet node '" + node.getName() + "' [" + node.getId() + "] has no outgoing connection."));
+                }
+                final String ruleFlowGroup = ruleSetNode.getRuleFlowGroup();
+                if (ruleFlowGroup == null || "".equals(ruleFlowGroup)) {
+                    errors.add( new ProcessValidationErrorImpl(process,
+                        "RuleSet node '" + node.getName() + "' [" + node.getId() + "] has no ruleflow-group."));
+                }
+            } else if (node instanceof Split) {
+                final Split split = (Split) node;
+                if (split.getType() == Split.TYPE_UNDEFINED) {
+                    errors.add(new ProcessValidationErrorImpl(process,
+                        "Split node '" + node.getName() + "' [" + node.getId() + "] has no type."));
+                }
+                if (split.getFrom() == null) {
+                    errors.add(new ProcessValidationErrorImpl(process,
+                        "Split node '" + node.getName() + "' [" + node.getId() + "] has no incoming connection."));
+                }
+                if (split.getDefaultOutgoingConnections().size() < 2) {
+                    errors.add(new ProcessValidationErrorImpl(process,
+                        "Split node '" + node.getName() + "' [" + node.getId() + "] does not have more than one outgoing connection: " + split.getOutgoingConnections().size() + "."));
+                }
+                if (split.getType() == Split.TYPE_XOR || split.getType() == Split.TYPE_OR ) {
+                    for ( final Iterator<Connection> it = split.getDefaultOutgoingConnections().iterator(); it.hasNext(); ) {
+                        final Connection connection = it.next();
+                        if (split.getConstraint(connection) == null) {
+                            errors.add(new ProcessValidationErrorImpl(process,
+                                "Split node '" + node.getName() + "' [" + node.getId() + "] does not have a constraint for " + connection.toString() + "."));
+                        }
+                    }
+                }
+            } else if ( node instanceof Join ) {
+                final Join join = (Join) node;
+                if (join.getType() == Join.TYPE_UNDEFINED) {
+                    errors.add(new ProcessValidationErrorImpl(process,
+                        "Join node '" + node.getName() + "' [" + node.getId() + "] has no type."));
+                }
+                if (join.getDefaultIncomingConnections().size() < 2) {
+                    errors.add(new ProcessValidationErrorImpl(process,
+                        "Join node '" + node.getName() + "' [" + node.getId() + "] does not have more than one incoming connection: " + join.getIncomingConnections().size() + "."));
+                }
+                if (join.getTo() == null) {
+                    errors.add(new ProcessValidationErrorImpl(process,
+                        "Join node '" + node.getName() + "' [" + node.getId() + "] has no outgoing connection."));
+                }
+            } else if (node instanceof MilestoneNode) {
+                final MilestoneNode milestone = (MilestoneNode) node;
+                if (milestone.getFrom() == null) {
+                    errors.add(new ProcessValidationErrorImpl(process,
+                        "Milestone node '" + node.getName() + "' [" + node.getId() + "] has no incoming connection."));
+                }
+
+                if (milestone.getTo() == null) {
+                    errors.add( new ProcessValidationErrorImpl(process,
+                        "Milestone node '" + node.getName() + "' [" + node.getId() + "] has no outgoing connection."));
+                }
+                if (milestone.getConstraint() == null) {
+                    errors.add( new ProcessValidationErrorImpl(process,
+                        "Milestone node '" + node.getName() + "' [" + node.getId() + "] has no constraint."));
+                }
+            } else if (node instanceof SubProcessNode) {
+                final SubProcessNode subProcess = (SubProcessNode) node;
+                if (subProcess.getFrom() == null) {
+                    errors.add(new ProcessValidationErrorImpl(process,
+                        "SubProcess node '" + node.getName() + "' [" + node.getId() + "] has no incoming connection."));
+                }
+                if (subProcess.getTo() == null) {
+                    errors.add(new ProcessValidationErrorImpl(process,
+                        "SubProcess node '" + node.getName() + "' [" + node.getId() + "] has no outgoing connection."));
+                }
+                if (subProcess.getProcessId() == null) {
+                    errors.add(new ProcessValidationErrorImpl(process,
+                        "SubProcess node '" + node.getName() + "' [" + node.getId() + "] has no process id."));
+                }
+            } else if (node instanceof ActionNode) {
+                final ActionNode actionNode = (ActionNode) node;
+                if (actionNode.getFrom() == null) {
+                    errors.add(new ProcessValidationErrorImpl(process,
+                        "Action node '" + node.getName() + "' [" + node.getId() + "] has no incoming connection."));
+                }
+                if (actionNode.getTo() == null) {
+                    errors.add(new ProcessValidationErrorImpl(process,
+                        "Action node '" + node.getName() + "' [" + node.getId() + "] has no outgoing connection."));
+                }
+                if (actionNode.getAction() == null) {
+                    errors.add(new ProcessValidationErrorImpl(process,
+                        "Action node '" + node.getName() + "' [" + node.getId() + "] has no action."));
+                } else {
+                	if (actionNode.getAction() instanceof DroolsConsequenceAction) {
+                		DroolsConsequenceAction droolsAction = (DroolsConsequenceAction) actionNode.getAction();
+                		String actionString = droolsAction.getConsequence();
+                		if (actionString == null) {
+                            errors.add(new ProcessValidationErrorImpl(process,
+                                "Action node '" + node.getName() + "' [" + node.getId() + "] has empty action."));
+                		} else {
+	                    	try {
+	                    		ExpressionCompiler compiler = new ExpressionCompiler(actionString);
+	                    		compiler.setVerifying(true);
+		                		ParserContext parserContext = new ParserContext();
+		                		//parserContext.setStrictTypeEnforcement(true);
+		                		compiler.compile(parserContext);
+		                		List<ErrorDetail> mvelErrors = parserContext.getErrorList();
+		                		if (mvelErrors != null) {
+		                			for (Iterator<ErrorDetail> iterator = mvelErrors.iterator(); iterator.hasNext(); ) {
+		                			    ErrorDetail error = iterator.next();
+		                                errors.add(new ProcessValidationErrorImpl(process,
+	                                        "Action node '" + node.getName() + "' [" + node.getId() + "] has invalid action: " + error.getMessage() + "."));
+		                			}
+		                		}
+	                    	} catch (Throwable t) {
+                                errors.add(new ProcessValidationErrorImpl(process,
+                                    "Action node '" + node.getName() + "' [" + node.getId() + "] has invalid action: " + t.getMessage() + "."));
+	                    	}
+                		}
+                	}
+                }
+            } else if (node instanceof WorkItemNode) {
+                final WorkItemNode workItemNode = (WorkItemNode) node;
+                if (workItemNode.getFrom() == null) {
+                    errors.add(new ProcessValidationErrorImpl(process,
+                        "WorkItem node '" + node.getName() + "' [" + node.getId() + "] has no incoming connection."));
+                }
+                if (workItemNode.getTo() == null) {
+                    errors.add(new ProcessValidationErrorImpl(process,
+                        "WorkItem node '" + node.getName() + "' [" + node.getId() + "] has no outgoing connection."));
+                }
+                if (workItemNode.getWork() == null) {
+                    errors.add(new ProcessValidationErrorImpl(process,
+                        "WorkItem node '" + node.getName() + "' [" + node.getId() + "] has no work specified."));
+                } else {
+                    Work work = workItemNode.getWork();
+                    if (work.getName() == null) {
+                        errors.add(new ProcessValidationErrorImpl(process,
+                            "WorkItem node '" + node.getName() + "' [" + node.getId() + "] has no work name."));
+                    }
+                }
+            } 
+        }
+        if (!startNodeFound) {
+            errors.add(new ProcessValidationErrorImpl(process,
+                "Process has no start node."));
+        }
+        if (!endNodeFound) {
+            errors.add(new ProcessValidationErrorImpl(process,
+                "Process has no end node."));
+        }
+        for (final Iterator<Variable> it = process.getVariables().iterator(); it.hasNext(); ) {
+            final Variable variable = it.next();
+            if (variable.getType() == null) {
+                errors.add(new ProcessValidationErrorImpl(process,
+                    "Variable '" + variable.getName() + "' has no type."));
+            }
+        }
+
+        checkAllNodesConnectedToStart(process, errors);
+
+        return errors.toArray(new ProcessValidationError[errors.size()]);
+    }
+
+    private void checkAllNodesConnectedToStart(final RuleFlowProcess process,
+                                               final List<ProcessValidationError> errors) {
+        final Map<Node, Boolean> processNodes = new HashMap<Node, Boolean>();
+        final Node[] nodes = process.getNodes();
+        for (int i = 0; i < nodes.length; i++) {
+            final Node node = nodes[i];
+            processNodes.put(node, Boolean.FALSE);
+        }
+        final Node start = process.getStart();
+        if (start != null) {
+            processNode(start, processNodes);
+        }
+        for ( final Iterator<Node> it = processNodes.keySet().iterator(); it.hasNext(); ) {
+            final Node node = it.next();
+            if (Boolean.FALSE.equals(processNodes.get(node))) {
+                errors.add(new ProcessValidationErrorImpl(process,
+                    "Node '" + node.getName() + "' [" + node.getId() + "] has no connection to the start node."));
+            }
+        }
+    }
+
+    private void processNode(final Node node, final Map<Node, Boolean> nodes) {
+        if (!nodes.containsKey(node) ) {
+            throw new IllegalStateException("A process node is connected with a node that does not belong to the process.");
+        }
+        final Boolean prevValue = (Boolean) nodes.put(node, Boolean.TRUE);
+        if (prevValue == Boolean.FALSE) {
+            for (final Iterator<List<Connection>> it = node.getOutgoingConnections().values().iterator(); it.hasNext(); ) {
+                final List<Connection> list = it.next();
+                for (final Iterator<Connection> it2 = list.iterator(); it2.hasNext(); ) {
+                    processNode(it2.next().getTo(), nodes);
+                }
+            }
+        }
+    }
+
+    public ProcessValidationError[] validateProcess(Process process) {
+        if (!(process instanceof RuleFlowProcess)) {
+            throw new IllegalArgumentException(
+                "This validator can only validate ruleflow processes!");
+        }
+        return validateProcess((RuleFlowProcess) process);
+    }
+
+}

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/RuleFlowNodeInstance.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/RuleFlowNodeInstance.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/RuleFlowNodeInstance.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,49 +0,0 @@
-package org.drools.ruleflow.instance;
-
-import org.drools.ruleflow.core.Node;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Represents a node instance in a RuleFlow. This is the runtime counterpart
- * of a node, containing all runtime state.  Node instance classes also
- * contain the logic on what to do when it is being triggered (start
- * executing) or completed (end of execution).
- * 
- * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
- */
-public interface RuleFlowNodeInstance {
-
-    void setId(long id);
-
-    long getId();
-
-    void setNodeId(long nodeId);
-
-    long getNodeId();
-    
-    Node getNode();
-
-    void setProcessInstance(RuleFlowProcessInstance processInstance);
-
-    RuleFlowProcessInstance getProcessInstance();
-
-    void trigger(RuleFlowNodeInstance from);
-
-    void cancel();
-
-}

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/RuleFlowProcessInstance.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/RuleFlowProcessInstance.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/RuleFlowProcessInstance.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,59 +0,0 @@
-package org.drools.ruleflow.instance;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import java.util.Collection;
-
-import org.drools.Agenda;
-import org.drools.WorkingMemory;
-import org.drools.common.InternalWorkingMemory;
-import org.drools.ruleflow.common.instance.ProcessInstance;
-import org.drools.ruleflow.core.Node;
-import org.drools.ruleflow.core.RuleFlowProcess;
-
-/**
- * A process instance for a RuleFlow process.
- * Contains a reference to all its node instances, and the agenda that
- * is controlling the RuleFlow process.
- * 
- * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
- */
-public interface RuleFlowProcessInstance
-    extends
-    ProcessInstance {
-
-    RuleFlowProcess getRuleFlowProcess();
-
-    void addNodeInstance(RuleFlowNodeInstance nodeInstance);
-
-    void removeNodeInstance(RuleFlowNodeInstance nodeInstance);
-
-    Collection getNodeInstances();
-
-    RuleFlowNodeInstance getFirstNodeInstance(long nodeId);
-
-    void setWorkingMemory(InternalWorkingMemory workingMemory);
-    
-    WorkingMemory getWorkingMemory();
-
-    Agenda getAgenda();
-
-    RuleFlowNodeInstance getNodeInstance(Node node);
-
-    void start();
-
-}
\ No newline at end of file

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/RuleFlowProcessInstanceFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/RuleFlowProcessInstanceFactory.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/RuleFlowProcessInstanceFactory.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,18 @@
+package org.drools.ruleflow.instance;
+
+import java.io.Serializable;
+
+import org.drools.process.instance.ProcessInstance;
+import org.drools.process.instance.ProcessInstanceFactory;
+
+public class RuleFlowProcessInstanceFactory implements ProcessInstanceFactory, Serializable {
+
+    private static final long serialVersionUID = 400L;
+
+    public ProcessInstance createProcessInstance() {
+        return new RuleFlowProcessInstance();
+    }
+    
+    
+
+}

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/ActionNodeInstanceImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/ActionNodeInstanceImpl.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/ActionNodeInstanceImpl.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,114 +0,0 @@
-package org.drools.ruleflow.instance.impl;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import java.io.Serializable;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.drools.base.ClassTypeResolver;
-import org.drools.base.TypeResolver;
-import org.drools.base.mvel.DroolsMVELFactory;
-import org.drools.ruleflow.core.ActionNode;
-import org.drools.ruleflow.core.impl.DroolsConsequenceAction;
-import org.drools.ruleflow.instance.RuleFlowNodeInstance;
-import org.drools.spi.Action;
-import org.mvel.ExpressionCompiler;
-import org.mvel.MVEL;
-import org.mvel.ParserContext;
-
-/**
- * Runtime counterpart of an action node.
- * 
- * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
- */
-public class ActionNodeInstanceImpl extends RuleFlowNodeInstanceImpl {
-    private Action action;
-
-    protected ActionNode getActionNode() {
-        return (ActionNode) getNode();
-    }
-
-    public void internalTrigger(final RuleFlowNodeInstance from) {
-		Action action = (Action) getActionNode().getAction();
-		
-		try {
-	        action.execute( getProcessInstance().getWorkingMemory() );		    
-		} catch (Exception e) {
-		    throw  new RuntimeException("unable to execute Action", e);
-		}
-		
-//		if (action instanceof DroolsConsequenceAction) {
-//			String actionString = ((DroolsConsequenceAction) action).getConsequence();
-//    		ExpressionCompiler compiler = new ExpressionCompiler(actionString);
-//    		ParserContext parserContext = new ParserContext();
-//    		// imports
-//    		List imports = getProcessInstance().getRuleFlowProcess().getImports();
-//    		Set importSet = new HashSet();
-//    		if (imports != null) {
-//        		importSet.addAll(imports);
-//    			for (Iterator iterator = imports.iterator(); iterator.hasNext(); ) {
-//    				String importClassName = (String) iterator.next();
-//    				if ( importClassName.endsWith( ".*" ) ) {
-//    					importClassName = importClassName.substring(0, importClassName.indexOf(".*"));
-//    		            parserContext.addPackageImport(importClassName);
-//    		        } else {
-//	    				try {
-//	    					parserContext.addImport(Class.forName(importClassName));
-//	    				} catch (ClassNotFoundException e) {
-//	    					// class not found, do nothing
-//	    				}
-//    		        }
-//    			}
-//    		}
-//    		TypeResolver typeResolver = new ClassTypeResolver(importSet, Thread.currentThread().getContextClassLoader());
-//    		// compile expression
-//    		Serializable expression = compiler.compile(parserContext);
-//    		// globals
-//    		Map globalDefs = getProcessInstance().getRuleFlowProcess().getGlobals();
-//    		Map globals = new HashMap();
-//    		if (globalDefs != null) {
-//    			for (Iterator iterator = globalDefs.entrySet().iterator(); iterator.hasNext(); ) {
-//    				Map.Entry entry = (Map.Entry) iterator.next();
-//    				try {
-//    					globals.put(entry.getKey(), typeResolver.resolveType((String) entry.getValue()));
-//    				} catch (ClassNotFoundException exc) {
-//    					throw new IllegalArgumentException("Could not find type " + entry.getValue() + " of global " + entry.getKey());
-//    				}
-//    			}
-//    		}
-//    		// execute
-//    		DroolsMVELFactory factory = new DroolsMVELFactory(Collections.EMPTY_MAP, null, globals);
-//    		factory.setContext(null, null, null, getProcessInstance().getWorkingMemory(), null);
-//    		MVEL.executeExpression(expression, null, factory);
-//		} else {
-//			throw new RuntimeException("Unknown action: " + action);
-//		}
-    	triggerCompleted();
-    }
-
-    public void triggerCompleted() {
-        getProcessInstance().getNodeInstance( getActionNode().getTo().getTo() ).trigger( this );
-        getProcessInstance().removeNodeInstance(this);
-    }
-
-}
\ No newline at end of file

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/EndNodeInstanceImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/EndNodeInstanceImpl.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/EndNodeInstanceImpl.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,33 +0,0 @@
-package org.drools.ruleflow.instance.impl;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import org.drools.ruleflow.common.instance.ProcessInstance;
-import org.drools.ruleflow.instance.RuleFlowNodeInstance;
-
-/**
- * Runtime counterpart of an end node.
- * 
- * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
- */
-public class EndNodeInstanceImpl extends RuleFlowNodeInstanceImpl {
-
-    public void internalTrigger(final RuleFlowNodeInstance from) {
-        getProcessInstance().setState( ProcessInstance.STATE_COMPLETED );
-    }
-
-}

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/MilestoneNodeInstanceImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/MilestoneNodeInstanceImpl.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/MilestoneNodeInstanceImpl.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,56 +0,0 @@
-package org.drools.ruleflow.instance.impl;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import java.util.Iterator;
-
-import org.drools.common.RuleFlowGroupNode;
-import org.drools.ruleflow.core.MilestoneNode;
-import org.drools.ruleflow.instance.RuleFlowNodeInstance;
-import org.drools.spi.Activation;
-import org.drools.spi.RuleFlowGroup;
-
-/**
- * Runtime counterpart of a milestone node.
- * 
- * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
- */
-public class MilestoneNodeInstanceImpl extends RuleFlowNodeInstanceImpl {
-
-    protected MilestoneNode getMilestoneNode() {
-        return (MilestoneNode) getNode();
-    }
-
-    public void internalTrigger(final RuleFlowNodeInstance from) {
-    	RuleFlowGroup systemRuleFlowGroup = getProcessInstance().getAgenda().getRuleFlowGroup("DROOLS_SYSTEM");
-    	String rule = "RuleFlow-Milestone-" + getProcessInstance().getProcess().getId()
-    		+ "-" + getNode().getId();
-    	for (Iterator activations = systemRuleFlowGroup.iterator(); activations.hasNext(); ) {
-    		Activation activation = ((RuleFlowGroupNode) activations.next()).getActivation();
-    		if (rule.equals(activation.getRule().getName())) {
-    			triggerCompleted();
-        		break;
-    		}
-    	}
-    }
-
-    public void triggerCompleted() {
-        getProcessInstance().getNodeInstance( getMilestoneNode().getTo().getTo() ).trigger( this );
-        getProcessInstance().removeNodeInstance(this);
-    }
-
-}
\ No newline at end of file

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/ProcessNodeInstanceFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/ProcessNodeInstanceFactory.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/ProcessNodeInstanceFactory.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,8 +0,0 @@
-package org.drools.ruleflow.instance.impl;
-
-import org.drools.ruleflow.core.Node;
-import org.drools.ruleflow.instance.RuleFlowNodeInstance;
-
-public interface ProcessNodeInstanceFactory {
-	RuleFlowNodeInstance getNodeInstance(Node node, RuleFlowProcessInstanceImpl processInstance);
-}

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/ProcessNodeInstanceFactoryRegistry.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/ProcessNodeInstanceFactoryRegistry.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/ProcessNodeInstanceFactoryRegistry.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,61 +0,0 @@
-package org.drools.ruleflow.instance.impl;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.drools.ruleflow.core.Node;
-import org.drools.ruleflow.core.WorkItemNode;
-import org.drools.ruleflow.core.impl.ActionNodeImpl;
-import org.drools.ruleflow.core.impl.EndNodeImpl;
-import org.drools.ruleflow.core.impl.JoinImpl;
-import org.drools.ruleflow.core.impl.MilestoneNodeImpl;
-import org.drools.ruleflow.core.impl.RuleSetNodeImpl;
-import org.drools.ruleflow.core.impl.SplitImpl;
-import org.drools.ruleflow.core.impl.StartNodeImpl;
-import org.drools.ruleflow.core.impl.SubFlowNodeImpl;
-import org.drools.ruleflow.instance.impl.factories.CreateNewNodeFactory;
-import org.drools.ruleflow.instance.impl.factories.ReuseNodeFactory;
-import org.drools.ruleflow.instance.impl.factories.RuleSetNodeFactory;
-import org.drools.util.ConfFileUtils;
-import org.mvel.MVEL;
-
-public class ProcessNodeInstanceFactoryRegistry {
-    public static final ProcessNodeInstanceFactoryRegistry          instance = new ProcessNodeInstanceFactoryRegistry();
-
-    private Map<Class< ? extends Node>, ProcessNodeInstanceFactory> registry;
-
-    public ProcessNodeInstanceFactoryRegistry() {
-        this.registry = new HashMap<Class< ? extends Node>, ProcessNodeInstanceFactory>();
-
-        // hard wired nodes:
-        register( RuleSetNodeImpl.class,
-                  new RuleSetNodeFactory() );
-        register( SplitImpl.class,
-                  new ReuseNodeFactory( RuleFlowSplitInstanceImpl.class ) );
-        register( JoinImpl.class,
-                  new ReuseNodeFactory( RuleFlowJoinInstanceImpl.class ) );
-        register( StartNodeImpl.class,
-                  new ReuseNodeFactory( StartNodeInstanceImpl.class ) );
-        register( EndNodeImpl.class,
-                  new CreateNewNodeFactory( EndNodeInstanceImpl.class ) );
-        register( MilestoneNodeImpl.class,
-                  new CreateNewNodeFactory( MilestoneNodeInstanceImpl.class ) );
-        register( SubFlowNodeImpl.class,
-                  new CreateNewNodeFactory( SubFlowNodeInstanceImpl.class ) );
-        register( ActionNodeImpl.class,
-                  new CreateNewNodeFactory( ActionNodeInstanceImpl.class ) );
-        register( WorkItemNode.class,
-                  new CreateNewNodeFactory( TaskNodeInstanceImpl.class ) );
-    }
-
-    public void register(Class< ? extends Node> cls,
-                         ProcessNodeInstanceFactory factory) {
-        this.registry.put( cls,
-                           factory );
-    }
-
-    public ProcessNodeInstanceFactory getRuleFlowNodeFactory(Node node) {
-        return this.registry.get( node.getClass() );
-    }
-}

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/RuleFlowJoinInstanceImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/RuleFlowJoinInstanceImpl.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/RuleFlowJoinInstanceImpl.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,111 +0,0 @@
-package org.drools.ruleflow.instance.impl;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.drools.ruleflow.core.Connection;
-import org.drools.ruleflow.core.Join;
-import org.drools.ruleflow.core.Node;
-import org.drools.ruleflow.instance.RuleFlowNodeInstance;
-
-/**
- * Runtime counterpart of a join node.
- * 
- * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
- */
-public class RuleFlowJoinInstanceImpl extends RuleFlowNodeInstanceImpl {
-
-    private final Map triggers = new HashMap();
-
-    protected Join getJoinNode() {
-        return (Join) getNode();
-    }
-
-    public void internalTrigger(final RuleFlowNodeInstance from) {
-        final Join join = getJoinNode();
-        switch ( join.getType() ) {
-            case Join.TYPE_XOR :
-                triggerCompleted();
-                break;
-            case Join.TYPE_AND :
-                Node node = getProcessInstance().getRuleFlowProcess().getNode( from.getNodeId() );
-                Integer count = (Integer) this.triggers.get( node );
-                if ( count == null ) {
-                    this.triggers.put( node,
-                                       new Integer( 1 ) );
-                } else {
-                    this.triggers.put( node,
-                                       new Integer( count.intValue() + 1 ) );
-                }
-                if (checkAllActivated()) {
-                    decreaseAllTriggers();
-                    triggerCompleted();
-                }
-                break;
-            case Join.TYPE_DISCRIMINATOR :
-                boolean triggerCompleted = triggers.isEmpty();
-                node = getProcessInstance().getRuleFlowProcess().getNode( from.getNodeId() );
-                triggers.put( node, new Integer( 1 ) );
-                if (checkAllActivated()) {
-                    resetAllTriggers();
-                }
-                if (triggerCompleted) {
-                    triggerCompleted();
-                }
-                break;
-            default :
-                throw new IllegalArgumentException( "Illegal join type " + join.getType() );
-        }
-    }
-
-    private boolean checkAllActivated() {
-        // check whether all parent nodes have been triggered 
-        for ( final Iterator it = getJoinNode().getIncomingConnections().iterator(); it.hasNext(); ) {
-            final Connection connection = (Connection) it.next();
-            if ( this.triggers.get( connection.getFrom() ) == null ) {
-                return false;
-            }
-        }
-        return true;
-    }
-    
-    private void decreaseAllTriggers() {
-        // decrease trigger count for all incoming connections
-        for ( final Iterator it = getJoinNode().getIncomingConnections().iterator(); it.hasNext(); ) {
-            final Connection connection = (Connection) it.next();
-            final Integer count = (Integer) this.triggers.get( connection.getFrom() );
-            if ( count.intValue() == 1 ) {
-                this.triggers.remove( connection.getFrom() );
-            } else {
-                this.triggers.put( connection.getFrom(),
-                                   new Integer( count.intValue() - 1 ) );
-            }
-        }
-    }
-
-    private void resetAllTriggers() {
-        triggers.clear();
-    }
-
-    public void triggerCompleted() {
-        getProcessInstance().getNodeInstance( getJoinNode().getTo().getTo() ).trigger( this );
-    }
-    
-}

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/RuleFlowNodeInstanceImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/RuleFlowNodeInstanceImpl.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/RuleFlowNodeInstanceImpl.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,78 +0,0 @@
-package org.drools.ruleflow.instance.impl;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import org.drools.common.EventSupport;
-import org.drools.common.InternalWorkingMemory;
-import org.drools.ruleflow.core.Node;
-import org.drools.ruleflow.instance.RuleFlowNodeInstance;
-import org.drools.ruleflow.instance.RuleFlowProcessInstance;
-
-/**
- * Default implementation of a RuleFlow node instance.
- * 
- * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
- */
-public abstract class RuleFlowNodeInstanceImpl
-    implements
-    RuleFlowNodeInstance {
-
-    private long                     id;
-    private long                     nodeId;
-    private RuleFlowProcessInstance processInstance;
-
-    public void setId(final long id) {
-        this.id = id;
-    }
-
-    public long getId() {
-        return this.id;
-    }
-
-    public void setNodeId(final long nodeId) {
-        this.nodeId = nodeId;
-    }
-
-    public long getNodeId() {
-        return this.nodeId;
-    }
-
-    public void setProcessInstance(final RuleFlowProcessInstance processInstance) {
-        this.processInstance = processInstance;
-    }
-
-    public RuleFlowProcessInstance getProcessInstance() {
-        return this.processInstance;
-    }
-
-    public Node getNode() {
-        return this.processInstance.getRuleFlowProcess().getNode( this.nodeId );
-    }
-    
-    public void cancel() {
-    	getProcessInstance().removeNodeInstance(this);
-    }
-    
-    public final void trigger(RuleFlowNodeInstance from) {
-        ((EventSupport) getProcessInstance().getWorkingMemory()).getRuleFlowEventSupport().fireBeforeRuleFlowNodeTriggered(this, (InternalWorkingMemory) getProcessInstance().getWorkingMemory());
-        internalTrigger(from);
-        ((EventSupport) getProcessInstance().getWorkingMemory()).getRuleFlowEventSupport().fireAfterRuleFlowNodeTriggered(this, (InternalWorkingMemory) getProcessInstance().getWorkingMemory());
-    }
-    
-    public abstract void internalTrigger(RuleFlowNodeInstance from);
-
-}

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/RuleFlowProcessInstanceImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/RuleFlowProcessInstanceImpl.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/RuleFlowProcessInstanceImpl.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,317 +0,0 @@
-package org.drools.ruleflow.instance.impl;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.drools.Agenda;
-import org.drools.WorkingMemory;
-import org.drools.common.EventSupport;
-import org.drools.common.InternalRuleBase;
-import org.drools.common.InternalWorkingMemory;
-import org.drools.event.ActivationCancelledEvent;
-import org.drools.event.ActivationCreatedEvent;
-import org.drools.event.AfterActivationFiredEvent;
-import org.drools.event.AgendaEventListener;
-import org.drools.event.AgendaGroupPoppedEvent;
-import org.drools.event.AgendaGroupPushedEvent;
-import org.drools.event.BeforeActivationFiredEvent;
-import org.drools.event.RuleFlowCompletedEvent;
-import org.drools.event.RuleFlowEventListener;
-import org.drools.event.RuleFlowGroupActivatedEvent;
-import org.drools.event.RuleFlowGroupDeactivatedEvent;
-import org.drools.event.RuleFlowNodeTriggeredEvent;
-import org.drools.event.RuleFlowStartedEvent;
-import org.drools.ruleflow.common.instance.WorkItem;
-import org.drools.ruleflow.common.instance.impl.ProcessInstanceImpl;
-import org.drools.ruleflow.core.Node;
-import org.drools.ruleflow.core.RuleFlowProcess;
-import org.drools.ruleflow.core.WorkItemNode;
-import org.drools.ruleflow.core.impl.ActionNodeImpl;
-import org.drools.ruleflow.core.impl.EndNodeImpl;
-import org.drools.ruleflow.core.impl.JoinImpl;
-import org.drools.ruleflow.core.impl.MilestoneNodeImpl;
-import org.drools.ruleflow.core.impl.RuleSetNodeImpl;
-import org.drools.ruleflow.core.impl.SplitImpl;
-import org.drools.ruleflow.core.impl.StartNodeImpl;
-import org.drools.ruleflow.core.impl.SubFlowNodeImpl;
-import org.drools.ruleflow.instance.RuleFlowNodeInstance;
-import org.drools.ruleflow.instance.RuleFlowProcessInstance;
-import org.drools.ruleflow.instance.impl.factories.CreateNewNodeFactory;
-import org.drools.ruleflow.instance.impl.factories.ReuseNodeFactory;
-import org.drools.ruleflow.instance.impl.factories.RuleSetNodeFactory;
-import org.drools.util.ConfFileUtils;
-import org.mvel.MVEL;
-
-/**
- * Default implementation of a RuleFlow process instance.
- * 
- * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
- */
-public class RuleFlowProcessInstanceImpl extends ProcessInstanceImpl
-    implements
-    RuleFlowProcessInstance,
-    AgendaEventListener,
-    RuleFlowEventListener {
-
-    private static final long                  serialVersionUID = 400L;
-
-    private InternalWorkingMemory              workingMemory;
-    private final List                         nodeInstances    = new ArrayList();
-
-    public RuleFlowProcess getRuleFlowProcess() {
-        return (RuleFlowProcess) getProcess();
-    }
-
-    public void addNodeInstance(final RuleFlowNodeInstance nodeInstance) {
-        this.nodeInstances.add( nodeInstance );
-        nodeInstance.setProcessInstance( this );
-    }
-
-    public void removeNodeInstance(final RuleFlowNodeInstance nodeInstance) {
-        this.nodeInstances.remove( nodeInstance );
-    }
-
-    public Collection getNodeInstances() {
-        return Collections.unmodifiableCollection( new ArrayList( this.nodeInstances ) );
-    }
-
-    public RuleFlowNodeInstance getFirstNodeInstance(final long nodeId) {
-        for ( final Iterator iterator = this.nodeInstances.iterator(); iterator.hasNext(); ) {
-            final RuleFlowNodeInstance nodeInstance = (RuleFlowNodeInstance) iterator.next();
-            if ( nodeInstance.getNodeId() == nodeId ) {
-                return nodeInstance;
-            }
-        }
-        return null;
-    }
-
-    public Agenda getAgenda() {
-        if ( this.workingMemory == null ) {
-            return null;
-        }
-        return this.workingMemory.getAgenda();
-    }
-
-    public void setWorkingMemory(final InternalWorkingMemory workingMemory) {
-        if ( this.workingMemory != null ) {
-            throw new IllegalArgumentException( "A working memory can only be set once." );
-        }
-        this.workingMemory = workingMemory;
-        workingMemory.addEventListener( (AgendaEventListener) this );
-        workingMemory.addEventListener( (RuleFlowEventListener) this );
-    }
-
-    public WorkingMemory getWorkingMemory() {
-        return this.workingMemory;
-    }
-    
-    public RuleFlowNodeInstance getNodeInstance(final Node node) {
-        ProcessNodeInstanceFactoryRegistry nodeRegistry = ( (InternalRuleBase) this.workingMemory.getRuleBase() ).getConfiguration().getProcessNodeInstanceFactoryRegistry();
-        
-        ProcessNodeInstanceFactory conf = nodeRegistry.getRuleFlowNodeFactory( node );
-        if ( conf == null ) {
-            throw new IllegalArgumentException( "Illegal node type: " + node.getClass() );
-        }
-
-        RuleFlowNodeInstance nodeInstance = conf.getNodeInstance( node,
-                                                                  this );
-
-        if ( nodeInstance == null ) {
-            throw new IllegalArgumentException( "Illegal node type: " + node.getClass() );
-        }
-        return nodeInstance;
-    }
-
-    public void start() {
-        if ( getState() != ProcessInstanceImpl.STATE_PENDING ) {
-            throw new IllegalArgumentException( "A process instance can only be started once" );
-        }
-        setState( ProcessInstanceImpl.STATE_ACTIVE );
-        getNodeInstance( getRuleFlowProcess().getStart() ).trigger( null );
-    }
-
-    public void setState(final int state) {
-        super.setState( state );
-        if ( state == ProcessInstanceImpl.STATE_COMPLETED ) {
-            ((EventSupport) this.workingMemory).getRuleFlowEventSupport().fireBeforeRuleFlowProcessCompleted( this,
-                                                                                                              this.workingMemory );
-            // deactivate all node instances of this process instance
-            while ( !nodeInstances.isEmpty() ) {
-                RuleFlowNodeInstance nodeInstance = (RuleFlowNodeInstance) nodeInstances.get( 0 );
-                nodeInstance.cancel();
-            }
-            workingMemory.removeEventListener( (AgendaEventListener) this );
-            workingMemory.removeEventListener( (RuleFlowEventListener) this );
-            workingMemory.removeProcessInstance( this );
-            ((EventSupport) this.workingMemory).getRuleFlowEventSupport().fireAfterRuleFlowProcessCompleted( this,
-                                                                                                             this.workingMemory );
-        }
-    }
-
-    public String toString() {
-        final StringBuffer sb = new StringBuffer( "RuleFlowProcessInstance" );
-        sb.append( getId() );
-        sb.append( " [processId=" );
-        sb.append( getProcess().getId() );
-        sb.append( ",state=" );
-        sb.append( getState() );
-        sb.append( "]" );
-        return sb.toString();
-    }
-
-    public void activationCreated(ActivationCreatedEvent event,
-                                  WorkingMemory workingMemory) {
-        // TODO group all milestone related code in milestone instance impl?
-        // check whether this activation is from the DROOLS_SYSTEM agenda group
-        String ruleFlowGroup = event.getActivation().getRule().getRuleFlowGroup();
-        if ( "DROOLS_SYSTEM".equals( ruleFlowGroup ) ) {
-            // new activations of the rule associate with a milestone node
-            // trigger node instances of that milestone node
-            String ruleName = event.getActivation().getRule().getName();
-            for ( Iterator iterator = getNodeInstances().iterator(); iterator.hasNext(); ) {
-                RuleFlowNodeInstance nodeInstance = (RuleFlowNodeInstance) iterator.next();
-                if ( nodeInstance instanceof MilestoneNodeInstanceImpl ) {
-                    String milestoneName = "RuleFlow-Milestone-" + getProcess().getId() + "-" + nodeInstance.getNodeId();
-                    if ( milestoneName.equals( ruleName ) ) {
-                        ((MilestoneNodeInstanceImpl) nodeInstance).triggerCompleted();
-                    }
-                }
-
-            }
-        }
-    }
-
-    public void activationCancelled(ActivationCancelledEvent event,
-                                    WorkingMemory workingMemory) {
-        // Do nothing
-    }
-
-    public void afterActivationFired(AfterActivationFiredEvent event,
-                                     WorkingMemory workingMemory) {
-        // Do nothing
-    }
-
-    public void agendaGroupPopped(AgendaGroupPoppedEvent event,
-                                  WorkingMemory workingMemory) {
-        // Do nothing
-    }
-
-    public void agendaGroupPushed(AgendaGroupPushedEvent event,
-                                  WorkingMemory workingMemory) {
-        // Do nothing
-    }
-
-    public void beforeActivationFired(BeforeActivationFiredEvent event,
-                                      WorkingMemory workingMemory) {
-        // Do nothing
-    }
-
-    public void beforeRuleFlowGroupActivated(RuleFlowGroupActivatedEvent event,
-                                             WorkingMemory workingMemory) {
-        // Do nothing
-    }
-
-    public void afterRuleFlowGroupActivated(RuleFlowGroupActivatedEvent event,
-                                            WorkingMemory workingMemory) {
-        // Do nothing
-    }
-
-    public void beforeRuleFlowGroupDeactivated(RuleFlowGroupDeactivatedEvent event,
-                                               WorkingMemory workingMemory) {
-        // Do nothing
-    }
-
-    public void afterRuleFlowGroupDeactivated(RuleFlowGroupDeactivatedEvent event,
-                                              WorkingMemory workingMemory) {
-        // Do nothing
-    }
-
-    public void beforeRuleFlowStarted(RuleFlowStartedEvent event,
-                                      WorkingMemory workingMemory) {
-        // Do nothing
-    }
-
-    public void afterRuleFlowStarted(RuleFlowStartedEvent event,
-                                     WorkingMemory workingMemory) {
-        // Do nothing
-    }
-
-    public void beforeRuleFlowCompleted(RuleFlowCompletedEvent event,
-                                        WorkingMemory workingMemory) {
-        // Do nothing
-    }
-
-    public void beforeRuleFlowNodeTriggered(RuleFlowNodeTriggeredEvent event,
-                                            WorkingMemory workingMemory) {
-        // Do nothing
-    }
-
-    public void afterRuleFlowNodeTriggered(RuleFlowNodeTriggeredEvent event,
-                                           WorkingMemory workingMemory) {
-        // Do nothing
-    }
-
-    public void afterRuleFlowCompleted(RuleFlowCompletedEvent event,
-                                       WorkingMemory workingMemory) {
-        // TODO group all subflow related code in subflow instance impl?
-        for ( Iterator iterator = getNodeInstances().iterator(); iterator.hasNext(); ) {
-            RuleFlowNodeInstance nodeInstance = (RuleFlowNodeInstance) iterator.next();
-            if ( nodeInstance instanceof SubFlowNodeInstanceImpl ) {
-                SubFlowNodeInstanceImpl subFlowInstance = (SubFlowNodeInstanceImpl) nodeInstance;
-                if ( event.getRuleFlowProcessInstance().getId() == subFlowInstance.getProcessInstanceId() ) {
-                    subFlowInstance.triggerCompleted();
-                }
-            }
-
-        }
-    }
-
-    public void taskCompleted(WorkItem taskInstance) {
-        for ( Iterator iterator = getNodeInstances().iterator(); iterator.hasNext(); ) {
-            RuleFlowNodeInstance nodeInstance = (RuleFlowNodeInstance) iterator.next();
-            if ( nodeInstance instanceof TaskNodeInstanceImpl ) {
-                TaskNodeInstanceImpl taskNodeInstance = (TaskNodeInstanceImpl) nodeInstance;
-                WorkItem nodeTaskInstance = taskNodeInstance.getTaskInstance();
-                if ( nodeTaskInstance != null && nodeTaskInstance.getId() == taskInstance.getId() ) {
-                    taskNodeInstance.triggerCompleted();
-                }
-            }
-        }
-    }
-
-    public void taskAborted(WorkItem taskInstance) {
-        for ( Iterator iterator = getNodeInstances().iterator(); iterator.hasNext(); ) {
-            RuleFlowNodeInstance nodeInstance = (RuleFlowNodeInstance) iterator.next();
-            if ( nodeInstance instanceof TaskNodeInstanceImpl ) {
-                TaskNodeInstanceImpl taskNodeInstance = (TaskNodeInstanceImpl) nodeInstance;
-                WorkItem nodeTaskInstance = taskNodeInstance.getTaskInstance();
-                if ( nodeTaskInstance != null && nodeTaskInstance.getId() == taskInstance.getId() ) {
-                    taskNodeInstance.triggerCompleted();
-                }
-            }
-        }
-    }
-
-}

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/RuleFlowSequenceNodeInstanceImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/RuleFlowSequenceNodeInstanceImpl.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/RuleFlowSequenceNodeInstanceImpl.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,47 +0,0 @@
-package org.drools.ruleflow.instance.impl;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import org.drools.ruleflow.core.RuleSetNode;
-import org.drools.ruleflow.instance.RuleFlowNodeInstance;
-
-/**
- * Runtime counterpart of a ruleset node.
- * 
- * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
- */
-public class RuleFlowSequenceNodeInstanceImpl extends RuleFlowNodeInstanceImpl {
-
-    protected RuleSetNode getRuleSetNode() {
-        return (RuleSetNode) getNode();
-    }
-
-    public void internalTrigger(final RuleFlowNodeInstance from) {
-        getProcessInstance().getAgenda().activateRuleFlowGroup( getRuleSetNode().getRuleFlowGroup() );
-    }
-
-    public void triggerCompleted() {
-        getProcessInstance().getNodeInstance( getRuleSetNode().getTo().getTo() ).trigger( this );
-        getProcessInstance().removeNodeInstance(this);
-    }
-    
-    public void cancel() {
-    	getProcessInstance().getAgenda().deactivateRuleFlowGroup( getRuleSetNode().getRuleFlowGroup() );
-    	super.cancel();
-    }
-
-}
\ No newline at end of file

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/RuleFlowSplitInstanceImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/RuleFlowSplitInstanceImpl.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/RuleFlowSplitInstanceImpl.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,93 +0,0 @@
-package org.drools.ruleflow.instance.impl;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.drools.ruleflow.core.Connection;
-import org.drools.ruleflow.core.Constraint;
-import org.drools.ruleflow.core.Split;
-import org.drools.ruleflow.instance.RuleFlowNodeInstance;
-import org.drools.ruleflow.nodes.split.ConstraintEvaluator;
-
-/**
- * Runtime counterpart of a split node.
- * 
- * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
- */
-public class RuleFlowSplitInstanceImpl extends RuleFlowNodeInstanceImpl {
-
-    protected Split getSplitNode() {
-        return (Split) getNode();
-    }
-
-    public void internalTrigger(final RuleFlowNodeInstance from) {
-        final Split split = getSplitNode();
-        switch ( split.getType() ) {
-            case Split.TYPE_AND :
-                List outgoing = split.getOutgoingConnections();
-                for ( final Iterator iterator = outgoing.iterator(); iterator.hasNext(); ) {
-                    final Connection connection = (Connection) iterator.next();
-                    getProcessInstance().getNodeInstance( connection.getTo() ).trigger( this );
-                }
-                break;
-            case Split.TYPE_XOR :
-                outgoing = split.getOutgoingConnections();
-                int priority = Integer.MAX_VALUE;
-                Connection selected = null;
-                for ( final Iterator iterator = outgoing.iterator(); iterator.hasNext(); ) {
-                    final Connection connection = (Connection) iterator.next();
-                    ConstraintEvaluator constraint = (ConstraintEvaluator) split.getConstraint( connection );
-                    if ( constraint != null && constraint.getPriority() < priority ) {
-                        if ( constraint.evaluate( this,
-                                                  connection,
-                                                  constraint ) ) {
-                            selected = connection;
-                            priority = constraint.getPriority();
-                            break;
-                        }
-                    }
-                }
-                if ( selected == null ) {
-                    throw new IllegalArgumentException( "XOR split could not find at least one valid outgoing connection for split " + getSplitNode().getName() );
-                }
-                getProcessInstance().getNodeInstance( selected.getTo() ).trigger( this );
-                break;
-            case Split.TYPE_OR :
-                outgoing = split.getOutgoingConnections();
-                boolean found = false;
-                for ( final Iterator iterator = outgoing.iterator(); iterator.hasNext(); ) {
-                    final Connection connection = (Connection) iterator.next();
-                    ConstraintEvaluator constraint = (ConstraintEvaluator) split.getConstraint( connection );
-
-                    if ( constraint != null && constraint.evaluate( this,
-                                                                    connection,
-                                                                    constraint ) ) {
-                        getProcessInstance().getNodeInstance( connection.getTo() ).trigger( this );
-                        found = true;
-                    }
-                }
-                if ( !found ) {
-                    throw new IllegalArgumentException( "OR split could not find at least one valid outgoing connection for split " + getSplitNode().getName() );
-                }                
-                break;
-            default :
-                throw new IllegalArgumentException( "Illegal split type " + split.getType() );
-        }
-    }
-}

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/StartNodeInstanceImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/StartNodeInstanceImpl.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/StartNodeInstanceImpl.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,42 +0,0 @@
-package org.drools.ruleflow.instance.impl;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import org.drools.ruleflow.core.StartNode;
-import org.drools.ruleflow.instance.RuleFlowNodeInstance;
-
-/**
- * Runtime counterpart of a start node.
- * 
- * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
- */
-public class StartNodeInstanceImpl extends RuleFlowNodeInstanceImpl {
-
-    public void internalTrigger(final RuleFlowNodeInstance from) {
-        triggerCompleted();
-    }
-
-    public StartNode getStartNode() {
-        return (StartNode) getNode();
-    }
-
-    public void triggerCompleted() {
-        getProcessInstance().getNodeInstance( getStartNode().getTo().getTo() ).trigger( this );
-        getProcessInstance().removeNodeInstance(this);
-    }
-    
-}

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/SubFlowNodeInstanceImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/SubFlowNodeInstanceImpl.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/SubFlowNodeInstanceImpl.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,56 +0,0 @@
-package org.drools.ruleflow.instance.impl;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import org.drools.ruleflow.common.instance.ProcessInstance;
-import org.drools.ruleflow.core.SubFlowNode;
-import org.drools.ruleflow.instance.RuleFlowNodeInstance;
-
-/**
- * Runtime counterpart of a SubFlow node.
- * 
- * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
- */
-public class SubFlowNodeInstanceImpl extends RuleFlowNodeInstanceImpl {
-
-	private long processInstanceId;
-	
-    protected SubFlowNode getSubFlowNode() {
-        return (SubFlowNode) getNode();
-    }
-
-    public void internalTrigger(final RuleFlowNodeInstance from) {
-    	ProcessInstance processInstance = 
-    		getProcessInstance().getWorkingMemory().startProcess(getSubFlowNode().getProcessId());
-    	if (!getSubFlowNode().isWaitForCompletion()
-    	        || processInstance.getState() == ProcessInstance.STATE_COMPLETED) {
-    		triggerCompleted();
-    	} else {
-    		this.processInstanceId = processInstance.getId();
-    	}
-    }
-    
-    public long getProcessInstanceId() {
-    	return processInstanceId;
-    }
-
-    public void triggerCompleted() {
-        getProcessInstance().getNodeInstance( getSubFlowNode().getTo().getTo() ).trigger( this );
-        getProcessInstance().removeNodeInstance(this);
-    }
-
-}
\ No newline at end of file

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/TaskNodeInstanceImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/TaskNodeInstanceImpl.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/TaskNodeInstanceImpl.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,56 +0,0 @@
-package org.drools.ruleflow.instance.impl;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import org.drools.ruleflow.common.core.Work;
-import org.drools.ruleflow.common.instance.WorkItem;
-import org.drools.ruleflow.common.instance.impl.WorkItemImpl;
-import org.drools.ruleflow.core.WorkItemNode;
-import org.drools.ruleflow.instance.RuleFlowNodeInstance;
-
-/**
- * Runtime counterpart of a task node.
- * 
- * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
- */
-public class TaskNodeInstanceImpl extends RuleFlowNodeInstanceImpl {
-
-    private WorkItemImpl taskInstance;
-    
-    protected WorkItemNode getTaskNode() {
-        return (WorkItemNode) getNode();
-    }
-    
-    public WorkItem getTaskInstance() {
-        return taskInstance;
-    }
-
-    public void internalTrigger(final RuleFlowNodeInstance from) {
-		Work task = getTaskNode().getWork();
-		taskInstance = new WorkItemImpl();
-		taskInstance.setName(task.getName());
-		taskInstance.setProcessInstanceId(getProcessInstance().getId());
-		taskInstance.setParameters(task.getParameters());
-		getProcessInstance().getWorkingMemory().getWorkItemManager().executeWorkItem(taskInstance);
-    }
-
-    public void triggerCompleted() {
-        getProcessInstance().getNodeInstance( getTaskNode().getTo().getTo() ).trigger( this );
-        getProcessInstance().removeNodeInstance(this);
-    }
-
-}
\ No newline at end of file

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/factories/CreateNewNodeFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/factories/CreateNewNodeFactory.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/factories/CreateNewNodeFactory.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,34 +0,0 @@
-package org.drools.ruleflow.instance.impl.factories;
-
-import org.drools.ruleflow.core.Node;
-import org.drools.ruleflow.core.RuleSetNode;
-import org.drools.ruleflow.instance.RuleFlowNodeInstance;
-import org.drools.ruleflow.instance.impl.ActionNodeInstanceImpl;
-import org.drools.ruleflow.instance.impl.MilestoneNodeInstanceImpl;
-import org.drools.ruleflow.instance.impl.ProcessNodeInstanceFactory;
-import org.drools.ruleflow.instance.impl.RuleFlowJoinInstanceImpl;
-import org.drools.ruleflow.instance.impl.RuleFlowProcessInstanceImpl;
-import org.drools.ruleflow.instance.impl.RuleFlowSplitInstanceImpl;
-import org.drools.ruleflow.instance.impl.StartNodeInstanceImpl;
-import org.drools.ruleflow.instance.impl.SubFlowNodeInstanceImpl;
-
-public class CreateNewNodeFactory implements ProcessNodeInstanceFactory {
-    public final Class<? extends RuleFlowNodeInstance> cls;
-    
-    public CreateNewNodeFactory(Class<? extends RuleFlowNodeInstance> cls){
-        this.cls = cls;
-    }
-    
-	public RuleFlowNodeInstance getNodeInstance(Node node, RuleFlowProcessInstanceImpl processInstance ) {    	  	
-        RuleFlowNodeInstance result;
-        try {
-            result = this.cls.newInstance();
-        } catch ( Exception e ) {
-            throw new RuntimeException("Unable  to instance RuleFlow Node: '" + this.cls.getName() );
-        }
-        result.setNodeId( node.getId() );
-        processInstance.addNodeInstance( result );
-        return result;
-	}
-
-}

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/factories/ReuseNodeFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/factories/ReuseNodeFactory.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/factories/ReuseNodeFactory.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,32 +0,0 @@
-package org.drools.ruleflow.instance.impl.factories;
-
-import org.drools.ruleflow.core.Node;
-import org.drools.ruleflow.instance.RuleFlowNodeInstance;
-import org.drools.ruleflow.instance.impl.ProcessNodeInstanceFactory;
-import org.drools.ruleflow.instance.impl.RuleFlowProcessInstanceImpl;
-
-public class ReuseNodeFactory implements ProcessNodeInstanceFactory {
-    public final Class<? extends RuleFlowNodeInstance> cls;
-    
-    public ReuseNodeFactory(Class<? extends RuleFlowNodeInstance> cls){
-        this.cls = cls;
-//        if ( RuleFlowNodeInstance.class.isAssignableFrom( this.cls ) ) {
-//            throw new IllegalArgumentException("Node must be of the type RuleFlowNodeInstance." );
-//        }
-    }
-
-	public RuleFlowNodeInstance getNodeInstance(Node node, RuleFlowProcessInstanceImpl processInstance ) {    	
-        RuleFlowNodeInstance result = processInstance.getFirstNodeInstance( node.getId() );
-        if ( result == null ) {
-            try {
-                result = ( RuleFlowNodeInstance ) cls.newInstance();
-            } catch ( Exception e ) {
-                throw new RuntimeException("Unable  to instance RuleFlow Node: '" + this.cls.getName() );
-            }
-            result.setNodeId( node.getId() );
-            processInstance.addNodeInstance( result );
-        }
-        return result;    	
-	}
-
-}

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/factories/RuleSetNodeFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/factories/RuleSetNodeFactory.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/factories/RuleSetNodeFactory.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,18 +0,0 @@
-package org.drools.ruleflow.instance.impl.factories;
-
-import org.drools.ruleflow.core.Node;
-import org.drools.ruleflow.core.RuleSetNode;
-import org.drools.ruleflow.instance.RuleFlowNodeInstance;
-import org.drools.ruleflow.instance.impl.ProcessNodeInstanceFactory;
-import org.drools.ruleflow.instance.impl.RuleFlowProcessInstanceImpl;
-
-public class RuleSetNodeFactory implements ProcessNodeInstanceFactory {
-
-	public RuleFlowNodeInstance getNodeInstance(Node node, RuleFlowProcessInstanceImpl processInstance ) {
-        final RuleFlowNodeInstance result = (RuleFlowNodeInstance) processInstance.getAgenda().getRuleFlowGroup( ((RuleSetNode) node).getRuleFlowGroup() );
-    	result.setNodeId( node.getId() );
-    	processInstance.addNodeInstance( result );
-    	return result;
-	}
-
-}

Copied: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/Connection.java (from rev 17570, labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/Connection.java)
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/Connection.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/Connection.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,52 @@
+package org.drools.workflow.core;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Represents a connection between two nodes in a workflow. 
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public interface Connection {
+
+    /**
+     * Returns the from node of the connection.
+     * @return the from node of the connection.
+     */
+    Node getFrom();
+
+    /**
+     * Returns the to node of the connection
+     * @return the to node of the connection
+     */
+    Node getTo();
+
+    /**
+     * Returns the type of the connection at the from node
+     * 
+     * @return the type of the connection at the from node
+     */
+    String getFromType();
+
+    /**
+     * Returns the type of the connection at the to node
+     * 
+     * @return the type of the connection at the to node
+     */
+    String getToType();
+
+}

Copied: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/Constraint.java (from rev 17570, labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/Constraint.java)
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/Constraint.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/Constraint.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,97 @@
+package org.drools.workflow.core;
+
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Represents a constraint in a RuleFlow.
+ * Can be used to specify conditions in (X)OR-splits. 
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public interface Constraint {
+    /**
+     * Typically this method returns the constraint as a String
+     * @return the constraint
+     */
+    String getConstraint();
+
+    /**
+     * Method for setting the constraint
+     * @param constraint 	the constraint
+     */
+    void setConstraint(String constraint);
+
+    /**
+     * Returns the name of the constraint
+     * @return the name of the constraint
+     */
+    String getName();
+
+    /**
+     * Sets the name of the constraint
+     * @param name	the name of the constraint
+     */
+    void setName(String name);
+
+    /**
+     * Returns the priority of the constraint
+     * 
+     * @return the priority of the constraint
+     */
+    int getPriority();
+
+    /**
+     * Method for setting the priority of the constraint
+     * 
+     * @param priority	the priority of the constraint
+     */
+    void setPriority(int priority);
+
+    /**
+     * Returns the type of the constraint,
+     * e.g. "code" or "rule"
+     * 
+     * @return the type of the constraint
+     */
+    String getType();
+
+    /**
+     * Method for setting the type of the constraint,
+     * e.g. "code" or "rule"
+     * 
+     * @param type  the type of the constraint
+     */
+    void setType(String type);
+
+    /**
+     * Returns the dialect of the constraint,
+     * e.g. "mvel" or "java"
+     * 
+     * @return the dialect of the constraint
+     */
+    String getDialect();
+
+    /**
+     * Method for setting the dialect of the constraint,
+     * e.g. "mvel" or "java"
+     * 
+     * @param type  the dialect of the constraint
+     */
+    void setDialect(String dialect);
+
+}

Copied: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/Node.java (from rev 17570, labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/Node.java)
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/Node.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/Node.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,89 @@
+package org.drools.workflow.core;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Represents a node in a RuleFlow. 
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public interface Node extends Serializable {
+
+    static final String CONNECTION_DEFAULT_TYPE = "DROOLS_DEFAULT";
+    
+    /**
+     * Returns the id of the node
+     * 
+     * @return the id of the node
+     */
+    long getId();
+
+    /**
+     * Method for setting the id of the node
+     * 
+     * @param id	the id of the node
+     */
+    void setId(long id);
+
+    /**
+     * Returns the name of the node
+     * 
+     * @return the name of the node
+     */
+    String getName();
+
+    /**
+     * Method for setting the name of the node
+     * 
+     * @param name 	the name of the node
+     */
+    void setName(String name);
+
+    /**
+     * Returns the incoming connections
+     * 
+     * @return the incoming connections 
+     */
+    Map<String, List<Connection>> getIncomingConnections();
+
+    /**
+     * Returns the outgoing connections
+     * 
+     * @return the outgoing connections 
+     */
+    Map<String, List<Connection>> getOutgoingConnections();
+
+    void addIncomingConnection(String type, Connection connection);
+    
+    void addOutgoingConnection(String type, Connection connection);
+    
+    void removeIncomingConnection(String type, Connection connection);
+    
+    void removeOutgoingConnection(String type, Connection connection);
+    
+    List<Connection> getIncomingConnections(String type);
+    
+    List<Connection> getOutgoingConnections(String type);
+    
+    NodeContainer getNodeContainer();
+    
+    void setNodeContainer(NodeContainer nodeContainer);
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/NodeContainer.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/NodeContainer.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/NodeContainer.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,44 @@
+package org.drools.workflow.core;
+
+/**
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public interface NodeContainer {
+
+    /**
+     * Returns the nodes of this node container.
+     * 
+     * @return the nodes of this node container
+     */
+    Node[] getNodes();
+
+    /**
+     * Returns the node with the given id
+     * 
+     * @param id
+     *            the node id
+     * @return the node with the given id
+     * @throws IllegalArgumentException
+     *             if an unknown id is passed
+     */
+    Node getNode(long id);
+
+    /**
+     * Method for adding a node to this node container. 
+     * Note that the node will get an id unique for this node container.
+     * 
+     * @param node  the node to be added
+     * @throws IllegalArgumentException if <code>node</code> is null 
+     */
+    void addNode(Node node);
+
+    /**
+     * Method for removing a node from this node container
+     * 
+     * @param node  the node to be removed
+     * @throws IllegalArgumentException if <code>node</code> is null or unknown
+     */
+    void removeNode(Node node);
+    
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/WorkflowProcess.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/WorkflowProcess.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/WorkflowProcess.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,68 @@
+package org.drools.workflow.core;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.List;
+import java.util.Map;
+
+import org.drools.process.core.Process;
+
+/**
+ * Represents a RuleFlow process. 
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public interface WorkflowProcess extends Process, NodeContainer {
+
+    /**
+     * Returns the imports of this RuleFlow process.
+     * They are defined as a List of fully qualified class names.
+     * 
+     * @return	the imports of this RuleFlow process
+     */
+    List<String> getImports();
+    
+    /**
+     * Sets the imports of this RuleFlow process
+     * 
+     * @param imports	the imports as a List of fully qualified class names
+     */
+    void setImports(List<String> imports);
+
+    /**
+     * Returns the globals of this RuleFlow process.
+     * They are defined as a Map with the name as key and the type as value.
+     * 
+     * @return	the imports of this RuleFlow process
+     */
+    Map<String, String> getGlobals();
+    
+    /**
+     * Sets the imports of this RuleFlow process
+     * 
+     * @param imports	the globals as a Map with the name as key and the type as value
+     */
+    void setGlobals(Map<String, String> globals);
+
+    /**
+     * Returns the names of the globals used in this RuleFlow process
+     * 
+     * @return	the names of the globals of this RuleFlow process
+     */
+    String[] getGlobalNames();
+    
+}

Copied: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/impl/ConnectionImpl.java (from rev 17570, labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/ConnectionImpl.java)
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/impl/ConnectionImpl.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/impl/ConnectionImpl.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,114 @@
+package org.drools.workflow.core.impl;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.Serializable;
+
+import org.drools.workflow.core.Connection;
+import org.drools.workflow.core.Node;
+
+/**
+ * Default implementation of a connection.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ConnectionImpl implements Connection, Serializable {
+
+    private static final long serialVersionUID = 400L;
+
+    private Node from;
+    private Node to;
+    private String fromType;
+    private String toType;
+    
+    ConnectionImpl() {
+    }
+
+    /**
+     * Creates a new connection, given a from node, a to node 
+     * and a type.
+     * 
+     * @param from      The from node
+     * @param to        The to node
+     * @param type      The connection type
+     */
+    public ConnectionImpl(final Node from, final String fromType,
+                          final Node to, final String toType) {
+        if (from == null) {
+            throw new IllegalArgumentException("From node is null!");
+        }
+        if (fromType == null) {
+            throw new IllegalArgumentException("From type is null!");
+        }
+        if (to == null) {
+            throw new IllegalArgumentException("To node is null!");
+        }
+        if (toType == null) {
+            throw new IllegalArgumentException("To type is null!");
+        }
+        if (from.equals(to)) {
+            throw new IllegalArgumentException(
+                "To and from nodes are the same!");
+        }
+        this.from = from;
+        this.fromType = fromType;
+        this.to = to;
+        this.toType = toType;
+        this.from.addOutgoingConnection(fromType, this);
+        this.to.addIncomingConnection(toType, this);
+    }
+
+    public synchronized void terminate() {
+        this.from.removeOutgoingConnection(fromType, this);
+        this.to.removeIncomingConnection(toType, this);
+        this.from = null;
+        this.fromType = null;
+        this.to = null;
+        this.toType = null;
+    }
+
+    public Node getFrom() {
+        return this.from;
+    }
+
+    public Node getTo() {
+        return this.to;
+    }
+
+    public String getFromType() {
+        return this.fromType;
+    }
+
+    public String getToType() {
+        return this.toType;
+    }
+
+    public String toString() {
+        final StringBuffer sb = new StringBuffer("Connection ");
+        sb.append(getFrom());
+        sb.append(" [type=");
+        sb.append(getFromType());
+        sb.append("]");
+        sb.append(" - ");
+        sb.append(getTo());
+        sb.append(" [type=");
+        sb.append(getToType());
+        sb.append("]");
+        return sb.toString();
+    }
+
+}

Copied: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/impl/ConstraintImpl.java (from rev 17570, labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/ConstraintImpl.java)
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/impl/ConstraintImpl.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/impl/ConstraintImpl.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,82 @@
+package org.drools.workflow.core.impl;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.Serializable;
+
+import org.drools.workflow.core.Constraint;
+
+/**
+ * Default implementation of a constraint.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ConstraintImpl implements Constraint, Serializable {
+
+    private static final long  serialVersionUID = 400L;
+
+    private String             name;
+    private String             constraint;
+    private int                priority;
+    private String             dialect;
+    private String             type;
+
+    public String getConstraint() {
+        return this.constraint;
+    }
+
+    public void setConstraint(final String constraint) {
+        this.constraint = constraint;
+    }
+
+    public String getName() {
+        return this.name;
+    }
+
+    public void setName(final String name) {
+        this.name = name;
+    }
+
+    public String toString() {
+        return this.name;
+    }
+
+    public int getPriority() {
+        return this.priority;
+    }
+
+    public void setPriority(final int priority) {
+        this.priority = priority;
+    }
+
+    public String getDialect() {
+        return dialect;
+    }
+
+    public void setDialect(String dialect) {
+        this.dialect = dialect;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+}

Copied: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/impl/DroolsConsequenceAction.java (from rev 17570, labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/DroolsConsequenceAction.java)
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/impl/DroolsConsequenceAction.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/impl/DroolsConsequenceAction.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,36 @@
+package org.drools.workflow.core.impl;
+
+import java.io.Serializable;
+
+public class DroolsConsequenceAction implements Serializable {
+	
+    private static final long serialVersionUID = 400L;
+    
+    private String dialect = "mvel";
+    private String consequence;
+	
+	public DroolsConsequenceAction(String dialect, String consequence) {
+	    this.dialect = dialect;
+		this.consequence = consequence;
+	}
+	
+	public void setConsequence(String consequence) {
+		this.consequence = consequence;
+	}
+	
+	public String getConsequence() {
+		return consequence;
+	}
+	
+	public void setDialect(String dialect) {
+	    this.dialect = dialect;
+	}
+	
+	public String getDialect() {
+	    return dialect;
+	}
+
+	public String toString() {
+		return consequence;
+	}
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/impl/NodeContainerImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/impl/NodeContainerImpl.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/impl/NodeContainerImpl.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,67 @@
+package org.drools.workflow.core.impl;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.drools.workflow.core.Node;
+import org.drools.workflow.core.NodeContainer;
+
+/**
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class NodeContainerImpl implements Serializable, NodeContainer {
+
+    private static final long serialVersionUID = 400L;
+
+    private Map<Long, Node> nodes;
+
+    private long lastNodeId;
+
+    public NodeContainerImpl() {
+        this.nodes = new HashMap<Long, Node>();
+    }
+
+    public void addNode(final Node node) {
+        validateAddNode(node);
+        if (!this.nodes.containsValue(node)) {
+            node.setId(++this.lastNodeId);
+            this.nodes.put(new Long(node.getId()), node);
+        }
+    }
+
+    protected void validateAddNode(Node node) {
+        if (node == null) {
+            throw new IllegalArgumentException("Node is null!");
+        }
+    }
+
+    public Node[] getNodes() {
+        return (Node[]) this.nodes.values()
+                .toArray(new Node[this.nodes.size()]);
+    }
+
+    public Node getNode(final long id) {
+        final Long idLong = new Long(id);
+        if (!this.nodes.containsKey(idLong)) {
+            throw new IllegalArgumentException("Unknown node id: " + id);
+        }
+        return (Node) this.nodes.get(idLong);
+    }
+
+    public void removeNode(final Node node) {
+        validateRemoveNode(node);
+        this.nodes.remove(new Long(node.getId()));
+    }
+
+    protected void validateRemoveNode(Node node) {
+        if (node == null) {
+            throw new IllegalArgumentException("Node is null");
+        }
+        if (this.nodes.get(node.getId()) == null) {
+            throw new IllegalArgumentException("Unknown node: " + node);
+        }
+    }
+
+}

Copied: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/impl/NodeImpl.java (from rev 17570, labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/NodeImpl.java)
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/impl/NodeImpl.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/impl/NodeImpl.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,176 @@
+package org.drools.workflow.core.impl;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.drools.workflow.core.Connection;
+import org.drools.workflow.core.Node;
+import org.drools.workflow.core.NodeContainer;
+
+/**
+ * Default implementation of a node.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public abstract class NodeImpl implements Node, Serializable {
+
+    protected static final NodeImpl[] EMPTY_NODE_ARRAY = new NodeImpl[0];
+
+    private long id;
+
+    private String name;
+    private Map<String, List<Connection>> incomingConnections;
+    private Map<String, List<Connection>> outgoingConnections;
+    private NodeContainer nodeContainer;
+
+    public NodeImpl() {
+        this.id = -1;
+        this.incomingConnections = new HashMap<String, List<Connection>>();
+        this.outgoingConnections = new HashMap<String, List<Connection>>();
+    }
+
+    public long getId() {
+        return this.id;
+    }
+
+    public void setId(final long id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return this.name;
+    }
+
+    public void setName(final String name) {
+        this.name = name;
+    }
+
+    public Map<String, List<Connection>> getIncomingConnections() {
+        // TODO: users can still modify the lists inside this Map
+        return Collections.unmodifiableMap(this.incomingConnections);
+    }
+
+    public Map<String, List<Connection>> getOutgoingConnections() {
+        // TODO: users can still modify the lists inside this Map
+        return Collections.unmodifiableMap(this.outgoingConnections);
+    }
+
+    public void addIncomingConnection(final String type, final Connection connection) {
+        validateAddIncomingConnection(type, connection);
+        List<Connection> connections = this.incomingConnections.get(type);
+        if (connections == null) {
+            connections = new ArrayList<Connection>();
+            this.incomingConnections.put(type, connections);
+        }
+        connections.add(connection);
+    }
+
+    public void validateAddIncomingConnection(final String type, final Connection connection) {
+        if (type == null) {
+            throw new IllegalArgumentException("Connection type cannot be null");
+        }
+        if (connection == null) {
+            throw new IllegalArgumentException("Connection cannot be null");
+        }
+    }
+    
+    public List<Connection> getIncomingConnections(String type) {
+        List<Connection> result = incomingConnections.get(type);
+        if (result == null) {
+            return new ArrayList<Connection>();
+        }
+        return result;
+    }
+
+    public void addOutgoingConnection(final String type, final Connection connection) {
+        validateAddOutgoingConnection(type, connection);
+        List<Connection> connections = this.outgoingConnections.get(type);
+        if (connections == null) {
+            connections = new ArrayList<Connection>();
+            this.outgoingConnections.put(type, connections);
+        }
+        connections.add(connection);
+    }
+
+    public void validateAddOutgoingConnection(final String type, final Connection connection) {
+        if (type == null) {
+            throw new IllegalArgumentException("Connection type cannot be null");
+        }
+        if (connection == null) {
+            throw new IllegalArgumentException("Connection cannot be null");
+        }
+    }
+
+    public List<Connection> getOutgoingConnections(String type) {
+        List<Connection> result = outgoingConnections.get(type);
+        if (result == null) {
+            return new ArrayList<Connection>();
+        }
+        return result;
+    }
+
+    public void removeIncomingConnection(final String type, final Connection connection) {
+        validateRemoveIncomingConnection(type, connection);
+        this.incomingConnections.get(type).remove(connection);
+    }
+
+    public void validateRemoveIncomingConnection(final String type, final Connection connection) {
+        if (type == null) {
+            throw new IllegalArgumentException("Connection type cannot be null");
+        }
+        if (connection == null) {
+            throw new IllegalArgumentException("Connection is null");
+        }
+        if (!incomingConnections.get(type).contains(connection)) {
+            throw new IllegalArgumentException("Given connection <"
+                    + connection + "> is not part of the incoming connections");
+        }
+    }
+
+    public void removeOutgoingConnection(final String type, final Connection connection) {
+        validateRemoveOutgoingConnection(type, connection);
+        this.outgoingConnections.get(type).remove(connection);
+    }
+
+    public void validateRemoveOutgoingConnection(final String type, final Connection connection) {
+        if (type == null) {
+            throw new IllegalArgumentException("Connection type cannot be null");
+        }
+        if (connection == null) {
+            throw new IllegalArgumentException("Connection is null");
+        }
+        if (!this.outgoingConnections.get(type).contains(connection)) {
+            throw new IllegalArgumentException("Given connection <"
+                    + connection + "> is not part of the outgoing connections");
+        }
+    }
+    
+    public NodeContainer getNodeContainer() {
+        return nodeContainer;
+    }
+    
+    public void setNodeContainer(NodeContainer nodeContainer) {
+        this.nodeContainer = nodeContainer;
+    }
+
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/impl/WorkflowProcessImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/impl/WorkflowProcessImpl.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/impl/WorkflowProcessImpl.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,94 @@
+package org.drools.workflow.core.impl;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.drools.process.core.impl.ProcessImpl;
+import org.drools.workflow.core.Node;
+import org.drools.workflow.core.NodeContainer;
+import org.drools.workflow.core.WorkflowProcess;
+
+/**
+ * Default implementation of a RuleFlow process.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class WorkflowProcessImpl extends ProcessImpl implements WorkflowProcess {
+
+    private static final long   serialVersionUID = 400L;
+
+    private NodeContainer nodeContainer;
+    private List<String> imports;
+    private Map<String, String> globals;
+    
+    public WorkflowProcessImpl() {
+        nodeContainer = createNodeContainer();
+    }
+    
+    protected NodeContainer createNodeContainer() {
+        return new NodeContainerImpl();
+    }
+    
+    public Node[] getNodes() {
+        return nodeContainer.getNodes();
+    }
+
+    public Node getNode(final long id) {
+        return nodeContainer.getNode(id);
+    }
+
+    public void removeNode(final Node node) {
+        nodeContainer.removeNode(node);
+        node.setNodeContainer(null);
+    }
+
+    public void addNode(final Node node) {
+        nodeContainer.addNode(node);
+        node.setNodeContainer(this);
+    }
+
+    public List<String> getImports() {
+        return imports;
+    }
+
+    public void setImports(List<String> imports) {
+        this.imports = imports;
+    }
+    
+    public Map<String, String> getGlobals() {
+        return globals;
+    }
+
+    public void setGlobals(Map<String, String> globals) {
+        this.globals = globals;
+    }
+
+    public String[] getGlobalNames() {
+        final List<String> result = new ArrayList<String>();
+        if (this.globals != null) {
+            for ( Iterator<String> iterator = this.globals.keySet().iterator(); iterator.hasNext(); ) {
+                result.add(iterator.next());
+            }
+        }
+        return result.toArray(new String[result.size()]);
+    }
+    
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/node/ActionNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/node/ActionNode.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/node/ActionNode.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,39 @@
+package org.drools.workflow.core.node;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+/**
+ * Default implementation of an action node.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ActionNode extends SequenceNode {
+
+	private static final long serialVersionUID = 400L;
+	
+	private Object action;
+
+	public Object getAction() {
+		return action;
+	}
+
+	public void setAction(Object action) {
+		this.action = action;
+	}
+
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/node/CompositeNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/node/CompositeNode.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/node/CompositeNode.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,230 @@
+package org.drools.workflow.core.node;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.drools.workflow.core.Connection;
+import org.drools.workflow.core.Node;
+import org.drools.workflow.core.NodeContainer;
+import org.drools.workflow.core.impl.ConnectionImpl;
+import org.drools.workflow.core.impl.NodeContainerImpl;
+import org.drools.workflow.core.impl.NodeImpl;
+
+/**
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class CompositeNode extends NodeImpl implements NodeContainer {
+
+    private static final long serialVersionUID = 400L;
+    
+    private NodeContainer nodeContainer;
+    private Map<String, CompositeNode.NodeAndType> inConnectionMap = new HashMap<String, CompositeNode.NodeAndType>();
+    private Map<String, CompositeNode.NodeAndType> outConnectionMap = new HashMap<String, CompositeNode.NodeAndType>();
+    
+    public CompositeNode() {
+        this.nodeContainer = new NodeContainerImpl();
+    }
+    
+    public Node getNode(long id) {
+        return nodeContainer.getNode(id);
+    }
+
+    public Node[] getNodes() {
+        return nodeContainer.getNodes();
+    }
+
+    public void addNode(Node node) {
+        nodeContainer.addNode(node);
+        node.setNodeContainer(this);
+    }
+
+    public void removeNode(Node node) {
+        nodeContainer.removeNode(node);
+        node.setNodeContainer(null);
+    }
+    
+    public void linkIncomingConnections(String inType, CompositeNode.NodeAndType inNode) {
+        inConnectionMap.put(inType, inNode);
+    }
+    
+    public void linkOutgoingConnections(CompositeNode.NodeAndType outNode, String outType) {
+        outConnectionMap.put(outType, outNode);
+    }
+
+    public CompositeNode.NodeAndType getLinkedIncomingNode(String inType) {
+        return inConnectionMap.get(inType);
+    }
+
+    public CompositeNode.NodeAndType getLinkedOutgoingNode(String outType) {
+        return outConnectionMap.get(outType);
+    }
+    
+    public void validateAddIncomingConnection(final String type, final Connection connection) {
+        CompositeNode.NodeAndType nodeAndType = getLinkedIncomingNode(type);
+        if (nodeAndType == null) {
+            throw new IllegalArgumentException(
+                "Cannot add incoming connections to a composite node until these connections can be mapped correctly to a subnode!");
+        }
+        ((NodeImpl) nodeAndType.getNode()).validateAddIncomingConnection(nodeAndType.getType(), connection);
+    }
+    
+    public void addIncomingConnection(String type, Connection connection) {
+        super.addIncomingConnection(type, connection);
+        CompositeNodeStart start = new CompositeNodeStart(connection.getFrom(), type);
+        addNode(start);
+        CompositeNode.NodeAndType inNode = getLinkedIncomingNode(type);
+        new ConnectionImpl(
+            start, Node.CONNECTION_DEFAULT_TYPE, 
+            inNode.getNode(), inNode.getType());
+    }
+    
+    public void validateAddOutgoingConnection(final String type, final Connection connection) {
+        CompositeNode.NodeAndType nodeAndType = getLinkedOutgoingNode(type);
+        if (nodeAndType == null) {
+            throw new IllegalArgumentException(
+                "Cannot add outgoing connections to a composite node until these connections can be mapped correctly to a subnode!");
+        }
+        ((NodeImpl) nodeAndType.getNode()).validateAddOutgoingConnection(nodeAndType.getType(), connection);
+    }
+    
+    public void addOutgoingConnection(String type, Connection connection) {
+        super.addOutgoingConnection(type, connection);
+        CompositeNodeEnd end = new CompositeNodeEnd(connection.getTo(), type);
+        addNode(end);
+        CompositeNode.NodeAndType outNode = getLinkedOutgoingNode(type);
+        new ConnectionImpl(
+            outNode.getNode(), outNode.getType(), 
+            end, Node.CONNECTION_DEFAULT_TYPE);
+    }
+    
+    public void validateRemoveIncomingConnection(final String type, final Connection connection) {
+        CompositeNode.NodeAndType nodeAndType = getLinkedIncomingNode(type);
+        ((NodeImpl) nodeAndType.getNode()).validateRemoveIncomingConnection(nodeAndType.getType(), connection);
+    }
+    
+    public void removeIncomingConnection(String type, Connection connection) {
+        super.removeIncomingConnection(type, connection);
+        CompositeNode.NodeAndType inNode = getLinkedIncomingNode(type);
+        List<Connection> connections = inNode.getNode().getIncomingConnections(inNode.getType());
+        for (Iterator<Connection> iterator = connections.iterator(); iterator.hasNext(); ) {
+            Connection internalConnection = iterator.next();
+            if (((CompositeNodeStart) internalConnection.getFrom()).getInNode().equals(connection.getFrom())) {
+                ((ConnectionImpl) internalConnection).terminate();
+                removeNode(internalConnection.getFrom());
+            }
+        }
+    }
+    
+    public void validateRemoveOutgoingConnection(final String type, final Connection connection) {
+        CompositeNode.NodeAndType nodeAndType = getLinkedOutgoingNode(type);
+        ((NodeImpl) nodeAndType.getNode()).validateRemoveOutgoingConnection(nodeAndType.getType(), connection);
+    }
+    
+    public void removeOutgoingConnection(String type, Connection connection) {
+        super.removeOutgoingConnection(type, connection);
+        CompositeNode.NodeAndType outNode = getLinkedOutgoingNode(type);
+        List<Connection> connections = outNode.getNode().getOutgoingConnections(outNode.getType());
+        for (Iterator<Connection> iterator = connections.iterator(); iterator.hasNext(); ) {
+            Connection internalConnection = iterator.next();
+            if (((CompositeNodeEnd) internalConnection.getTo()).getOutNode().equals(connection.getTo())) {
+                ((ConnectionImpl) internalConnection).terminate();
+                removeNode(internalConnection.getTo());
+            }
+        }
+    }
+    
+    public static class NodeAndType {
+
+        private Node node;
+        private String type;
+        
+        public NodeAndType(Node node, String type) {
+            if (node == null || type == null) {
+                throw new IllegalArgumentException(
+                    "Node or type may not be null!");
+            }
+            this.node = node;
+            this.type = type;
+        }
+        
+        public Node getNode() {
+            return node;
+        }
+
+        public String getType() {
+            return type;
+        }
+        
+        public boolean equals(Object o) {
+            if (o instanceof NodeAndType) {
+                return node.equals(((NodeAndType) o).node)
+                    && type.equals(((NodeAndType) o).type); 
+            }
+            return false;
+        }
+        
+        public int hashCode() {
+            return node.hashCode() + 13*type.hashCode();
+        }
+        
+    }
+    
+    public class CompositeNodeStart extends NodeImpl {
+
+        private static final long serialVersionUID = 400L;
+        
+        private Node outNode;
+        private String outType;
+        
+        public CompositeNodeStart(Node outNode, String outType) {
+            setName("Composite node start");
+            this.outNode = outNode;
+            this.outType = outType;
+        }
+        
+        public Node getInNode() {
+            return outNode;
+        }
+        
+        public String getInType() {
+            return outType;
+        }
+        
+        public Connection getTo() {
+            final List<Connection> list =
+                getOutgoingConnections(Node.CONNECTION_DEFAULT_TYPE);
+            if (list.size() > 0) {
+                return (Connection) list.get(0);
+            }
+            return null;
+        }
+        
+    }
+    
+    public class CompositeNodeEnd extends NodeImpl {
+
+        private static final long serialVersionUID = 400L;
+        
+        private Node outNode;
+        private String outType;
+        
+        public CompositeNodeEnd(Node outNode, String outType) {
+            setName("Composite node end");
+            this.outNode = outNode;
+            this.outType = outType;
+        }
+        
+        public Node getOutNode() {
+            return outNode;
+        }
+        
+        public String getOutType() {
+            return outType;
+        }
+        
+    }
+    
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/node/EndNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/node/EndNode.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/node/EndNode.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,39 @@
+package org.drools.workflow.core.node;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.workflow.core.Connection;
+
+/**
+ * Default implementation of an end node.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class EndNode extends SequenceNode {
+
+    private static final long serialVersionUID = 400L;
+
+    public void validateAddOutgoingConnection(final String type, final Connection connection) {
+        throw new UnsupportedOperationException(
+            "An end node does not have an outgoing connection!");
+    }
+
+    public void validateRemoveOutgoingConnection(final String type, final Connection connection) {
+        throw new UnsupportedOperationException(
+            "An end node does not have an outgoing connection!");
+    }
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/node/Join.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/node/Join.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/node/Join.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,101 @@
+package org.drools.workflow.core.node;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.List;
+
+import org.drools.workflow.core.Connection;
+import org.drools.workflow.core.Node;
+import org.drools.workflow.core.impl.NodeImpl;
+
+/**
+ * Default implementation of a join.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class Join extends NodeImpl {
+
+    public static final int TYPE_UNDEFINED     = 0;
+    /**
+     * The outgoing connection of a join of this type is triggered
+     * when all its incoming connections have been triggered.
+     */
+    public static final int TYPE_AND           = 1;
+    /**
+     * The outgoing connection of a join of this type is triggered
+     * when one of its incoming connections has been triggered.
+     */
+    public static final int TYPE_XOR           = 2;
+    /**
+     * The outgoing connection of a join of this type is triggered
+     * when one of its incoming connections has been triggered. It then
+     * waits until all other incoming connections have been triggered
+     * before allowing 
+     */
+    public static final int TYPE_DISCRIMINATOR = 3;
+    
+    private static final long serialVersionUID = 400L;
+
+    private int               type;
+
+    public Join() {
+        this.type = TYPE_UNDEFINED;
+    }
+
+    public void setType(final int type) {
+        this.type = type;
+    }
+
+    public int getType() {
+        return this.type;
+    }
+
+    public Connection getTo() {
+        final List<Connection> list =
+            getOutgoingConnections(Node.CONNECTION_DEFAULT_TYPE);
+        if (list.size() > 0) {
+            return (Connection) list.get(0);
+        }
+        return null;
+    }
+    
+    public List<Connection> getDefaultIncomingConnections() {
+        return getIncomingConnections(Node.CONNECTION_DEFAULT_TYPE);
+    }
+
+    public void validateAddIncomingConnection(final String type,
+            final Connection connection) {
+        super.validateAddIncomingConnection(type, connection);
+        if (!Node.CONNECTION_DEFAULT_TYPE.equals(type)) {
+            throw new IllegalArgumentException(
+                "This type of node only accepts default incoming connection type!");
+        }
+    }
+
+    public void validateAddOutgoingConnection(final String type, final Connection connection) {
+        super.validateAddOutgoingConnection(type, connection);
+        if (!Node.CONNECTION_DEFAULT_TYPE.equals(type)) {
+            throw new IllegalArgumentException(
+                "This type of node only accepts default outgoing connection type!");
+        }
+        if (!getOutgoingConnections(Node.CONNECTION_DEFAULT_TYPE).isEmpty()) {
+            throw new IllegalArgumentException(
+                "This type of node cannot have more than one outgoing connection");
+        }
+    }
+    
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/node/MilestoneNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/node/MilestoneNode.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/node/MilestoneNode.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,39 @@
+package org.drools.workflow.core.node;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+/**
+ * Default implementation of a milestone node.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class MilestoneNode extends SequenceNode {
+
+	private static final long serialVersionUID = 8552568488755348247L;
+
+	private String            constraint;
+
+    public void setConstraint(final String constraint) {
+        this.constraint = constraint;
+    }
+
+    public String getConstraint() {
+        return this.constraint;
+    }
+
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/node/RuleSetNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/node/RuleSetNode.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/node/RuleSetNode.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,39 @@
+package org.drools.workflow.core.node;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+/**
+ * Default implementation of a RuleSet node.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class RuleSetNode extends SequenceNode {
+
+    private static final long serialVersionUID = 400L;
+
+    private String ruleFlowGroup;
+
+    public void setRuleFlowGroup(final String ruleFlowGroup) {
+        this.ruleFlowGroup = ruleFlowGroup;
+    }
+
+    public String getRuleFlowGroup() {
+        return this.ruleFlowGroup;
+    }
+
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/node/SequenceNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/node/SequenceNode.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/node/SequenceNode.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,59 @@
+package org.drools.workflow.core.node;
+
+import java.util.List;
+
+import org.drools.workflow.core.Connection;
+import org.drools.workflow.core.Node;
+import org.drools.workflow.core.impl.NodeImpl;
+
+/**
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public abstract class SequenceNode extends NodeImpl {
+
+    public Connection getFrom() {
+        final List<Connection> list =
+            getIncomingConnections(Node.CONNECTION_DEFAULT_TYPE);
+        if (list.size() > 0) {
+            return (Connection) list.get(0);
+        }
+        return null;
+    }
+
+    public Connection getTo() {
+        final List<Connection> list =
+            getOutgoingConnections(Node.CONNECTION_DEFAULT_TYPE);
+        if (list.size() > 0) {
+            return (Connection) list.get(0);
+        }
+        return null;
+    }
+
+    public void validateAddIncomingConnection(final String type,
+            final Connection connection) {
+        super.validateAddIncomingConnection(type, connection);
+        if (!Node.CONNECTION_DEFAULT_TYPE.equals(type)) {
+            throw new IllegalArgumentException(
+                "This type of node only accepts default incoming connection type!");
+        }
+        if (getIncomingConnections(Node.CONNECTION_DEFAULT_TYPE) != null
+                && !getIncomingConnections(Node.CONNECTION_DEFAULT_TYPE).isEmpty()) {
+            throw new IllegalArgumentException(
+                "This type of node cannot have more than one incoming connection!");
+        }
+    }
+
+    public void validateAddOutgoingConnection(final String type, final Connection connection) {
+        super.validateAddOutgoingConnection(type, connection);
+        if (!Node.CONNECTION_DEFAULT_TYPE.equals(type)) {
+            throw new IllegalArgumentException(
+                "This type of node only accepts default outgoing connection type!");
+        }
+        if (getOutgoingConnections(Node.CONNECTION_DEFAULT_TYPE) != null
+                && !getOutgoingConnections(Node.CONNECTION_DEFAULT_TYPE).isEmpty()) {
+            throw new IllegalArgumentException(
+                "This type of node cannot have more than one outgoing connection!");
+        }
+    }
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/node/Split.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/node/Split.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/node/Split.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,168 @@
+package org.drools.workflow.core.node;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.drools.workflow.core.Connection;
+import org.drools.workflow.core.Constraint;
+import org.drools.workflow.core.Node;
+import org.drools.workflow.core.impl.NodeImpl;
+
+/**
+ * Default implementation of a split node.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class Split extends NodeImpl {
+
+    public static final int TYPE_UNDEFINED = 0;
+    /**
+     * All outgoing connections of a split of this type are triggered
+     * when its incoming connection has been triggered.  A split of this
+     * type should have no constraints linked to any of its outgoing
+     * connections.
+     */
+    public static final int TYPE_AND       = 1;
+    /**
+     * Exactly one outgoing connection of a split of this type is triggered
+     * when its incoming connection has been triggered.  Which connection
+     * is based on the constraints associated with each of the connections:
+     * the connection with the highest priority whose constraint is satisfied
+     * is triggered.  
+     */
+    public static final int TYPE_XOR       = 2;
+    /**
+     * One or multiple outgoing connections of a split of this type are
+     * triggered when its incoming connection has been triggered.  Which
+     * connections is based on the constraints associated with each of the
+     * connections: all connections whose constraint is satisfied are
+     * triggered.  
+     */
+    public static final int TYPE_OR        = 3;
+
+    private static final long serialVersionUID = 400L;
+
+    private int type;
+    private Map<Connection, Constraint> constraints = new HashMap<Connection, Constraint>();
+
+    public Split() {
+        this.type = TYPE_UNDEFINED;
+    }
+
+    public Split(final int type) {
+        this.type = type;
+    }
+
+    public void setType(final int type) {
+        this.type = type;
+    }
+
+    public int getType() {
+        return this.type;
+    }
+
+    public Constraint getConstraint(final Connection connection) {
+        if ( connection == null ) {
+            throw new IllegalArgumentException( "connection is null" );
+        }
+
+        // dirty hack because keys were entered wrong
+        // probably caused by xstreams
+        // TODO xstream 1.3.0 should fix this by default; in 1.2.2 it's fixable: http://jira.codehaus.org/browse/XSTR-363
+        final HashMap<Connection, Constraint> newMap = new HashMap<Connection, Constraint>();
+        for (final Iterator<Map.Entry<Connection, Constraint>> it = this.constraints.entrySet().iterator(); it.hasNext(); ) {
+            final Entry<Connection, Constraint> entry = it.next();
+            newMap.put(entry.getKey(), entry.getValue());
+        }
+        this.constraints = newMap;
+
+        if ( this.type == TYPE_OR || this.type == TYPE_XOR ) {
+            return this.constraints.get(connection);
+        }
+        throw new UnsupportedOperationException( "Constraints are " + "only supported with XOR or OR split types, not with: " + getType() );
+    }
+
+    public void setConstraint(final Connection connection,
+                              final Constraint constraint) {
+        if ( this.type == TYPE_OR || this.type == TYPE_XOR ) {
+            if ( connection == null ) {
+                throw new IllegalArgumentException( "connection is null" );
+            }
+            if (getOutgoingConnections(Node.CONNECTION_DEFAULT_TYPE) != null
+                    && !getOutgoingConnections(Node.CONNECTION_DEFAULT_TYPE).contains(connection)) {
+                throw new IllegalArgumentException("connection is unknown:" + connection);
+            }
+            this.constraints.put( connection,
+                                  constraint );
+        } else {
+            throw new UnsupportedOperationException( "Constraints are " + "only supported with XOR or OR split types, not with type:" + getType() );
+        }
+    }
+
+    public Map<Connection, Constraint> getConstraints() {
+        if ( this.type == TYPE_OR || this.type == TYPE_XOR ) {
+            return Collections.unmodifiableMap( this.constraints );
+        }
+        throw new UnsupportedOperationException( "Constraints are " + "only supported with XOR or OR split types, not with: " + getType() );
+    }
+
+    public Connection getFrom() {
+        final List<Connection> list =
+            getIncomingConnections(Node.CONNECTION_DEFAULT_TYPE);
+        if (list.size() > 0) {
+            return (Connection) list.get(0);
+        }
+        return null;
+    }
+    
+    public List<Connection> getDefaultOutgoingConnections() {
+        return getOutgoingConnections(Node.CONNECTION_DEFAULT_TYPE);
+    }
+
+    public void validateAddIncomingConnection(final String type,
+            final Connection connection) {
+        super.validateAddIncomingConnection(type, connection);
+        if (!Node.CONNECTION_DEFAULT_TYPE.equals(type)) {
+            throw new IllegalArgumentException(
+                "This type of node only accepts default incoming connection type!");
+        }
+        if (!getIncomingConnections(Node.CONNECTION_DEFAULT_TYPE).isEmpty()) {
+            throw new IllegalArgumentException(
+                "This type of node cannot have more than one incoming connection!");
+        }
+    }
+
+    public void validateAddOutgoingConnection(final String type, final Connection connection) {
+        super.validateAddOutgoingConnection(type, connection);
+        if (!Node.CONNECTION_DEFAULT_TYPE.equals(type)) {
+            throw new IllegalArgumentException(
+                "This type of node only accepts default outgoing connection type!");
+        }
+    }
+
+    public void removeOutgoingConnection(final String type, final Connection connection) {
+        super.removeOutgoingConnection(type, connection);
+        this.constraints.remove(connection);
+    }
+
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/node/StartNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/node/StartNode.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/node/StartNode.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,40 @@
+package org.drools.workflow.core.node;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.workflow.core.Connection;
+
+/**
+ * Default implementation of a start node.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class StartNode extends SequenceNode {
+
+    private static final long serialVersionUID = 400L;
+
+    public void validateAddIncomingConnection(final String type, final Connection connection) {
+        throw new UnsupportedOperationException(
+            "A start node does not have an incoming connection!");
+    }
+
+    public void validateRemoveIncomingConnection(final String type, final Connection connection) {
+        throw new UnsupportedOperationException(
+            "A start node does not have an incoming connection!");
+    }
+
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/node/SubProcessNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/node/SubProcessNode.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/node/SubProcessNode.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,48 @@
+package org.drools.workflow.core.node;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+/**
+ * Default implementation of a sub-flow node.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class SubProcessNode extends SequenceNode {
+
+	private static final long serialVersionUID = 400L;
+	
+	private String            processId;
+	private boolean           waitForCompletion = true;
+
+    public void setProcessId(final String processId) {
+        this.processId = processId;
+    }
+
+    public String getProcessId() {
+        return this.processId;
+    }
+
+    public boolean isWaitForCompletion() {
+        return waitForCompletion;
+    }
+
+    public void setWaitForCompletion(boolean waitForCompletion) {
+        this.waitForCompletion = waitForCompletion;
+    }
+
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/node/WorkItemNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/node/WorkItemNode.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/core/node/WorkItemNode.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,70 @@
+package org.drools.workflow.core.node;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.drools.process.core.Work;
+
+/**
+ * Default implementation of a task node.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class WorkItemNode extends SequenceNode {
+
+	private static final long serialVersionUID = 400L;
+	
+	private Work work;
+    private Map<String, String> inMapping = new HashMap<String, String>();
+    private Map<String, String> outMapping = new HashMap<String, String>();
+
+	public Work getWork() {
+		return work;
+	}
+
+	public void setWork(Work task) {
+		this.work = task;
+	}
+	
+    public void addInMapping(String parameterName, String variableName) {
+        inMapping.put(parameterName, variableName);
+    }
+    
+    public String getInMapping(String parameterName) {
+        return inMapping.get(parameterName);
+    }
+
+    public Map<String, String> getInMappings() {
+        return Collections.unmodifiableMap(inMapping);
+    }
+    
+    public void addOutMapping(String parameterName, String variableName) {
+        outMapping.put(parameterName, variableName);
+    }
+    
+    public String getOutMapping(String parameterName) {
+        return outMapping.get(parameterName);
+    }
+
+    public Map<String, String> getOutMappings() {
+        return Collections.unmodifiableMap(outMapping);
+    }
+
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/NodeInstance.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/NodeInstance.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/NodeInstance.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,46 @@
+package org.drools.workflow.instance;
+
+import org.drools.workflow.core.Node;
+
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Represents a node instance in a RuleFlow. This is the runtime counterpart
+ * of a node, containing all runtime state.  Node instance classes also
+ * contain the logic on what to do when it is being triggered (start
+ * executing) or completed (end of execution).
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public interface NodeInstance {
+
+    long getId();
+
+    long getNodeId();
+
+    WorkflowProcessInstance getProcessInstance();
+
+    NodeInstanceContainer getNodeInstanceContainer();
+    
+    void trigger(NodeInstance from, String type);
+
+    void cancel();
+    
+    Node getNode();
+    
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/NodeInstanceContainer.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/NodeInstanceContainer.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/NodeInstanceContainer.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,28 @@
+package org.drools.workflow.instance;
+
+import java.util.Collection;
+
+import org.drools.workflow.core.Node;
+import org.drools.workflow.core.NodeContainer;
+
+/**
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public interface NodeInstanceContainer {
+
+    Collection<NodeInstance> getNodeInstances();
+
+    Collection<NodeInstance> getNodeInstances(boolean recursive);
+
+    NodeInstance getFirstNodeInstance(long nodeId);
+
+    NodeInstance getNodeInstance(Node node);
+
+    void addNodeInstance(NodeInstance nodeInstance);
+
+    void removeNodeInstance(NodeInstance nodeInstance);
+    
+    NodeContainer getNodeContainer();
+
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/WorkflowProcessInstance.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/WorkflowProcessInstance.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/WorkflowProcessInstance.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,44 @@
+package org.drools.workflow.instance;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.Agenda;
+import org.drools.WorkingMemory;
+import org.drools.process.instance.ProcessInstance;
+import org.drools.process.instance.WorkItemListener;
+import org.drools.workflow.core.WorkflowProcess;
+
+/**
+ * A process instance for a RuleFlow process.
+ * Contains a reference to all its node instances, and the agenda that
+ * is controlling the RuleFlow process.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public interface WorkflowProcessInstance extends ProcessInstance, NodeInstanceContainer {
+
+    WorkflowProcess getWorkflowProcess();
+
+    WorkingMemory getWorkingMemory();
+
+    Agenda getAgenda();
+    
+    void addWorkItemListener(WorkItemListener listener);
+
+    void removeWorkItemListener(WorkItemListener listener);
+
+}
\ No newline at end of file

Copied: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/ConstraintEvaluator.java (from rev 17570, labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/nodes/split/ConstraintEvaluator.java)
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/ConstraintEvaluator.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/ConstraintEvaluator.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,13 @@
+package org.drools.workflow.instance.impl;
+
+import org.drools.workflow.core.Connection;
+import org.drools.workflow.core.Constraint;
+import org.drools.workflow.instance.node.SplitInstance;
+
+public interface ConstraintEvaluator extends Constraint {
+    
+    // TODO: make this work for more than only splits
+    public boolean evaluate(SplitInstance instance,
+                            Connection connection,
+                            Constraint constraint);
+}
\ No newline at end of file

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/NodeInstanceFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/NodeInstanceFactory.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/NodeInstanceFactory.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,12 @@
+package org.drools.workflow.instance.impl;
+
+import org.drools.workflow.core.Node;
+import org.drools.workflow.instance.NodeInstance;
+import org.drools.workflow.instance.NodeInstanceContainer;
+import org.drools.workflow.instance.WorkflowProcessInstance;
+
+public interface NodeInstanceFactory {
+    
+	NodeInstance getNodeInstance(Node node, WorkflowProcessInstance processInstance, NodeInstanceContainer nodeInstanceContainer);
+	
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/NodeInstanceFactoryRegistry.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/NodeInstanceFactoryRegistry.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/NodeInstanceFactoryRegistry.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,66 @@
+package org.drools.workflow.instance.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.drools.workflow.core.Node;
+import org.drools.workflow.core.node.ActionNode;
+import org.drools.workflow.core.node.EndNode;
+import org.drools.workflow.core.node.Join;
+import org.drools.workflow.core.node.MilestoneNode;
+import org.drools.workflow.core.node.RuleSetNode;
+import org.drools.workflow.core.node.Split;
+import org.drools.workflow.core.node.StartNode;
+import org.drools.workflow.core.node.SubProcessNode;
+import org.drools.workflow.core.node.WorkItemNode;
+import org.drools.workflow.instance.impl.factory.CreateNewNodeFactory;
+import org.drools.workflow.instance.impl.factory.ReuseNodeFactory;
+import org.drools.workflow.instance.node.ActionNodeInstance;
+import org.drools.workflow.instance.node.EndNodeInstance;
+import org.drools.workflow.instance.node.JoinInstance;
+import org.drools.workflow.instance.node.MilestoneNodeInstance;
+import org.drools.workflow.instance.node.RuleSetNodeInstance;
+import org.drools.workflow.instance.node.SplitInstance;
+import org.drools.workflow.instance.node.StartNodeInstance;
+import org.drools.workflow.instance.node.SubProcessNodeInstance;
+import org.drools.workflow.instance.node.WorkItemNodeInstance;
+
+public class NodeInstanceFactoryRegistry {
+    public static final NodeInstanceFactoryRegistry          instance = new NodeInstanceFactoryRegistry();
+
+    private Map<Class< ? extends Node>, NodeInstanceFactory> registry;
+
+    public NodeInstanceFactoryRegistry() {
+        this.registry = new HashMap<Class< ? extends Node>, NodeInstanceFactory>();
+
+        // hard wired nodes:
+        register( RuleSetNode.class,
+                  new CreateNewNodeFactory( RuleSetNodeInstance.class ) );
+        register( Split.class,
+                  new CreateNewNodeFactory( SplitInstance.class ) );
+        register( Join.class,
+                  new ReuseNodeFactory( JoinInstance.class ) );
+        register( StartNode.class,
+                  new CreateNewNodeFactory( StartNodeInstance.class ) );
+        register( EndNode.class,
+                  new CreateNewNodeFactory( EndNodeInstance.class ) );
+        register( MilestoneNode.class,
+                  new CreateNewNodeFactory( MilestoneNodeInstance.class ) );
+        register( SubProcessNode.class,
+                  new CreateNewNodeFactory( SubProcessNodeInstance.class ) );
+        register( ActionNode.class,
+                  new CreateNewNodeFactory( ActionNodeInstance.class ) );
+        register( WorkItemNode.class,
+                  new CreateNewNodeFactory( WorkItemNodeInstance.class ) );
+    }
+
+    public void register(Class< ? extends Node> cls,
+                         NodeInstanceFactory factory) {
+        this.registry.put( cls,
+                           factory );
+    }
+
+    public NodeInstanceFactory getProcessNodeInstanceFactory(Node node) {
+        return this.registry.get( node.getClass() );
+    }
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/NodeInstanceImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/NodeInstanceImpl.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/NodeInstanceImpl.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,90 @@
+package org.drools.workflow.instance.impl;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.Serializable;
+
+import org.drools.common.EventSupport;
+import org.drools.common.InternalWorkingMemory;
+import org.drools.workflow.core.Node;
+import org.drools.workflow.instance.NodeInstance;
+import org.drools.workflow.instance.NodeInstanceContainer;
+import org.drools.workflow.instance.WorkflowProcessInstance;
+
+/**
+ * Default implementation of a RuleFlow node instance.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public abstract class NodeInstanceImpl implements NodeInstance, Serializable {
+
+    private long id;
+    private long nodeId;
+    private WorkflowProcessInstance processInstance;
+    private NodeInstanceContainer nodeInstanceContainer;
+
+    public void setId(final long id) {
+        this.id = id;
+    }
+
+    public long getId() {
+        return this.id;
+    }
+
+    public void setNodeId(final long nodeId) {
+        this.nodeId = nodeId;
+    }
+
+    public long getNodeId() {
+        return this.nodeId;
+    }
+
+    public void setProcessInstance(final WorkflowProcessInstance processInstance) {
+        this.processInstance = processInstance;
+    }
+
+    public WorkflowProcessInstance getProcessInstance() {
+        return this.processInstance;
+    }
+
+    public NodeInstanceContainer getNodeInstanceContainer() {
+        return this.nodeInstanceContainer;
+    }
+    
+    public void setNodeInstanceContainer(NodeInstanceContainer nodeInstanceContainer) {
+        this.nodeInstanceContainer = nodeInstanceContainer;
+        if (nodeInstanceContainer != null) {
+            nodeInstanceContainer.addNodeInstance(this);
+        }
+    }
+
+    public Node getNode() {
+        return this.nodeInstanceContainer.getNodeContainer().getNode( this.nodeId );
+    }
+    
+    public void cancel() {
+        nodeInstanceContainer.removeNodeInstance(this);
+    }
+    
+    public final void trigger(NodeInstance from, String type) {
+        ((EventSupport) getProcessInstance().getWorkingMemory()).getRuleFlowEventSupport().fireBeforeRuleFlowNodeTriggered(this, (InternalWorkingMemory) getProcessInstance().getWorkingMemory());
+        internalTrigger(from, type);
+        ((EventSupport) getProcessInstance().getWorkingMemory()).getRuleFlowEventSupport().fireAfterRuleFlowNodeTriggered(this, (InternalWorkingMemory) getProcessInstance().getWorkingMemory());
+    }
+    
+    public abstract void internalTrigger(NodeInstance from, String type);
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/ReturnValueConstraintEvaluator.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/ReturnValueConstraintEvaluator.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/ReturnValueConstraintEvaluator.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,107 @@
+package org.drools.workflow.instance.impl;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.Serializable;
+
+import org.drools.spi.ReturnValueEvaluator;
+import org.drools.workflow.core.Connection;
+import org.drools.workflow.core.Constraint;
+import org.drools.workflow.instance.node.SplitInstance;
+
+/**
+ * Default implementation of a constraint.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ReturnValueConstraintEvaluator
+    implements Constraint, ConstraintEvaluator, Serializable {
+
+    private static final long  serialVersionUID = 400L;
+
+    private String             name;
+    private String             constraint;
+    private int                priority;
+    private String             dialect;
+    private String             type;       
+    
+    private ReturnValueEvaluator evaluator;
+    
+    public String getConstraint() {
+        return this.constraint;
+    }
+
+    public void setConstraint(final String constraint) {
+        this.constraint = constraint;
+    }
+
+    public String getName() {
+        return this.name;
+    }
+
+    public void setName(final String name) {
+        this.name = name;
+    }
+
+    public String toString() {
+        return this.name;
+    }
+
+    public int getPriority() {
+        return this.priority;
+    }
+
+    public void setPriority(final int priority) {
+        this.priority = priority;
+    }
+
+    public String getDialect() {
+        return dialect;
+    }
+
+    public void setDialect(String dialect) {
+        this.dialect = dialect;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+    
+    public void setEvaluator(ReturnValueEvaluator evaluator) {
+        this.evaluator = evaluator;
+    }
+
+    public boolean evaluate(SplitInstance instance,
+                            Connection connection,
+                            Constraint constraint) {
+        Object value;
+        try {
+            value = this.evaluator.evaluate( instance.getProcessInstance().getWorkingMemory() );
+        } catch ( Exception e ) {
+            throw  new RuntimeException("unable to execute ReturnValueEvaluator", e);
+        }
+        if ( !(value instanceof Boolean) ) {
+            throw new RuntimeException("Constraints must return boolean values" );
+        }
+        return ((Boolean)value).booleanValue();
+    }    
+
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/RuleConstraintEvaluator.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/RuleConstraintEvaluator.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/RuleConstraintEvaluator.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,106 @@
+package org.drools.workflow.instance.impl;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.Serializable;
+import java.util.Iterator;
+
+import org.drools.common.RuleFlowGroupNode;
+import org.drools.spi.Activation;
+import org.drools.spi.RuleFlowGroup;
+import org.drools.workflow.core.Connection;
+import org.drools.workflow.core.Constraint;
+import org.drools.workflow.instance.WorkflowProcessInstance;
+import org.drools.workflow.instance.node.SplitInstance;
+
+/**
+ * Default implementation of a constraint.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class RuleConstraintEvaluator implements Constraint,
+        ConstraintEvaluator, Serializable {
+
+    private static final long  serialVersionUID = 400L;
+
+    private String             name;
+    private String             constraint;
+    private int                priority;
+    private String             dialect;
+    private String             type;       
+    
+    public String getConstraint() {
+        return this.constraint;
+    }
+
+    public void setConstraint(final String constraint) {
+        this.constraint = constraint;
+    }
+
+    public String getName() {
+        return this.name;
+    }
+
+    public void setName(final String name) {
+        this.name = name;
+    }
+
+    public String toString() {
+        return this.name;
+    }
+
+    public int getPriority() {
+        return this.priority;
+    }
+
+    public void setPriority(final int priority) {
+        this.priority = priority;
+    }
+
+    public String getDialect() {
+        return dialect;
+    }
+
+    public void setDialect(String dialect) {
+        this.dialect = dialect;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+    
+    public boolean evaluate(SplitInstance instance,
+                            Connection connection,
+                            Constraint constraint) {
+        WorkflowProcessInstance processInstance = instance.getProcessInstance();
+        RuleFlowGroup systemRuleFlowGroup = processInstance.getAgenda().getRuleFlowGroup( "DROOLS_SYSTEM" );
+
+        String rule = "RuleFlow-Split-" + processInstance.getProcess().getId() + "-" + instance.getNode().getId() + "-" + connection.getTo().getId();
+        for ( Iterator activations = systemRuleFlowGroup.iterator(); activations.hasNext(); ) {
+            Activation activation = ((RuleFlowGroupNode) activations.next()).getActivation();
+            if ( rule.equals( activation.getRule().getName() ) ) {
+                return true;
+            }
+        }
+        return false;
+    }    
+
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/WorkflowProcessInstanceImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/WorkflowProcessInstanceImpl.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/WorkflowProcessInstanceImpl.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,183 @@
+package org.drools.workflow.instance.impl;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.drools.Agenda;
+import org.drools.WorkingMemory;
+import org.drools.common.EventSupport;
+import org.drools.common.InternalRuleBase;
+import org.drools.common.InternalWorkingMemory;
+import org.drools.process.instance.WorkItem;
+import org.drools.process.instance.WorkItemListener;
+import org.drools.process.instance.impl.ProcessInstanceImpl;
+import org.drools.workflow.core.Node;
+import org.drools.workflow.core.NodeContainer;
+import org.drools.workflow.core.WorkflowProcess;
+import org.drools.workflow.instance.NodeInstance;
+import org.drools.workflow.instance.NodeInstanceContainer;
+import org.drools.workflow.instance.WorkflowProcessInstance;
+
+/**
+ * Default implementation of a RuleFlow process instance.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public abstract class WorkflowProcessInstanceImpl extends ProcessInstanceImpl
+        implements WorkflowProcessInstance {
+
+    private static final long serialVersionUID = 400L;
+
+    private InternalWorkingMemory workingMemory;
+    private final List<NodeInstance> nodeInstances = new ArrayList<NodeInstance>();;
+    private long nodeInstanceCounter = 0;
+    private List<WorkItemListener> workItemListeners = new ArrayList<WorkItemListener>();
+
+    public WorkflowProcess getWorkflowProcess() {
+        return (WorkflowProcess) getProcess();
+    }
+
+    public NodeContainer getNodeContainer() {
+        return getWorkflowProcess();
+    }
+
+    public void addNodeInstance(final NodeInstance nodeInstance) {
+        ((NodeInstanceImpl) nodeInstance).setId(nodeInstanceCounter++);
+        this.nodeInstances.add(nodeInstance);
+    }
+
+    public void removeNodeInstance(final NodeInstance nodeInstance) {
+        this.nodeInstances.remove(nodeInstance);
+    }
+
+    public Collection<NodeInstance> getNodeInstances() {
+        return getNodeInstances(false);
+    }
+    
+    public Collection<NodeInstance> getNodeInstances(boolean recursive) {
+        Collection<NodeInstance> result = nodeInstances;
+        if (recursive) {
+            result = new ArrayList<NodeInstance>(result);
+            for (Iterator<NodeInstance> iterator = nodeInstances.iterator(); iterator.hasNext(); ) {
+                NodeInstance nodeInstance = iterator.next();
+                if (nodeInstance instanceof NodeInstanceContainer) {
+                    result.addAll(((NodeInstanceContainer) nodeInstance).getNodeInstances(true));
+                }
+            }
+        }
+        return Collections.unmodifiableCollection(result);
+    }
+
+    public NodeInstance getFirstNodeInstance(final long nodeId) {
+        for ( final Iterator<NodeInstance> iterator = this.nodeInstances.iterator(); iterator.hasNext(); ) {
+            final NodeInstance nodeInstance = iterator.next();
+            if ( nodeInstance.getNodeId() == nodeId ) {
+                return nodeInstance;
+            }
+        }
+        return null;
+    }
+
+    public NodeInstance getNodeInstance(final Node node) {
+        NodeInstanceFactoryRegistry nodeRegistry =
+            ((InternalRuleBase) this.workingMemory.getRuleBase())
+                .getConfiguration().getProcessNodeInstanceFactoryRegistry();
+        NodeInstanceFactory conf = nodeRegistry.getProcessNodeInstanceFactory(node);
+        if (conf == null) {
+            throw new IllegalArgumentException("Illegal node type: " + node.getClass());
+        }
+        NodeInstanceImpl nodeInstance = (NodeInstanceImpl) conf.getNodeInstance(node, this, this);
+        nodeInstance.setNodeId(node.getId());
+        nodeInstance.setNodeInstanceContainer(this);
+        nodeInstance.setProcessInstance(this);
+        if (nodeInstance == null) {
+            throw new IllegalArgumentException("Illegal node type: " + node.getClass());
+        }
+        return nodeInstance;
+    }
+
+    public Agenda getAgenda() {
+        if ( this.workingMemory == null ) {
+            return null;
+        }
+        return this.workingMemory.getAgenda();
+    }
+
+    public void setWorkingMemory(final InternalWorkingMemory workingMemory) {
+        if ( this.workingMemory != null ) {
+            throw new IllegalArgumentException( "A working memory can only be set once." );
+        }
+        this.workingMemory = workingMemory;
+    }
+
+    public WorkingMemory getWorkingMemory() {
+        return this.workingMemory;
+    }
+    
+    public void setState(final int state) {
+        super.setState( state );
+        if ( state == ProcessInstanceImpl.STATE_COMPLETED ) {
+            ((EventSupport) this.workingMemory).getRuleFlowEventSupport().fireBeforeRuleFlowProcessCompleted( this,
+                                                                                                              this.workingMemory );
+            // deactivate all node instances of this process instance
+            while ( !nodeInstances.isEmpty() ) {
+                NodeInstance nodeInstance = (NodeInstance) nodeInstances.get( 0 );
+                nodeInstance.cancel();
+            }
+            workingMemory.removeProcessInstance( this );
+            ((EventSupport) this.workingMemory).getRuleFlowEventSupport().fireAfterRuleFlowProcessCompleted( this,
+                                                                                                             this.workingMemory );
+        }
+    }
+
+    public String toString() {
+        final StringBuffer sb = new StringBuffer( "WorkflowProcessInstance" );
+        sb.append( getId() );
+        sb.append( " [processId=" );
+        sb.append( getProcess().getId() );
+        sb.append( ",state=" );
+        sb.append( getState() );
+        sb.append( "]" );
+        return sb.toString();
+    }
+
+    public void workItemCompleted(WorkItem workItem) {
+        for (WorkItemListener listener: workItemListeners) {
+            listener.workItemCompleted(workItem);
+        }
+    }
+
+    public void workItemAborted(WorkItem workItem) {
+        for (WorkItemListener listener: workItemListeners) {
+            listener.workItemCompleted(workItem);
+        }
+    }
+    
+    public void addWorkItemListener(WorkItemListener listener) {
+        workItemListeners.add(listener);
+    }
+    
+    public void removeWorkItemListener(WorkItemListener listener) {
+        workItemListeners.remove(listener);
+    }
+    
+}

Copied: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/factory/CreateNewNodeFactory.java (from rev 17570, labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/factories/CreateNewNodeFactory.java)
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/factory/CreateNewNodeFactory.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/factory/CreateNewNodeFactory.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,26 @@
+package org.drools.workflow.instance.impl.factory;
+
+import org.drools.workflow.core.Node;
+import org.drools.workflow.instance.NodeInstance;
+import org.drools.workflow.instance.NodeInstanceContainer;
+import org.drools.workflow.instance.WorkflowProcessInstance;
+import org.drools.workflow.instance.impl.NodeInstanceFactory;
+
+public class CreateNewNodeFactory implements NodeInstanceFactory {
+    
+    public final Class<? extends NodeInstance> cls;
+    
+    public CreateNewNodeFactory(Class<? extends NodeInstance> cls){
+        this.cls = cls;
+    }
+    
+    public NodeInstance getNodeInstance(Node node, WorkflowProcessInstance processInstance, NodeInstanceContainer nodeInstanceContainer ) {     
+        try {
+            return this.cls.newInstance();
+        } catch (Exception e) {
+            throw new RuntimeException("Unable to instantiate node: '"
+                + this.cls.getName() + "':" + e.getMessage());
+        }
+	}
+
+}

Copied: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/factory/ReuseNodeFactory.java (from rev 17570, labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/factories/ReuseNodeFactory.java)
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/factory/ReuseNodeFactory.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/impl/factory/ReuseNodeFactory.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,30 @@
+package org.drools.workflow.instance.impl.factory;
+
+import org.drools.workflow.core.Node;
+import org.drools.workflow.instance.NodeInstance;
+import org.drools.workflow.instance.NodeInstanceContainer;
+import org.drools.workflow.instance.WorkflowProcessInstance;
+import org.drools.workflow.instance.impl.NodeInstanceFactory;
+
+public class ReuseNodeFactory implements NodeInstanceFactory {
+    
+    public final Class<? extends NodeInstance> cls;
+    
+    public ReuseNodeFactory(Class<? extends NodeInstance> cls){
+        this.cls = cls;
+    }
+
+	public NodeInstance getNodeInstance(Node node, WorkflowProcessInstance processInstance, NodeInstanceContainer nodeInstanceContainer ) {    	
+        NodeInstance result = nodeInstanceContainer.getFirstNodeInstance( node.getId() );
+        if (result != null) {
+            return result;
+        }
+        try {
+            return cls.newInstance();
+        } catch (Exception e) {
+            throw new RuntimeException("Unable to instantiate node '"
+                + this.cls.getName() + "': " + e.getMessage());
+        }
+	}
+
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/ActionNodeInstance.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/ActionNodeInstance.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/ActionNodeInstance.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,57 @@
+package org.drools.workflow.instance.node;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.spi.Action;
+import org.drools.workflow.core.Node;
+import org.drools.workflow.core.node.ActionNode;
+import org.drools.workflow.instance.NodeInstance;
+import org.drools.workflow.instance.impl.NodeInstanceImpl;
+
+/**
+ * Runtime counterpart of an action node.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ActionNodeInstance extends NodeInstanceImpl {
+
+    private static final long serialVersionUID = 400L;
+
+    protected ActionNode getActionNode() {
+        return (ActionNode) getNode();
+    }
+
+    public void internalTrigger(final NodeInstance from, String type) {
+        if (!Node.CONNECTION_DEFAULT_TYPE.equals(type)) {
+            throw new IllegalArgumentException(
+                "An ActionNode only accepts default incoming connections!");
+        }
+		Action action = (Action) getActionNode().getAction();
+		try {
+	        action.execute( getProcessInstance().getWorkingMemory() );		    
+		} catch (Exception e) {
+		    throw new RuntimeException("unable to execute Action", e);
+		}
+    	triggerCompleted();
+    }
+
+    public void triggerCompleted() {
+        getNodeInstanceContainer().removeNodeInstance(this);
+        getNodeInstanceContainer().getNodeInstance(getActionNode().getTo().getTo()).trigger(this, getActionNode().getTo().getToType());
+    }
+
+}
\ No newline at end of file

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/CompositeNodeInstance.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/CompositeNodeInstance.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/CompositeNodeInstance.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,186 @@
+package org.drools.workflow.instance.node;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.drools.common.InternalRuleBase;
+import org.drools.workflow.core.Connection;
+import org.drools.workflow.core.Node;
+import org.drools.workflow.core.NodeContainer;
+import org.drools.workflow.core.node.CompositeNode;
+import org.drools.workflow.instance.NodeInstance;
+import org.drools.workflow.instance.NodeInstanceContainer;
+import org.drools.workflow.instance.impl.NodeInstanceFactory;
+import org.drools.workflow.instance.impl.NodeInstanceFactoryRegistry;
+import org.drools.workflow.instance.impl.NodeInstanceImpl;
+
+/**
+ * Runtime counterpart of a composite node.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class CompositeNodeInstance extends NodeInstanceImpl implements NodeInstanceContainer {
+
+    private static final long serialVersionUID = 400L;
+    
+    private final List<NodeInstance> nodeInstances = new ArrayList<NodeInstance>();;
+    private long nodeInstanceCounter = 0;
+    
+    protected CompositeNode getCompositeNode() {
+        return (CompositeNode) getNode();
+    }
+    
+    public NodeContainer getNodeContainer() {
+        return getCompositeNode();
+    }
+
+    public void internalTrigger(final NodeInstance from, String type) {
+        CompositeNode.NodeAndType nodeAndType = getCompositeNode().getLinkedIncomingNode(type);
+        List<Connection> connections = nodeAndType.getNode().getIncomingConnections(nodeAndType.getType());
+        for (Iterator<Connection> iterator = connections.iterator(); iterator.hasNext(); ) {
+            Connection connection = iterator.next();
+            if (((CompositeNode.CompositeNodeStart) connection.getFrom()).getInNode().getId() == from.getNodeId()) {
+                NodeInstance nodeInstance = getNodeInstance(connection.getFrom());
+                nodeInstance.trigger(null, nodeAndType.getType());
+                return;
+            }
+        }
+        throw new IllegalArgumentException(
+            "Could not find start for composite node: " + type);
+    }
+
+    public void triggerCompleted(String outType) {
+        getNodeInstanceContainer().removeNodeInstance(this);
+        Connection connection = getCompositeNode().getOutgoingConnections(outType).get(0);
+        getNodeInstanceContainer().getNodeInstance( connection.getTo() ).trigger( this, connection.getToType() );
+    }
+
+    public void addNodeInstance(final NodeInstance nodeInstance) {
+        ((NodeInstanceImpl) nodeInstance).setId(nodeInstanceCounter++);
+        this.nodeInstances.add(nodeInstance);
+    }
+
+    public void removeNodeInstance(final NodeInstance nodeInstance) {
+        this.nodeInstances.remove(nodeInstance);
+    }
+
+    public Collection<NodeInstance> getNodeInstances() {
+        return getNodeInstances(false);
+    }
+    
+    public Collection<NodeInstance> getNodeInstances(boolean recursive) {
+        Collection<NodeInstance> result = nodeInstances;
+        if (recursive) {
+            result = new ArrayList<NodeInstance>(result);
+            for (Iterator<NodeInstance> iterator = nodeInstances.iterator(); iterator.hasNext(); ) {
+                NodeInstance nodeInstance = iterator.next();
+                if (nodeInstance instanceof NodeInstanceContainer) {
+                    result.addAll(((NodeInstanceContainer) nodeInstance).getNodeInstances(true));
+                }
+            }
+        }
+        return Collections.unmodifiableCollection(result);
+    }
+
+    public NodeInstance getFirstNodeInstance(final long nodeId) {
+        for ( final Iterator<NodeInstance> iterator = this.nodeInstances.iterator(); iterator.hasNext(); ) {
+            final NodeInstance nodeInstance = iterator.next();
+            if ( nodeInstance.getNodeId() == nodeId ) {
+                return nodeInstance;
+            }
+        }
+        return null;
+    }
+    
+    public NodeInstance getNodeInstance(final Node node) {
+        // TODO do this cleaner for start / end of composite?
+        if (node instanceof CompositeNode.CompositeNodeStart) {
+            CompositeNodeStartInstance nodeInstance = new CompositeNodeStartInstance();
+            nodeInstance.setNodeId(node.getId());
+            nodeInstance.setNodeInstanceContainer(this);
+            nodeInstance.setProcessInstance(getProcessInstance());
+            return nodeInstance;
+        } else if (node instanceof CompositeNode.CompositeNodeEnd) {
+            CompositeNodeEndInstance nodeInstance = new CompositeNodeEndInstance();
+            nodeInstance.setNodeId(node.getId());
+            nodeInstance.setNodeInstanceContainer(this);
+            nodeInstance.setProcessInstance(getProcessInstance());
+            return nodeInstance;
+        }
+        
+        NodeInstanceFactoryRegistry nodeRegistry =
+            ((InternalRuleBase) getProcessInstance().getWorkingMemory().getRuleBase())
+                .getConfiguration().getProcessNodeInstanceFactoryRegistry();
+        NodeInstanceFactory conf = nodeRegistry.getProcessNodeInstanceFactory(node);
+        if (conf == null) {
+            throw new IllegalArgumentException("Illegal node type: " + node.getClass());
+        }
+        NodeInstanceImpl nodeInstance = (NodeInstanceImpl) conf.getNodeInstance(node, getProcessInstance(), this);
+        nodeInstance.setNodeId(node.getId());
+        nodeInstance.setNodeInstanceContainer(this);
+        nodeInstance.setProcessInstance(getProcessInstance());
+        if (nodeInstance == null) {
+            throw new IllegalArgumentException("Illegal node type: " + node.getClass());
+        }
+        return nodeInstance;
+    }
+
+    public class CompositeNodeStartInstance extends NodeInstanceImpl {
+
+        private static final long serialVersionUID = 400L;
+
+        public CompositeNode.CompositeNodeStart getCompositeNodeStart() {
+            return (CompositeNode.CompositeNodeStart) getNode();
+        }
+        
+        public void internalTrigger(NodeInstance from, String type) {
+            triggerCompleted();
+        }
+        
+        public void triggerCompleted() {
+            getNodeInstanceContainer().removeNodeInstance(this);
+            getNodeInstanceContainer().getNodeInstance( getCompositeNodeStart().getTo().getTo() ).trigger( this, getCompositeNodeStart().getTo().getToType());
+        }
+        
+    }
+
+    public class CompositeNodeEndInstance extends NodeInstanceImpl {
+
+        private static final long serialVersionUID = 400L;
+
+        public CompositeNode.CompositeNodeEnd getCompositeNodeEnd() {
+            return (CompositeNode.CompositeNodeEnd) getNode();
+        }
+        
+        public void internalTrigger(NodeInstance from, String type) {
+            triggerCompleted();
+        }
+        
+        public void triggerCompleted() {
+            getNodeInstanceContainer().removeNodeInstance(this);
+            CompositeNodeInstance.this.triggerCompleted(
+                getCompositeNodeEnd().getOutType());
+        }
+        
+    }
+
+}
\ No newline at end of file

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/EndNodeInstance.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/EndNodeInstance.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/EndNodeInstance.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,42 @@
+package org.drools.workflow.instance.node;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.process.instance.ProcessInstance;
+import org.drools.workflow.core.Node;
+import org.drools.workflow.instance.NodeInstance;
+import org.drools.workflow.instance.impl.NodeInstanceImpl;
+
+/**
+ * Runtime counterpart of an end node.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class EndNodeInstance extends NodeInstanceImpl {
+
+    private static final long serialVersionUID = 400L;
+
+    public void internalTrigger(final NodeInstance from, String type) {
+        if (!Node.CONNECTION_DEFAULT_TYPE.equals(type)) {
+            throw new IllegalArgumentException(
+                "An EndNode only accepts default incoming connections!");
+        }
+        getNodeInstanceContainer().removeNodeInstance(this);
+        getProcessInstance().setState( ProcessInstance.STATE_COMPLETED );
+    }
+
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/JoinInstance.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/JoinInstance.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/JoinInstance.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,121 @@
+package org.drools.workflow.instance.node;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.drools.workflow.core.Connection;
+import org.drools.workflow.core.Node;
+import org.drools.workflow.core.node.Join;
+import org.drools.workflow.instance.NodeInstance;
+import org.drools.workflow.instance.impl.NodeInstanceImpl;
+
+/**
+ * Runtime counterpart of a join node.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class JoinInstance extends NodeInstanceImpl {
+
+    private static final long serialVersionUID = 400L;
+    
+    private final Map<Node, Integer> triggers = new HashMap<Node, Integer>();
+    
+    protected Join getJoin() {
+        return (Join) getNode();
+    }
+
+    public void internalTrigger(final NodeInstance from, String type) {
+        if (!Node.CONNECTION_DEFAULT_TYPE.equals(type)) {
+            throw new IllegalArgumentException(
+                "An ActionNode only accepts default incoming connections!");
+        }
+        final Join join = getJoin();
+        switch ( join.getType() ) {
+            case Join.TYPE_XOR :
+                triggerCompleted();
+                break;
+            case Join.TYPE_AND :
+                Node node = getNodeInstanceContainer().getNodeContainer().getNode( from.getNodeId() );
+                Integer count = (Integer) this.triggers.get( node );
+                if ( count == null ) {
+                    this.triggers.put( node,
+                                       new Integer( 1 ) );
+                } else {
+                    this.triggers.put( node,
+                                       new Integer( count.intValue() + 1 ) );
+                }
+                if (checkAllActivated()) {
+                    decreaseAllTriggers();
+                    triggerCompleted();
+                }
+                break;
+            case Join.TYPE_DISCRIMINATOR :
+                boolean triggerCompleted = triggers.isEmpty();
+                node = getNodeInstanceContainer().getNodeContainer().getNode( from.getNodeId() );
+                triggers.put( node, new Integer( 1 ) );
+                if (checkAllActivated()) {
+                    resetAllTriggers();
+                }
+                if (triggerCompleted) {
+                    triggerCompleted();
+                }
+                break;
+            default :
+                throw new IllegalArgumentException( "Illegal join type " + join.getType() );
+        }
+    }
+
+    private boolean checkAllActivated() {
+        // check whether all parent nodes have been triggered 
+        for ( final Iterator<Connection> it = getJoin().getDefaultIncomingConnections().iterator(); it.hasNext(); ) {
+            final Connection connection = it.next();
+            if ( this.triggers.get( connection.getFrom() ) == null ) {
+                return false;
+            }
+        }
+        return true;
+    }
+    
+    private void decreaseAllTriggers() {
+        // decrease trigger count for all incoming connections
+        for ( final Iterator<Connection> it = getJoin().getDefaultIncomingConnections().iterator(); it.hasNext(); ) {
+            final Connection connection = it.next();
+            final Integer count = (Integer) this.triggers.get( connection.getFrom() );
+            if ( count.intValue() == 1 ) {
+                this.triggers.remove( connection.getFrom() );
+            } else {
+                this.triggers.put( connection.getFrom(),
+                                   new Integer( count.intValue() - 1 ) );
+            }
+        }
+    }
+
+    private void resetAllTriggers() {
+        triggers.clear();
+    }
+
+    public void triggerCompleted() {
+        // join nodes are only removed from the container when they contain no more state
+        if (triggers.isEmpty()) {
+            getNodeInstanceContainer().removeNodeInstance(this);
+        }
+        getNodeInstanceContainer().getNodeInstance( getJoin().getTo().getTo() ).trigger( this, getJoin().getTo().getToType() );
+    }
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/MilestoneNodeInstance.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/MilestoneNodeInstance.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/MilestoneNodeInstance.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,115 @@
+package org.drools.workflow.instance.node;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.Iterator;
+
+import org.drools.WorkingMemory;
+import org.drools.common.RuleFlowGroupNode;
+import org.drools.event.ActivationCancelledEvent;
+import org.drools.event.ActivationCreatedEvent;
+import org.drools.event.AfterActivationFiredEvent;
+import org.drools.event.AgendaEventListener;
+import org.drools.event.AgendaGroupPoppedEvent;
+import org.drools.event.AgendaGroupPushedEvent;
+import org.drools.event.BeforeActivationFiredEvent;
+import org.drools.spi.Activation;
+import org.drools.spi.RuleFlowGroup;
+import org.drools.workflow.core.Node;
+import org.drools.workflow.core.node.MilestoneNode;
+import org.drools.workflow.instance.NodeInstance;
+import org.drools.workflow.instance.impl.NodeInstanceImpl;
+
+/**
+ * Runtime counterpart of a milestone node.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class MilestoneNodeInstance extends NodeInstanceImpl implements AgendaEventListener {
+
+    private static final long serialVersionUID = 400L;
+
+    protected MilestoneNode getMilestoneNode() {
+        return (MilestoneNode) getNode();
+    }
+
+    public void internalTrigger(final NodeInstance from, String type) {
+        if (!Node.CONNECTION_DEFAULT_TYPE.equals(type)) {
+            throw new IllegalArgumentException(
+                "A MilestoneNode only accepts default incoming connections!");
+        }
+    	RuleFlowGroup systemRuleFlowGroup = getProcessInstance().getAgenda().getRuleFlowGroup("DROOLS_SYSTEM");
+    	String rule = "RuleFlow-Milestone-" + getProcessInstance().getProcess().getId()
+    		+ "-" + getNode().getId();
+    	for (Iterator activations = systemRuleFlowGroup.iterator(); activations.hasNext(); ) {
+    		Activation activation = ((RuleFlowGroupNode) activations.next()).getActivation();
+    		if (rule.equals(activation.getRule().getName())) {
+    			triggerCompleted();
+        		return;
+    		}
+    	}
+    	getProcessInstance().getWorkingMemory().addEventListener(this);
+    }
+
+    public void triggerCompleted() {
+        getNodeInstanceContainer().removeNodeInstance(this);
+        getNodeInstanceContainer().getNodeInstance(getMilestoneNode().getTo().getTo())
+            .trigger(this, getMilestoneNode().getTo().getToType());
+    }
+
+    public void activationCancelled(ActivationCancelledEvent event,
+            WorkingMemory workingMemory) {
+        // Do nothing
+    }
+
+    public void activationCreated(ActivationCreatedEvent event,
+            WorkingMemory workingMemory) {
+        // check whether this activation is from the DROOLS_SYSTEM agenda group
+        String ruleFlowGroup = event.getActivation().getRule().getRuleFlowGroup();
+        if ("DROOLS_SYSTEM".equals(ruleFlowGroup)) {
+            // new activations of the rule associate with a milestone node
+            // trigger node instances of that milestone node
+            String ruleName = event.getActivation().getRule().getName();
+            String milestoneName = "RuleFlow-Milestone-" + getProcessInstance().getProcess().getId() + "-" + getNodeId();
+            if (milestoneName.equals(ruleName)) {
+                getProcessInstance().getWorkingMemory().removeEventListener(this);
+                triggerCompleted();
+            }
+        }
+    }
+
+    public void afterActivationFired(AfterActivationFiredEvent event,
+            WorkingMemory workingMemory) {
+        // Do nothing
+    }
+
+    public void agendaGroupPopped(AgendaGroupPoppedEvent event,
+            WorkingMemory workingMemory) {
+        // Do nothing
+    }
+
+    public void agendaGroupPushed(AgendaGroupPushedEvent event,
+            WorkingMemory workingMemory) {
+        // Do nothing
+    }
+
+    public void beforeActivationFired(BeforeActivationFiredEvent event,
+            WorkingMemory workingMemory) {
+        // Do nothing
+    }
+
+}
\ No newline at end of file

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/RuleSetNodeInstance.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/RuleSetNodeInstance.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/RuleSetNodeInstance.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,71 @@
+package org.drools.workflow.instance.node;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.common.InternalRuleFlowGroup;
+import org.drools.common.RuleFlowGroupListener;
+import org.drools.workflow.core.Node;
+import org.drools.workflow.core.node.RuleSetNode;
+import org.drools.workflow.instance.NodeInstance;
+import org.drools.workflow.instance.impl.NodeInstanceImpl;
+
+/**
+ * Runtime counterpart of a ruleset node.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class RuleSetNodeInstance extends NodeInstanceImpl implements RuleFlowGroupListener {
+
+    private static final long serialVersionUID = 400L;
+    
+    private InternalRuleFlowGroup ruleFlowGroup;
+
+    public RuleSetNodeInstance() {
+    }
+    
+    protected RuleSetNode getRuleSetNode() {
+        return (RuleSetNode) getNode();
+    }
+
+    public void internalTrigger(final NodeInstance from, String type) {
+        ruleFlowGroup = (InternalRuleFlowGroup)
+        getProcessInstance().getWorkingMemory().getAgenda()
+            .getRuleFlowGroup(getRuleSetNode().getRuleFlowGroup());
+        ruleFlowGroup.addRuleFlowGroupListener(this);
+        if (!Node.CONNECTION_DEFAULT_TYPE.equals(type)) {
+            throw new IllegalArgumentException(
+                "A RuleSetNode only accepts default incoming connections!");
+        }
+        getProcessInstance().getAgenda().activateRuleFlowGroup( getRuleSetNode().getRuleFlowGroup() );
+    }
+
+    public void triggerCompleted() {
+        getNodeInstanceContainer().removeNodeInstance(this);
+        getNodeInstanceContainer().getNodeInstance( getRuleSetNode().getTo().getTo() ).trigger( this, getRuleSetNode().getTo().getToType() );
+    }
+    
+    public void cancel() {
+    	getProcessInstance().getAgenda().deactivateRuleFlowGroup( getRuleSetNode().getRuleFlowGroup() );
+    	super.cancel();
+    }
+
+    public void ruleFlowGroupDeactivated() {
+        ruleFlowGroup.removeRuleFlowGroupListener(this);
+        triggerCompleted();
+    }
+
+}
\ No newline at end of file

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/SplitInstance.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/SplitInstance.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/SplitInstance.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,118 @@
+package org.drools.workflow.instance.node;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.drools.workflow.core.Connection;
+import org.drools.workflow.core.Node;
+import org.drools.workflow.core.node.Split;
+import org.drools.workflow.instance.NodeInstance;
+import org.drools.workflow.instance.impl.ConstraintEvaluator;
+import org.drools.workflow.instance.impl.NodeInstanceImpl;
+
+/**
+ * Runtime counterpart of a split node.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class SplitInstance extends NodeInstanceImpl {
+
+    private static final long serialVersionUID = 400L;
+
+    protected Split getSplit() {
+        return (Split) getNode();
+    }
+
+    public void internalTrigger(final NodeInstance from, String type) {
+        if (!Node.CONNECTION_DEFAULT_TYPE.equals(type)) {
+            throw new IllegalArgumentException(
+                "A Split only accepts default incoming connections!");
+        }
+        final Split split = getSplit();
+        // TODO make different strategies for each type
+        switch ( split.getType() ) {
+            case Split.TYPE_AND :
+                getNodeInstanceContainer().removeNodeInstance(this);
+                List<Connection> outgoing = split.getDefaultOutgoingConnections();
+                for ( final Iterator<Connection> iterator = outgoing.iterator(); iterator.hasNext(); ) {
+                    final Connection connection = (Connection) iterator.next();
+                    getNodeInstanceContainer().getNodeInstance(connection.getTo()).trigger(this, connection.getToType());
+                }
+                break;
+            case Split.TYPE_XOR :
+                outgoing = split.getDefaultOutgoingConnections();
+                int priority = Integer.MAX_VALUE;
+                Connection selected = null;
+                for ( final Iterator<Connection> iterator = outgoing.iterator(); iterator.hasNext(); ) {
+                    final Connection connection = (Connection) iterator.next();
+                    ConstraintEvaluator constraint = (ConstraintEvaluator) split.getConstraint( connection );
+                    if ( constraint != null && constraint.getPriority() < priority ) {
+                        if ( constraint.evaluate( this,
+                                                  connection,
+                                                  constraint ) ) {
+                            selected = connection;
+                            priority = constraint.getPriority();
+                            break;
+                        }
+                    }
+                }
+                getNodeInstanceContainer().removeNodeInstance(this);
+                if ( selected == null ) {
+                    throw new IllegalArgumentException( "XOR split could not find at least one valid outgoing connection for split " + getSplit().getName() );
+                }
+                getNodeInstanceContainer().getNodeInstance( selected.getTo() ).trigger( this, selected.getToType() );
+                break;
+            case Split.TYPE_OR :
+                getNodeInstanceContainer().removeNodeInstance(this);
+                outgoing = split.getDefaultOutgoingConnections();
+                boolean found = false;
+                List<Connection> outgoingCopy = new ArrayList<Connection>(outgoing);
+                while (!outgoingCopy.isEmpty()) {
+                    priority = Integer.MAX_VALUE;
+                    Connection selectedConnection = null;
+                    ConstraintEvaluator selectedConstraint = null;
+                    for ( final Iterator<Connection> iterator = outgoingCopy.iterator(); iterator.hasNext(); ) {
+                        final Connection connection = (Connection) iterator.next();
+                        ConstraintEvaluator constraint = (ConstraintEvaluator) split.getConstraint( connection );
+    
+                        if ( constraint != null  
+                                && constraint.getPriority() < priority ) {
+                            priority = constraint.getPriority();
+                            selectedConnection = connection;
+                            selectedConstraint = constraint;
+                        }
+                    }
+                    if (selectedConstraint.evaluate( this,
+                                                     selectedConnection,
+                                                     selectedConstraint ) ) {
+                            getNodeInstanceContainer().getNodeInstance(selectedConnection.getTo()).trigger(this, selectedConnection.getToType());
+                            found = true;
+                    }
+                    outgoingCopy.remove(selectedConnection);
+                }
+                if ( !found ) {
+                    throw new IllegalArgumentException( "OR split could not find at least one valid outgoing connection for split " + getSplit().getName() );
+                }                
+                break;
+            default :
+                throw new IllegalArgumentException( "Illegal split type " + split.getType() );
+        }
+    }
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/StartNodeInstance.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/StartNodeInstance.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/StartNodeInstance.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,54 @@
+package org.drools.workflow.instance.node;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.workflow.core.node.StartNode;
+import org.drools.workflow.instance.NodeInstance;
+import org.drools.workflow.instance.impl.NodeInstanceImpl;
+
+/**
+ * Runtime counterpart of a start node.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class StartNodeInstance extends NodeInstanceImpl {
+
+    private static final long serialVersionUID = 400L;
+
+    public void internalTrigger(final NodeInstance from, String type) {
+        if (type != null) {
+            throw new IllegalArgumentException(
+                "A StartNode does not accept incoming connections!");
+        }
+        if (from != null) {
+            throw new IllegalArgumentException(
+                "A StartNode can only be triggered by the process itself!");
+        }
+        triggerCompleted();
+    }
+    
+    public StartNode getStartNode() {
+        return (StartNode) getNode();
+    }
+
+    public void triggerCompleted() {
+        getNodeInstanceContainer().removeNodeInstance(this);
+        getNodeInstanceContainer().getNodeInstance(getStartNode().getTo().getTo())
+            .trigger(this, getStartNode().getTo().getToType());
+    }
+    
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/SubProcessNodeInstance.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/SubProcessNodeInstance.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/SubProcessNodeInstance.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,126 @@
+package org.drools.workflow.instance.node;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.WorkingMemory;
+import org.drools.event.RuleFlowCompletedEvent;
+import org.drools.event.RuleFlowEventListener;
+import org.drools.event.RuleFlowGroupActivatedEvent;
+import org.drools.event.RuleFlowGroupDeactivatedEvent;
+import org.drools.event.RuleFlowNodeTriggeredEvent;
+import org.drools.event.RuleFlowStartedEvent;
+import org.drools.process.instance.ProcessInstance;
+import org.drools.workflow.core.Node;
+import org.drools.workflow.core.node.SubProcessNode;
+import org.drools.workflow.instance.NodeInstance;
+import org.drools.workflow.instance.impl.NodeInstanceImpl;
+
+/**
+ * Runtime counterpart of a SubFlow node.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class SubProcessNodeInstance extends NodeInstanceImpl implements RuleFlowEventListener {
+
+    private static final long serialVersionUID = 400L;
+    
+    private long processInstanceId;
+	
+    protected SubProcessNode getSubFlowNode() {
+        return (SubProcessNode) getNode();
+    }
+
+    public void internalTrigger(final NodeInstance from, String type) {
+        if (!Node.CONNECTION_DEFAULT_TYPE.equals(type)) {
+            throw new IllegalArgumentException(
+                "A SubProcess node only accepts default incoming connections!");
+        }
+    	ProcessInstance processInstance = 
+    		getProcessInstance().getWorkingMemory().startProcess(getSubFlowNode().getProcessId());
+    	if (!getSubFlowNode().isWaitForCompletion()
+    	        || processInstance.getState() == ProcessInstance.STATE_COMPLETED) {
+    		triggerCompleted();
+    	} else {
+    	    getProcessInstance().getWorkingMemory().addEventListener(this);
+    		this.processInstanceId = processInstance.getId();
+    	}
+    }
+    
+    public long getProcessInstanceId() {
+    	return processInstanceId;
+    }
+
+    public void triggerCompleted() {
+        getNodeInstanceContainer().removeNodeInstance(this);
+        getNodeInstanceContainer().getNodeInstance(getSubFlowNode().getTo().getTo())
+            .trigger(this, getSubFlowNode().getTo().getToType());
+    }
+
+    public void afterRuleFlowCompleted(RuleFlowCompletedEvent event,
+            WorkingMemory workingMemory) {
+        if ( event.getRuleFlowProcessInstance().getId() == processInstanceId ) {
+            getProcessInstance().getWorkingMemory().removeEventListener(this);
+            triggerCompleted();
+        }
+    }
+
+    public void afterRuleFlowGroupActivated(RuleFlowGroupActivatedEvent event,
+            WorkingMemory workingMemory) {
+        // Do nothing
+    }
+
+    public void afterRuleFlowGroupDeactivated(
+            RuleFlowGroupDeactivatedEvent event, WorkingMemory workingMemory) {
+        // Do nothing
+    }
+
+    public void afterRuleFlowNodeTriggered(RuleFlowNodeTriggeredEvent event,
+            WorkingMemory workingMemory) {
+        // Do nothing
+    }
+
+    public void afterRuleFlowStarted(RuleFlowStartedEvent event,
+            WorkingMemory workingMemory) {
+        // Do nothing
+    }
+
+    public void beforeRuleFlowCompleted(RuleFlowCompletedEvent event,
+            WorkingMemory workingMemory) {
+        // Do nothing
+    }
+
+    public void beforeRuleFlowGroupActivated(RuleFlowGroupActivatedEvent event,
+            WorkingMemory workingMemory) {
+        // Do nothing
+    }
+
+    public void beforeRuleFlowGroupDeactivated(
+            RuleFlowGroupDeactivatedEvent event, WorkingMemory workingMemory) {
+        // Do nothing
+    }
+
+    public void beforeRuleFlowNodeTriggered(RuleFlowNodeTriggeredEvent event,
+            WorkingMemory workingMemory) {
+        // Do nothing
+    }
+
+    public void beforeRuleFlowStarted(RuleFlowStartedEvent event,
+            WorkingMemory workingMemory) {
+        // Do nothing
+    }
+
+}
\ No newline at end of file

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/WorkItemNodeInstance.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/WorkItemNodeInstance.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/WorkItemNodeInstance.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,92 @@
+package org.drools.workflow.instance.node;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.Iterator;
+import java.util.Map;
+
+import org.drools.process.core.Work;
+import org.drools.process.instance.WorkItem;
+import org.drools.process.instance.WorkItemListener;
+import org.drools.process.instance.impl.WorkItemImpl;
+import org.drools.workflow.core.node.WorkItemNode;
+import org.drools.workflow.instance.NodeInstance;
+import org.drools.workflow.instance.impl.NodeInstanceImpl;
+
+/**
+ * Runtime counterpart of a task node.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class WorkItemNodeInstance extends NodeInstanceImpl implements WorkItemListener {
+
+    private static final long serialVersionUID = 400L;
+    
+    private WorkItemImpl workItem;
+    
+    protected WorkItemNode getWorkItemNode() {
+        return (WorkItemNode) getNode();
+    }
+    
+    public WorkItem getWorkItem() {
+        return workItem;
+    }
+
+    public void internalTrigger(final NodeInstance from, String type) {
+        // TODO this should be included for ruleflow only, not for BPEL
+//        if (!Node.CONNECTION_DEFAULT_TYPE.equals(type)) {
+//            throw new IllegalArgumentException(
+//                "A WorkItemNode only accepts default incoming connections!");
+//        }
+        WorkItemNode workItemNode = getWorkItemNode();
+        Work work = workItemNode.getWork();
+		workItem = new WorkItemImpl();
+		workItem.setName(work.getName());
+		workItem.setProcessInstanceId(getProcessInstance().getId());
+		workItem.setParameters(work.getParameters());
+		for (Iterator<Map.Entry<String, String>> iterator = workItemNode.getInMappings().entrySet().iterator(); iterator.hasNext(); ) {
+            Map.Entry<String, String> mapping = iterator.next();
+            workItem.setParameter(mapping.getKey(), getProcessInstance().getVariable(mapping.getValue()));
+        }
+		getProcessInstance().addWorkItemListener(this);
+		getProcessInstance().getWorkingMemory().getWorkItemManager().executeWorkItem(workItem);
+    }
+
+    public void triggerCompleted(WorkItem workItem) {
+        getNodeInstanceContainer().removeNodeInstance(this);
+        for (Iterator<Map.Entry<String, String>> iterator = getWorkItemNode().getOutMappings().entrySet().iterator(); iterator.hasNext(); ) {
+            Map.Entry<String, String> mapping = iterator.next();
+            getProcessInstance().setVariable(mapping.getValue(), workItem.getResult(mapping.getKey()));
+        }
+        getNodeInstanceContainer().getNodeInstance( getWorkItemNode().getTo().getTo() ).trigger( this, getWorkItemNode().getTo().getToType() );
+    }
+
+    public void workItemAborted(WorkItem workItem) {
+        if ( this.workItem.getId() == workItem.getId() ) {
+            getProcessInstance().removeWorkItemListener(this);
+            triggerCompleted(workItem);
+        }
+    }
+
+    public void workItemCompleted(WorkItem workItem) {
+        if ( this.workItem.getId() == workItem.getId() ) {
+            getProcessInstance().removeWorkItemListener(this);
+            triggerCompleted(workItem);
+        }
+    }
+
+}
\ No newline at end of file

Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/RuleFlowGroupTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/RuleFlowGroupTest.java	2008-01-09 01:25:51 UTC (rev 17636)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/RuleFlowGroupTest.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -20,7 +20,6 @@
 import java.util.List;
 
 import org.drools.DroolsTestCase;
-import org.drools.RuleBase;
 import org.drools.RuleBaseFactory;
 import org.drools.WorkingMemory;
 import org.drools.base.SalienceInteger;
@@ -28,30 +27,23 @@
 import org.drools.common.InternalAgenda;
 import org.drools.common.PropagationContextImpl;
 import org.drools.common.RuleFlowGroupImpl;
+import org.drools.process.instance.ProcessInstance;
 import org.drools.reteoo.builder.BuildContext;
 import org.drools.rule.Rule;
-import org.drools.ruleflow.common.instance.ProcessInstance;
-import org.drools.ruleflow.core.Connection;
-import org.drools.ruleflow.core.Constraint;
-import org.drools.ruleflow.core.EndNode;
-import org.drools.ruleflow.core.Join;
 import org.drools.ruleflow.core.RuleFlowProcess;
-import org.drools.ruleflow.core.RuleSetNode;
-import org.drools.ruleflow.core.Split;
-import org.drools.ruleflow.core.StartNode;
-import org.drools.ruleflow.core.impl.ConnectionImpl;
-import org.drools.ruleflow.core.impl.EndNodeImpl;
-import org.drools.ruleflow.core.impl.JoinImpl;
-import org.drools.ruleflow.core.impl.RuleFlowProcessImpl;
-import org.drools.ruleflow.core.impl.RuleSetNodeImpl;
-import org.drools.ruleflow.core.impl.SplitImpl;
-import org.drools.ruleflow.core.impl.StartNodeImpl;
 import org.drools.ruleflow.instance.RuleFlowProcessInstance;
-import org.drools.ruleflow.instance.impl.RuleFlowProcessInstanceImpl;
-import org.drools.ruleflow.nodes.split.ConstraintEvaluator;
 import org.drools.spi.Consequence;
 import org.drools.spi.KnowledgeHelper;
 import org.drools.spi.PropagationContext;
+import org.drools.workflow.core.Connection;
+import org.drools.workflow.core.Node;
+import org.drools.workflow.core.impl.ConnectionImpl;
+import org.drools.workflow.core.node.EndNode;
+import org.drools.workflow.core.node.Join;
+import org.drools.workflow.core.node.RuleSetNode;
+import org.drools.workflow.core.node.Split;
+import org.drools.workflow.core.node.StartNode;
+import org.drools.workflow.instance.impl.ConstraintEvaluator;
 
 /**
  * @author mproctor
@@ -135,48 +127,56 @@
                                                                         null );
 
         // nodes
-        final StartNode start = new StartNodeImpl();
-        final RuleSetNode ruleSet0 = new RuleSetNodeImpl();
+        final StartNode start = new StartNode();
+        final RuleSetNode ruleSet0 = new RuleSetNode();
         ruleSet0.setRuleFlowGroup( "rule-flow-group-0" );
-        final RuleSetNode ruleSet1 = new RuleSetNodeImpl();
+        final RuleSetNode ruleSet1 = new RuleSetNode();
         ruleSet1.setRuleFlowGroup( "rule-flow-group-1" );
-        final RuleSetNode ruleSet2 = new RuleSetNodeImpl();
+        final RuleSetNode ruleSet2 = new RuleSetNode();
         ruleSet2.setRuleFlowGroup( "rule-flow-group-2" );
-        final RuleSetNode ruleSet3 = new RuleSetNodeImpl();
+        final RuleSetNode ruleSet3 = new RuleSetNode();
         ruleSet3.setRuleFlowGroup( "rule-flow-group-3" );
-        final Split split = new SplitImpl();
+        final Split split = new Split();
         split.setType( Split.TYPE_AND );
-        final Join join = new JoinImpl();
+        final Join join = new Join();
         join.setType( Join.TYPE_AND );
-        final EndNode end = new EndNodeImpl();
+        final EndNode end = new EndNode();
         // connections
         new ConnectionImpl( start,
+                            Node.CONNECTION_DEFAULT_TYPE,
                             ruleSet0,
-                            Connection.TYPE_NORMAL );
+                            Node.CONNECTION_DEFAULT_TYPE);
         new ConnectionImpl( ruleSet0,
+                            Node.CONNECTION_DEFAULT_TYPE,
                             split,
-                            Connection.TYPE_NORMAL );
+                            Node.CONNECTION_DEFAULT_TYPE);
         new ConnectionImpl( split,
+                            Node.CONNECTION_DEFAULT_TYPE,
                             ruleSet1,
-                            Connection.TYPE_NORMAL );
+                            Node.CONNECTION_DEFAULT_TYPE);
         new ConnectionImpl( split,
+                            Node.CONNECTION_DEFAULT_TYPE,
                             ruleSet2,
-                            Connection.TYPE_NORMAL );
+                            Node.CONNECTION_DEFAULT_TYPE);
         new ConnectionImpl( ruleSet1,
+                            Node.CONNECTION_DEFAULT_TYPE,
                             join,
-                            Connection.TYPE_NORMAL );
+                            Node.CONNECTION_DEFAULT_TYPE);
         new ConnectionImpl( ruleSet2,
+                            Node.CONNECTION_DEFAULT_TYPE,
                             join,
-                            Connection.TYPE_NORMAL );
+                            Node.CONNECTION_DEFAULT_TYPE);
         new ConnectionImpl( join,
+                            Node.CONNECTION_DEFAULT_TYPE,
                             ruleSet3,
-                            Connection.TYPE_NORMAL );
+                            Node.CONNECTION_DEFAULT_TYPE);
         new ConnectionImpl( ruleSet3,
+                            Node.CONNECTION_DEFAULT_TYPE,
                             end,
-                            Connection.TYPE_NORMAL );
+                            Node.CONNECTION_DEFAULT_TYPE);
 
         // process
-        final RuleFlowProcess process = new RuleFlowProcessImpl();
+        final RuleFlowProcess process = new RuleFlowProcess();
         process.addNode( start );
         process.addNode( ruleSet0 );
         process.addNode( ruleSet1 );
@@ -187,7 +187,7 @@
         process.addNode( end );
 
         // proces instance
-        final RuleFlowProcessInstance processInstance = new RuleFlowProcessInstanceImpl();
+        final RuleFlowProcessInstance processInstance = new RuleFlowProcessInstance();
         processInstance.setWorkingMemory( workingMemory );
         processInstance.setProcess( process );
         assertEquals( ProcessInstance.STATE_PENDING,
@@ -379,56 +379,64 @@
                                                                         null );
 
         // nodes
-        final StartNode start = new StartNodeImpl();
-        final RuleSetNode ruleSet0 = new RuleSetNodeImpl();
+        final StartNode start = new StartNode();
+        final RuleSetNode ruleSet0 = new RuleSetNode();
         ruleSet0.setRuleFlowGroup( "rule-flow-group-0" );
-        final RuleSetNode ruleSet1 = new RuleSetNodeImpl();
+        final RuleSetNode ruleSet1 = new RuleSetNode();
         ruleSet1.setRuleFlowGroup( "rule-flow-group-1" );
-        final RuleSetNode ruleSet2 = new RuleSetNodeImpl();
+        final RuleSetNode ruleSet2 = new RuleSetNode();
         ruleSet2.setRuleFlowGroup( "rule-flow-group-2" );
-        final RuleSetNode ruleSet3 = new RuleSetNodeImpl();
+        final RuleSetNode ruleSet3 = new RuleSetNode();
         ruleSet3.setRuleFlowGroup( "rule-flow-group-3" );
-        final Split split = new SplitImpl();
+        final Split split = new Split();
         split.setType( Split.TYPE_XOR );
-        final Join join = new JoinImpl();
+        final Join join = new Join();
         join.setType( Join.TYPE_XOR );
-        final EndNode end = new EndNodeImpl();
+        final EndNode end = new EndNode();
         // connections
         new ConnectionImpl( start,
+                            Node.CONNECTION_DEFAULT_TYPE,
                             ruleSet0,
-                            Connection.TYPE_NORMAL );
+                            Node.CONNECTION_DEFAULT_TYPE);
         new ConnectionImpl( ruleSet0,
+                            Node.CONNECTION_DEFAULT_TYPE,
                             split,
-                            Connection.TYPE_NORMAL );
+                            Node.CONNECTION_DEFAULT_TYPE);
         Connection out1 = new ConnectionImpl( split,
+                                              Node.CONNECTION_DEFAULT_TYPE,
                                               ruleSet1,
-                                              Connection.TYPE_NORMAL );
+                                              Node.CONNECTION_DEFAULT_TYPE);
         Connection out2 = new ConnectionImpl( split,
+                                              Node.CONNECTION_DEFAULT_TYPE,
                                               ruleSet2,
-                                              Connection.TYPE_NORMAL );
+                                              Node.CONNECTION_DEFAULT_TYPE);
         new ConnectionImpl( ruleSet1,
+                            Node.CONNECTION_DEFAULT_TYPE,
                             join,
-                            Connection.TYPE_NORMAL );
+                            Node.CONNECTION_DEFAULT_TYPE);
         new ConnectionImpl( ruleSet2,
+                            Node.CONNECTION_DEFAULT_TYPE,
                             join,
-                            Connection.TYPE_NORMAL );
+                            Node.CONNECTION_DEFAULT_TYPE);
         new ConnectionImpl( join,
+                            Node.CONNECTION_DEFAULT_TYPE,
                             ruleSet3,
-                            Connection.TYPE_NORMAL );
+                            Node.CONNECTION_DEFAULT_TYPE);
         new ConnectionImpl( ruleSet3,
+                            Node.CONNECTION_DEFAULT_TYPE,
                             end,
-                            Connection.TYPE_NORMAL );
-        ConstraintEvaluator constraint1 = new org.drools.ruleflow.core.impl.RuleFlowConstraintEvaluator();
+                            Node.CONNECTION_DEFAULT_TYPE);
+        ConstraintEvaluator constraint1 = new org.drools.workflow.instance.impl.RuleConstraintEvaluator();
         constraint1.setPriority( 1 );
         split.setConstraint( out1,
                              constraint1 );
-        ConstraintEvaluator constraint2 = new org.drools.ruleflow.core.impl.RuleFlowConstraintEvaluator();
+        ConstraintEvaluator constraint2 = new org.drools.workflow.instance.impl.RuleConstraintEvaluator();
         constraint2.setPriority( 2 );
         split.setConstraint( out2,
                              constraint2 );
 
         // process
-        final RuleFlowProcess process = new RuleFlowProcessImpl();
+        final RuleFlowProcess process = new RuleFlowProcess();
         process.setId( "1" );
         process.addNode( start );
         process.addNode( ruleSet0 );
@@ -461,7 +469,7 @@
                                                                   buildContext );
 
         // proces instance
-        final RuleFlowProcessInstance processInstance = new RuleFlowProcessInstanceImpl();
+        final RuleFlowProcessInstance processInstance = new RuleFlowProcessInstance();
         processInstance.setWorkingMemory( workingMemory );
         processInstance.setProcess( process );
         assertEquals( ProcessInstance.STATE_PENDING,

Copied: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance (from rev 17570, labs/jbossrules/trunk/drools-core/src/test/java/org/drools/ruleflow/instance/impl)

Deleted: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/EndNodeInstanceImplTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/ruleflow/instance/impl/EndNodeInstanceImplTest.java	2008-01-05 14:13:22 UTC (rev 17570)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/EndNodeInstanceImplTest.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,57 +0,0 @@
-package org.drools.ruleflow.instance.impl;
-
-
-import org.drools.RuleBase;
-import org.drools.RuleBaseConfiguration;
-import org.drools.RuleBaseFactory;
-import org.drools.StatefulSession;
-import org.drools.common.InternalWorkingMemory;
-import org.drools.ruleflow.common.core.impl.ProcessImpl;
-import org.drools.ruleflow.common.instance.ProcessInstance;
-import org.drools.ruleflow.core.Connection;
-import org.drools.ruleflow.core.Node;
-import org.drools.ruleflow.core.impl.ConnectionImpl;
-import org.drools.ruleflow.core.impl.EndNodeImpl;
-import org.drools.ruleflow.core.impl.NodeImpl;
-import org.drools.ruleflow.core.impl.RuleFlowProcessImpl;
-import org.drools.ruleflow.core.impl.StartNodeImpl;
-
-import junit.framework.TestCase;
-
-public class EndNodeInstanceImplTest extends TestCase {
-    public void testStartNode() {
-        RuleBaseConfiguration conf = new RuleBaseConfiguration();
-        
-        RuleBase ruleBase = RuleBaseFactory.newRuleBase( conf );
-        StatefulSession session = ruleBase.newStatefulSession();        
-        
-        NodeImpl mockNode = new NodeImpl()  { };        
-        MockNodeInstanceFactory factory = new MockNodeInstanceFactory( new MockNodeInstance( mockNode ) );
-        conf.getProcessNodeInstanceFactoryRegistry().register(  mockNode.getClass(), factory );
-        
-        RuleFlowProcessImpl process = new RuleFlowProcessImpl(); 
-        
-        Node endNode = new  EndNodeImpl();  
-        endNode.setId( 1 );
-        endNode.setName( "end node" );        
-                            
-        mockNode.setId( 2 );
-        new ConnectionImpl(mockNode, endNode, Connection.TYPE_NORMAL);
-        
-        process.addNode( mockNode );
-        process.addNode( endNode );
-                
-        RuleFlowProcessInstanceImpl processInstance = new RuleFlowProcessInstanceImpl();   
-        processInstance.setState( ProcessInstance.STATE_ACTIVE );
-        processInstance.setProcess( process );
-        processInstance.setWorkingMemory( (InternalWorkingMemory) session );
-        
-        
-
-        
-        MockNodeInstance mockNodeInstance = ( MockNodeInstance ) processInstance.getNodeInstance( mockNode );
-        
-        mockNodeInstance.trigger( null );
-        assertEquals( ProcessInstance.STATE_COMPLETED, processInstance.getState() );                               
-    }
-}

Deleted: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/MockEndNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/ruleflow/instance/impl/MockEndNode.java	2008-01-05 14:13:22 UTC (rev 17570)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/MockEndNode.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,9 +0,0 @@
-package org.drools.ruleflow.instance.impl;
-
-import org.drools.ruleflow.core.impl.NodeImpl;
-
-public class MockEndNode extends NodeImpl {
-    public MockEndNode() {
-        
-    }
-}

Deleted: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/MockEndNodeInstance.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/ruleflow/instance/impl/MockEndNodeInstance.java	2008-01-05 14:13:22 UTC (rev 17570)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/MockEndNodeInstance.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,51 +0,0 @@
-/**
- * 
- */
-package org.drools.ruleflow.instance.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.drools.ruleflow.core.impl.ConnectionImpl;
-import org.drools.ruleflow.core.impl.NodeImpl;
-import org.drools.ruleflow.instance.RuleFlowNodeInstance;
-
-public class MockEndNodeInstance extends RuleFlowNodeInstanceImpl {
-    private List list = new ArrayList();
-    
-    private NodeImpl node;
-    
-    public MockEndNodeInstance(NodeImpl node) {
-        this.node = node;
-    }
-    
-    public NodeImpl getNode() {
-        return this.node;
-    }
-    
-    public void internalTrigger(RuleFlowNodeInstance from) {
-        this.list.add( from );    
-        triggerCompleted();
-    }
-    
-    public List getList() {
-        return this.list;
-    }      
-    
-    public int hashCode() {
-        return (int) this.node.getId();
-    }
-    
-    public boolean equals(Object object) {
-        if ( object == null || (!( object instanceof MockEndNodeInstance ) )) {
-            return false;
-        }
-        
-        MockEndNodeInstance other = ( MockEndNodeInstance ) object;
-        return getNode().getId() == other.getNode().getId();
-    }        
-    
-    public void triggerCompleted() {        
-        getProcessInstance().removeNodeInstance(this);
-    }
-}
\ No newline at end of file

Deleted: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/MockEndNodeInstanceFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/ruleflow/instance/impl/MockEndNodeInstanceFactory.java	2008-01-05 14:13:22 UTC (rev 17570)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/MockEndNodeInstanceFactory.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,26 +0,0 @@
-/**
- * 
- */
-package org.drools.ruleflow.instance.impl;
-
-import org.drools.ruleflow.core.Node;
-import org.drools.ruleflow.instance.RuleFlowNodeInstance;
-
-public class MockEndNodeInstanceFactory implements ProcessNodeInstanceFactory {
-    private MockEndNodeInstance instance;
-    
-    public MockEndNodeInstanceFactory(MockEndNodeInstance instance) {
-        this.instance = instance;
-    }
-    
-    public MockEndNodeInstance getMockEndNodeInstance() {
-        return this.instance;
-    }
-
-    public RuleFlowNodeInstance getNodeInstance(Node node,
-                                                RuleFlowProcessInstanceImpl processInstance) {
-        this.instance.setNodeId( node.getId() );
-        processInstance.addNodeInstance( this.instance );            
-        return instance;
-    }        
-}
\ No newline at end of file

Deleted: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/MockNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/ruleflow/instance/impl/MockNode.java	2008-01-05 14:13:22 UTC (rev 17570)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/MockNode.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,9 +0,0 @@
-package org.drools.ruleflow.instance.impl;
-
-import org.drools.ruleflow.core.impl.NodeImpl;
-
-public class MockNode extends NodeImpl {
-    public MockNode() {
-        
-    }
-}

Deleted: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/MockNodeInstance.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/ruleflow/instance/impl/MockNodeInstance.java	2008-01-05 14:13:22 UTC (rev 17570)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/MockNodeInstance.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,52 +0,0 @@
-/**
- * 
- */
-package org.drools.ruleflow.instance.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.drools.ruleflow.core.impl.ConnectionImpl;
-import org.drools.ruleflow.core.impl.NodeImpl;
-import org.drools.ruleflow.instance.RuleFlowNodeInstance;
-
-public class MockNodeInstance extends RuleFlowNodeInstanceImpl {
-    private List list = new ArrayList();
-    
-    private NodeImpl node;
-    
-    public MockNodeInstance(NodeImpl node) {
-        this.node = node;
-    }
-    
-    public NodeImpl getNode() {
-        return this.node;
-    }
-    
-    public void internalTrigger(RuleFlowNodeInstance from) {
-        this.list.add( from );    
-        triggerCompleted();
-    }
-    
-    public List getList() {
-        return this.list;
-    }      
-    
-    public int hashCode() {
-        return (int) this.node.getId();
-    }
-    
-    public boolean equals(Object object) {
-        if ( object == null || (!( object instanceof MockNodeInstance ) )) {
-            return false;
-        }
-        
-        MockNodeInstance other = ( MockNodeInstance ) object;
-        return getNode().getId() == other.getNode().getId();
-    }        
-    
-    public void triggerCompleted() {        
-        getProcessInstance().removeNodeInstance(this);
-        getProcessInstance().getNodeInstance( ((ConnectionImpl) this.node.getOutgoingConnections().get( 0 )).getTo() ).trigger( this );
-    }
-}
\ No newline at end of file

Deleted: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/MockNodeInstanceFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/ruleflow/instance/impl/MockNodeInstanceFactory.java	2008-01-05 14:13:22 UTC (rev 17570)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/MockNodeInstanceFactory.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,26 +0,0 @@
-/**
- * 
- */
-package org.drools.ruleflow.instance.impl;
-
-import org.drools.ruleflow.core.Node;
-import org.drools.ruleflow.instance.RuleFlowNodeInstance;
-
-public class MockNodeInstanceFactory implements ProcessNodeInstanceFactory {
-    private MockNodeInstance instance;
-    
-    public MockNodeInstanceFactory(MockNodeInstance instance) {
-        this.instance = instance;
-    }
-    
-    public MockNodeInstance getMockNodeInstance() {
-        return this.instance;
-    }
-
-    public RuleFlowNodeInstance getNodeInstance(Node node,
-                                                RuleFlowProcessInstanceImpl processInstance) {
-        this.instance.setNodeId( node.getId() );
-        processInstance.addNodeInstance( this.instance );            
-        return instance;
-    }        
-}
\ No newline at end of file

Deleted: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/ProcessNodeInstanceFactoryTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/ruleflow/instance/impl/ProcessNodeInstanceFactoryTest.java	2008-01-05 14:13:22 UTC (rev 17570)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/ProcessNodeInstanceFactoryTest.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,32 +0,0 @@
-package org.drools.ruleflow.instance.impl;
-
-import java.util.Properties;
-
-import junit.framework.TestCase;
-
-import org.drools.RuleBaseConfiguration;
-import org.drools.ruleflow.core.Node;
-import org.drools.ruleflow.core.impl.ActionNodeImpl;
-import org.drools.ruleflow.instance.impl.factories.CreateNewNodeFactory;
-
-public class ProcessNodeInstanceFactoryTest extends TestCase {
-    
-    public void testDefaultEntries() throws Exception {
-        RuleBaseConfiguration conf = new RuleBaseConfiguration();
-        
-        ProcessNodeInstanceFactoryRegistry registry = conf.getProcessNodeInstanceFactoryRegistry();
-        Node node = new ActionNodeImpl();
-        assertEquals( CreateNewNodeFactory.class, registry.getRuleFlowNodeFactory( node ).getClass() );       
-    }
-    
-    public void testDiscoveredEntry() {
-        Properties properties = new Properties(); 
-        properties.put( "processNodeInstanceFactoryRegistry", "mockProcessNodeInstanceFactory.conf" );        
-        
-        RuleBaseConfiguration conf = new RuleBaseConfiguration( properties );
-        
-        ProcessNodeInstanceFactoryRegistry registry = conf.getProcessNodeInstanceFactoryRegistry();
-        
-        assertEquals( MockNodeInstanceFactory.class, registry.getRuleFlowNodeFactory( new MockNode() ).getClass() );
-    }
-}

Deleted: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/StartNodeInstanceImplTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/ruleflow/instance/impl/StartNodeInstanceImplTest.java	2008-01-05 14:13:22 UTC (rev 17570)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/StartNodeInstanceImplTest.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -1,64 +0,0 @@
-package org.drools.ruleflow.instance.impl;
-
-
-import org.drools.RuleBase;
-import org.drools.RuleBaseConfiguration;
-import org.drools.RuleBaseFactory;
-import org.drools.StatefulSession;
-import org.drools.common.InternalWorkingMemory;
-import org.drools.ruleflow.common.instance.ProcessInstance;
-import org.drools.ruleflow.core.Connection;
-import org.drools.ruleflow.core.Node;
-import org.drools.ruleflow.core.impl.ConnectionImpl;
-import org.drools.ruleflow.core.impl.EndNodeImpl;
-import org.drools.ruleflow.core.impl.NodeImpl;
-import org.drools.ruleflow.core.impl.RuleFlowProcessImpl;
-import org.drools.ruleflow.core.impl.StartNodeImpl;
-
-import junit.framework.TestCase;
-
-public class StartNodeInstanceImplTest extends TestCase {
-    public void testStartNode() {
-        RuleBaseConfiguration conf = new RuleBaseConfiguration();
-        
-        RuleBase ruleBase = RuleBaseFactory.newRuleBase( conf );
-        StatefulSession session = ruleBase.newStatefulSession();        
-        
-        MockNode mockNode = new MockNode();
-        MockNodeInstanceFactory mockNodeFactory = new MockNodeInstanceFactory( new MockNodeInstance( mockNode ) );
-        conf.getProcessNodeInstanceFactoryRegistry().register(  mockNode.getClass(), mockNodeFactory );
-        
-        MockEndNode mockEndNode = new MockEndNode();
-        MockEndNodeInstanceFactory mockEndNodeFactory = new MockEndNodeInstanceFactory( new MockEndNodeInstance( mockEndNode ) );        
-        conf.getProcessNodeInstanceFactoryRegistry().register(  mockEndNode.getClass(), mockEndNodeFactory );      
-        
-        RuleFlowProcessImpl process = new RuleFlowProcessImpl(); 
-        
-        Node startNode = new  StartNodeImpl();  
-        startNode.setId( 1 );
-        startNode.setName( "start node" );                
-                            
-        mockNode.setId( 2 );
-        mockEndNode.setId( 3 );
-        new ConnectionImpl(startNode, mockNode, Connection.TYPE_NORMAL);
-        new ConnectionImpl(mockNode, mockEndNode, Connection.TYPE_NORMAL);
-        
-        process.addNode( startNode );
-        process.addNode( mockNode );
-        process.addNode( mockEndNode );
-                
-        RuleFlowProcessInstanceImpl processInstance = new RuleFlowProcessInstanceImpl();   
-        processInstance.setProcess( process );
-        processInstance.setWorkingMemory( (InternalWorkingMemory) session );              
-        
-        assertEquals(  ProcessInstance.STATE_PENDING, processInstance.getState() );
-        processInstance.start();        
-        assertEquals(  ProcessInstance.STATE_ACTIVE, processInstance.getState() );
-        
-        MockNodeInstance mockNodeInstance = mockNodeFactory.getMockNodeInstance();
-        assertSame( startNode, ((RuleFlowNodeInstanceImpl) mockNodeInstance.getList().get( 0  )).getNode() );
-        
-        MockEndNodeInstance mockEndNodeInstance = mockEndNodeFactory.getMockEndNodeInstance();
-        assertSame( mockNode, ((RuleFlowNodeInstanceImpl) mockEndNodeInstance.getList().get( 0  )).getNode() );        
-    }
-}

Added: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/node/EndNodeInstanceTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/node/EndNodeInstanceTest.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/node/EndNodeInstanceTest.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,51 @@
+package org.drools.workflow.instance.node;
+
+
+import junit.framework.TestCase;
+
+import org.drools.RuleBase;
+import org.drools.RuleBaseConfiguration;
+import org.drools.RuleBaseFactory;
+import org.drools.StatefulSession;
+import org.drools.common.InternalWorkingMemory;
+import org.drools.process.instance.ProcessInstance;
+import org.drools.ruleflow.instance.RuleFlowProcessInstance;
+import org.drools.workflow.core.Node;
+import org.drools.workflow.core.impl.ConnectionImpl;
+import org.drools.workflow.core.impl.WorkflowProcessImpl;
+import org.drools.workflow.core.node.EndNode;
+
+public class EndNodeInstanceTest extends TestCase {
+    
+    public void testEndNode() {
+        RuleBaseConfiguration conf = new RuleBaseConfiguration();
+        RuleBase ruleBase = RuleBaseFactory.newRuleBase( conf );
+        StatefulSession session = ruleBase.newStatefulSession();        
+        
+        MockNode mockNode = new MockNode();        
+        MockNodeInstanceFactory factory = new MockNodeInstanceFactory( new MockNodeInstance( mockNode ) );
+        conf.getProcessNodeInstanceFactoryRegistry().register(  mockNode.getClass(), factory );
+        
+        WorkflowProcessImpl process = new WorkflowProcessImpl(); 
+        
+        Node endNode = new EndNode();  
+        endNode.setId( 1 );
+        endNode.setName( "end node" );        
+                            
+        mockNode.setId( 2 );
+        new ConnectionImpl(mockNode, Node.CONNECTION_DEFAULT_TYPE, endNode, Node.CONNECTION_DEFAULT_TYPE);
+        
+        process.addNode( mockNode );
+        process.addNode( endNode );
+                
+        RuleFlowProcessInstance processInstance = new RuleFlowProcessInstance();   
+        processInstance.setState( ProcessInstance.STATE_ACTIVE );
+        processInstance.setProcess( process );
+        processInstance.setWorkingMemory( (InternalWorkingMemory) session );
+        
+        MockNodeInstance mockNodeInstance = ( MockNodeInstance ) processInstance.getNodeInstance( mockNode );
+        
+        mockNodeInstance.triggerCompleted();
+        assertEquals( ProcessInstance.STATE_COMPLETED, processInstance.getState() );                               
+    }
+}

Added: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/node/MockNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/node/MockNode.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/node/MockNode.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,9 @@
+package org.drools.workflow.instance.node;
+
+import org.drools.workflow.core.node.SequenceNode;
+
+public class MockNode extends SequenceNode {
+
+    private static final long serialVersionUID = 400L;
+
+}

Added: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/node/MockNodeInstance.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/node/MockNodeInstance.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/node/MockNodeInstance.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,67 @@
+/**
+ * 
+ */
+package org.drools.workflow.instance.node;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.drools.workflow.core.Node;
+import org.drools.workflow.instance.NodeInstance;
+import org.drools.workflow.instance.impl.NodeInstanceImpl;
+
+public class MockNodeInstance extends NodeInstanceImpl {
+    
+    private static final long serialVersionUID = 400L;
+
+    private Map<String, List<NodeInstance>> triggers = new HashMap<String, List<NodeInstance>>();
+    private MockNode mockNode;
+    
+    public MockNodeInstance(MockNode mockNode) {
+        this.mockNode = mockNode;
+    }
+    
+    public Node getNode() {
+        return mockNode;
+    }
+    
+    public MockNode getMockNode() {
+        return mockNode;
+    }
+    
+    public void internalTrigger(NodeInstance from, String type) {
+        if (type == null) {
+            throw new IllegalArgumentException(
+                "Trigger type is null!");
+        }
+        List<NodeInstance> list = triggers.get(type);
+        if (list == null) {
+            list = new ArrayList<NodeInstance>();
+            triggers.put(type, list);
+        }
+        list.add(from);
+    }
+    
+    public Map<String, List<NodeInstance>> getTriggers() {
+        return triggers;
+    }      
+    
+    public int hashCode() {
+        return (int) getNodeId();
+    }
+    
+    public boolean equals(Object object) {
+        if ( object == null || (!( object instanceof MockNodeInstance ) )) {
+            return false;
+        }
+        MockNodeInstance other = ( MockNodeInstance ) object;
+        return getNodeId() == other.getNodeId();
+    }        
+    
+    public void triggerCompleted() {        
+        getNodeInstanceContainer().removeNodeInstance(this);
+        getNodeInstanceContainer().getNodeInstance(getMockNode().getTo().getTo()).trigger(this, getMockNode().getTo().getToType());
+    }
+}
\ No newline at end of file

Added: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/node/MockNodeInstanceFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/node/MockNodeInstanceFactory.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/node/MockNodeInstanceFactory.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,27 @@
+/**
+ * 
+ */
+package org.drools.workflow.instance.node;
+
+import org.drools.workflow.core.Node;
+import org.drools.workflow.instance.NodeInstance;
+import org.drools.workflow.instance.NodeInstanceContainer;
+import org.drools.workflow.instance.WorkflowProcessInstance;
+import org.drools.workflow.instance.impl.NodeInstanceFactory;
+
+public class MockNodeInstanceFactory implements NodeInstanceFactory {
+    
+    private MockNodeInstance instance;
+    
+    public MockNodeInstanceFactory(MockNodeInstance instance) {
+        this.instance = instance;
+    }
+    
+    public MockNodeInstance getMockNodeInstance() {
+        return this.instance;
+    }
+
+    public NodeInstance getNodeInstance(Node node, WorkflowProcessInstance processInstance, NodeInstanceContainer nodeInstanceContainer) {
+        return instance;
+    }        
+}
\ No newline at end of file

Added: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/node/ProcessNodeInstanceFactoryTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/node/ProcessNodeInstanceFactoryTest.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/node/ProcessNodeInstanceFactoryTest.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,29 @@
+package org.drools.workflow.instance.node;
+
+import java.util.Properties;
+
+import junit.framework.TestCase;
+
+import org.drools.RuleBaseConfiguration;
+import org.drools.workflow.core.Node;
+import org.drools.workflow.core.node.ActionNode;
+import org.drools.workflow.instance.impl.NodeInstanceFactoryRegistry;
+import org.drools.workflow.instance.impl.factory.CreateNewNodeFactory;
+
+public class ProcessNodeInstanceFactoryTest extends TestCase {
+    
+    public void testDefaultEntries() throws Exception {
+        RuleBaseConfiguration conf = new RuleBaseConfiguration();
+        NodeInstanceFactoryRegistry registry = conf.getProcessNodeInstanceFactoryRegistry();
+        Node node = new ActionNode();
+        assertEquals( CreateNewNodeFactory.class, registry.getProcessNodeInstanceFactory( node ).getClass() );       
+    }
+    
+    public void testDiscoveredEntry() {
+        Properties properties = new Properties(); 
+        properties.put( "processNodeInstanceFactoryRegistry", "mockProcessNodeInstanceFactory.conf" );        
+        RuleBaseConfiguration conf = new RuleBaseConfiguration( properties );
+        NodeInstanceFactoryRegistry registry = conf.getProcessNodeInstanceFactoryRegistry();
+        assertEquals( MockNodeInstanceFactory.class, registry.getProcessNodeInstanceFactory( new MockNode() ).getClass() );
+    }
+}

Added: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/node/StartNodeInstanceTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/node/StartNodeInstanceTest.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/workflow/instance/node/StartNodeInstanceTest.java	2008-01-09 01:33:20 UTC (rev 17637)
@@ -0,0 +1,59 @@
+package org.drools.workflow.instance.node;
+
+
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.drools.RuleBase;
+import org.drools.RuleBaseConfiguration;
+import org.drools.RuleBaseFactory;
+import org.drools.StatefulSession;
+import org.drools.common.InternalWorkingMemory;
+import org.drools.process.instance.ProcessInstance;
+import org.drools.ruleflow.core.RuleFlowProcess;
+import org.drools.ruleflow.instance.RuleFlowProcessInstance;
+import org.drools.workflow.core.Node;
+import org.drools.workflow.core.impl.ConnectionImpl;
+import org.drools.workflow.core.node.StartNode;
+import org.drools.workflow.instance.NodeInstance;
+
+public class StartNodeInstanceTest extends TestCase {
+    
+    public void testStartNode() {
+        
+        RuleBaseConfiguration conf = new RuleBaseConfiguration();
+        RuleBase ruleBase = RuleBaseFactory.newRuleBase( conf );
+        StatefulSession session = ruleBase.newStatefulSession();        
+        
+        MockNode mockNode = new MockNode();
+        MockNodeInstanceFactory mockNodeFactory = new MockNodeInstanceFactory( new MockNodeInstance( mockNode ) );
+        conf.getProcessNodeInstanceFactoryRegistry().register( mockNode.getClass(), mockNodeFactory );
+        
+        RuleFlowProcess process = new RuleFlowProcess(); 
+        
+        Node startNode = new StartNode();  
+        startNode.setId( 1 );
+        startNode.setName( "start node" );                
+                            
+        mockNode.setId( 2 );
+        new ConnectionImpl(startNode, Node.CONNECTION_DEFAULT_TYPE, mockNode, Node.CONNECTION_DEFAULT_TYPE);
+        
+        process.addNode( startNode );
+        process.addNode( mockNode );
+                
+        RuleFlowProcessInstance processInstance = new RuleFlowProcessInstance();   
+        processInstance.setProcess( process );
+        processInstance.setWorkingMemory( (InternalWorkingMemory) session );              
+        
+        assertEquals(  ProcessInstance.STATE_PENDING, processInstance.getState() );
+        processInstance.start();        
+        assertEquals(  ProcessInstance.STATE_ACTIVE, processInstance.getState() );
+        
+        MockNodeInstance mockNodeInstance = mockNodeFactory.getMockNodeInstance();
+        List<NodeInstance> triggeredBy = mockNodeInstance.getTriggers().get(Node.CONNECTION_DEFAULT_TYPE);
+        assertNotNull(triggeredBy);
+        assertEquals(1, triggeredBy.size());
+        assertSame(startNode.getId(), triggeredBy.get(0).getNodeId());
+    }
+}




More information about the jboss-svn-commits mailing list