[savara-commits] savara SVN: r491 - in trunk: bundles and 216 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Sat Nov 20 18:03:33 EST 2010


Author: objectiser
Date: 2010-11-20 18:03:24 -0500 (Sat, 20 Nov 2010)
New Revision: 491

Added:
   trunk/bundles/
   trunk/bundles/org.savara.bpel/
   trunk/bundles/org.savara.bpel/.classpath
   trunk/bundles/org.savara.bpel/.project
   trunk/bundles/org.savara.bpel/Copyright.txt
   trunk/bundles/org.savara.bpel/META-INF/
   trunk/bundles/org.savara.bpel/META-INF/MANIFEST.MF
   trunk/bundles/org.savara.bpel/build.properties
   trunk/bundles/org.savara.bpel/pom.xml
   trunk/bundles/org.savara.bpel/src/
   trunk/bundles/org.savara.bpel/src/main/
   trunk/bundles/org.savara.bpel/src/main/java/
   trunk/bundles/org.savara.bpel/src/main/java/org/
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/export/
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/export/BPELLanguageModelStreamExportRule.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/generator/
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/generator/GeneratorUtil.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/BPELLanguageModel.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/BPELNotation.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/DefaultBPELLanguageModel.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/AbstractBPELModelChangeRule.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/ConversationChangeRule.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/ConversationInteractionModelChangeRule.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/IfModelChangeRule.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/InteractionPatterns.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/LanguageToConversationModelChangeRule.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/ModelChangeUtils.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/RunModelChangeRule.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/SpawnModelChangeRule.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/WhenModelChangeRule.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/WhileModelChangeRule.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/AbstractCondition.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/AbstractInteraction.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/BPELActivity.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/BPELElement.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/BPELElementFactory.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/BPELGroupingConstruct.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Catch.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/CatchAll.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/CompensationHandler.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Condition.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/ConversionContext.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/DefaultConversionContext.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Else.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Elseif.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/EventHandlers.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Exit.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/FaultHandlers.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Flow.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/For.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/ForEach.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/If.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Import.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Invoke.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Link.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/OnAlarm.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/OnEvent.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/OnMessage.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/PartnerLink.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Pick.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Process.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Receive.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/RepeatUntil.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Reply.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Rethrow.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Scope.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/ScopeActivity.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Sequence.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Source.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Target.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/TerminationHandler.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Throw.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Until.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Variable.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Wait.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/While.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/util/
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/util/InteractionUtil.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/util/TypeReferenceUtil.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/osgi/
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/osgi/Activator.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/parser/
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/parser/BPELModelParserRule.java
   trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/parser/BPELTokenizer.java
   trunk/bundles/org.savara.bpel/src/test/
   trunk/bundles/org.savara.bpel/src/test/java/
   trunk/bundles/org.savara.bpel/src/test/java/org/
   trunk/bundles/org.savara.bpel/src/test/java/org/savara/
   trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/
   trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/
   trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/change/
   trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/change/ModelChangeUtilsTest.java
   trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/
   trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/AbstractInteractionTest.java
   trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/BPELActivityTest.java
   trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/BPELElementTest.java
   trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/CatchAllTest.java
   trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/CatchTest.java
   trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/CompensationHandlerTest.java
   trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/ConditionTest.java
   trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/ElseIfTest.java
   trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/ElseTest.java
   trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/EventHandlersTest.java
   trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/ExitTest.java
   trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/FaultHandlersTest.java
   trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/FlowTest.java
   trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/ForEachTest.java
   trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/IfTest.java
   trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/InvokeTest.java
   trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/OnAlarmTest.java
   trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/OnEventTest.java
   trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/OnMessageTest.java
   trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/PartnerLinkTest.java
   trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/PickTest.java
   trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/ProcessTest.java
   trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/ReceiveTest.java
   trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/RepeatUntilTest.java
   trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/ReplyTest.java
   trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/RethrowTest.java
   trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/ScopeTest.java
   trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/SequenceTest.java
   trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/TerminationHandlerTest.java
   trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/TestAbstractInteraction.java
   trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/TestBPELActivity.java
   trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/TestBPELElement.java
   trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/ThrowTest.java
   trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/VariableTest.java
   trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/WaitTest.java
   trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/WhileTest.java
   trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/util/
   trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/util/InteractionUtilTest.java
   trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/util/
   trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/util/XMLUtilsTest.java
   trunk/bundles/org.savara.contract.model/
   trunk/bundles/org.savara.contract.model/.classpath
   trunk/bundles/org.savara.contract.model/.project
   trunk/bundles/org.savara.contract.model/Copyright.txt
   trunk/bundles/org.savara.contract.model/META-INF/
   trunk/bundles/org.savara.contract.model/META-INF/MANIFEST.MF
   trunk/bundles/org.savara.contract.model/build.properties
   trunk/bundles/org.savara.contract.model/pom.xml
   trunk/bundles/org.savara.contract.model/src/
   trunk/bundles/org.savara.contract.model/src/main/
   trunk/bundles/org.savara.contract.model/src/main/java/
   trunk/bundles/org.savara.contract.model/src/main/java/org/
   trunk/bundles/org.savara.contract.model/src/main/java/org/savara/
   trunk/bundles/org.savara.contract.model/src/main/java/org/savara/contract/
   trunk/bundles/org.savara.contract.model/src/main/java/org/savara/contract/model/
   trunk/bundles/org.savara.contract.model/src/main/java/org/savara/contract/model/Contract.java
   trunk/bundles/org.savara.contract.model/src/main/java/org/savara/contract/model/FaultDetails.java
   trunk/bundles/org.savara.contract.model/src/main/java/org/savara/contract/model/Interface.java
   trunk/bundles/org.savara.contract.model/src/main/java/org/savara/contract/model/MessageExchangePattern.java
   trunk/bundles/org.savara.contract.model/src/main/java/org/savara/contract/model/Namespace.java
   trunk/bundles/org.savara.contract.model/src/main/java/org/savara/contract/model/OneWayRequestMEP.java
   trunk/bundles/org.savara.contract.model/src/main/java/org/savara/contract/model/RequestResponseMEP.java
   trunk/bundles/org.savara.contract.model/src/main/java/org/savara/contract/model/Type.java
   trunk/bundles/org.savara.contract.model/src/main/java/org/savara/contract/model/TypeDefinition.java
   trunk/bundles/org.savara.contract.model/src/main/java/org/savara/contract/model/osgi/
   trunk/bundles/org.savara.contract.model/src/main/java/org/savara/contract/model/osgi/Activator.java
   trunk/bundles/org.savara.core/
   trunk/bundles/org.savara.core/.classpath
   trunk/bundles/org.savara.core/.project
   trunk/bundles/org.savara.core/META-INF/
   trunk/bundles/org.savara.core/META-INF/MANIFEST.MF
   trunk/bundles/org.savara.core/build.properties
   trunk/bundles/org.savara.core/pom.xml
   trunk/bundles/org.savara.core/src/
   trunk/bundles/org.savara.core/src/main/
   trunk/bundles/org.savara.core/src/main/java/
   trunk/bundles/org.savara.core/src/main/java/org/
   trunk/bundles/org.savara.core/src/main/java/org/savara/
   trunk/bundles/org.savara.core/src/main/java/org/savara/core/
   trunk/bundles/org.savara.core/src/main/java/org/savara/core/osgi/
   trunk/bundles/org.savara.core/src/main/java/org/savara/core/osgi/Activator.java
   trunk/bundles/org.savara.core/src/main/java/org/savara/util/
   trunk/bundles/org.savara.core/src/main/java/org/savara/util/XMLUtils.java
   trunk/bundles/org.savara.wsdl/
   trunk/bundles/org.savara.wsdl/.classpath
   trunk/bundles/org.savara.wsdl/.project
   trunk/bundles/org.savara.wsdl/Copyright.txt
   trunk/bundles/org.savara.wsdl/META-INF/
   trunk/bundles/org.savara.wsdl/META-INF/MANIFEST.MF
   trunk/bundles/org.savara.wsdl/build.properties
   trunk/bundles/org.savara.wsdl/pom.xml
   trunk/bundles/org.savara.wsdl/src/
   trunk/bundles/org.savara.wsdl/src/main/
   trunk/bundles/org.savara.wsdl/src/main/java/
   trunk/bundles/org.savara.wsdl/src/main/java/org/
   trunk/bundles/org.savara.wsdl/src/main/java/org/savara/
   trunk/bundles/org.savara.wsdl/src/main/java/org/savara/wsdl/
   trunk/bundles/org.savara.wsdl/src/main/java/org/savara/wsdl/generator/
   trunk/bundles/org.savara.wsdl/src/main/java/org/savara/wsdl/generator/WSDLBinding.java
   trunk/bundles/org.savara.wsdl/src/main/java/org/savara/wsdl/generator/WSDLGenerator.java
   trunk/bundles/org.savara.wsdl/src/main/java/org/savara/wsdl/generator/WSDLGeneratorFactory.java
   trunk/bundles/org.savara.wsdl/src/main/java/org/savara/wsdl/generator/impl/
   trunk/bundles/org.savara.wsdl/src/main/java/org/savara/wsdl/generator/impl/WSDLGeneratorImpl.java
   trunk/bundles/org.savara.wsdl/src/main/java/org/savara/wsdl/generator/soap/
   trunk/bundles/org.savara.wsdl/src/main/java/org/savara/wsdl/generator/soap/SOAPDocLitWSDLBinding.java
   trunk/bundles/org.savara.wsdl/src/main/java/org/savara/wsdl/generator/soap/SOAPRPCWSDLBinding.java
   trunk/bundles/org.savara.wsdl/src/main/java/org/savara/wsdl/osgi/
   trunk/bundles/org.savara.wsdl/src/main/java/org/savara/wsdl/osgi/Activator.java
   trunk/bundles/org.savara.wsdl/src/main/java/org/savara/wsdl/util/
   trunk/bundles/org.savara.wsdl/src/main/java/org/savara/wsdl/util/WSDLGeneratorUtil.java
   trunk/bundles/org.savara.wsdl/src/test/
   trunk/bundles/org.savara.wsdl/src/test/java/
   trunk/bundles/org.savara.wsdl/src/test/java/org/
   trunk/bundles/org.savara.wsdl/src/test/java/org/savara/
   trunk/bundles/org.savara.wsdl/src/test/java/org/savara/tools/
   trunk/bundles/org.savara.wsdl/src/test/java/org/savara/tools/wsdl/
   trunk/bundles/org.savara.wsdl/src/test/java/org/savara/tools/wsdl/tests/
   trunk/bundles/org.savara.wsdl/src/test/java/org/savara/tools/wsdl/tests/WSDLGeneratorTest.java
   trunk/bundles/org.scribble.conformance/
   trunk/bundles/org.scribble.conformance/.classpath
   trunk/bundles/org.scribble.conformance/.project
   trunk/bundles/org.scribble.conformance/LICENSE.txt
   trunk/bundles/org.scribble.conformance/META-INF/
   trunk/bundles/org.scribble.conformance/META-INF/MANIFEST.MF
   trunk/bundles/org.scribble.conformance/build.properties
   trunk/bundles/org.scribble.conformance/pom.xml
   trunk/bundles/org.scribble.conformance/src/
   trunk/bundles/org.scribble.conformance/src/main/
   trunk/bundles/org.scribble.conformance/src/main/java/
   trunk/bundles/org.scribble.conformance/src/main/java/org/
   trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/
   trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/
   trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/comparator/
   trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/comparator/BehaviourListComparatorRule.java
   trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/comparator/Messages.properties
   trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/comparator/StatelessDefinitionComparatorRule.java
   trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/comparator/SyncPoint.java
   trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/
   trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/BehaviourList.java
   trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/BehaviourListIterator.java
   trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/BehaviourListPaths.java
   trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/
   trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/AbstractDefinitionStatelessTransformationRule.java
   trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/AbstractStatelessTransformationRule.java
   trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/BlockStatelessTransformationRule.java
   trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/DefaultStatelessTransformationContext.java
   trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/DefaultStatelessTransformer.java
   trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/InteractionStatelessTransformationRule.java
   trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/MessageSignatureStatelessTransformationRule.java
   trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/RoleStatelessTransformationRule.java
   trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/StatelessTransformationContext.java
   trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/StatelessTransformationRule.java
   trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/StatelessTransformer.java
   trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/TransformState.java
   trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/TypeReferenceStatelessTransformationRule.java
   trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/osgi/
   trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/osgi/Activator.java
   trunk/bundles/org.scribble.conformance/src/plugintest/
   trunk/bundles/org.scribble.conformance/src/plugintest/org/
   trunk/bundles/org.scribble.conformance/src/plugintest/org/scribble/
   trunk/bundles/org.scribble.conformance/src/plugintest/org/scribble/conformance/
   trunk/bundles/org.scribble.conformance/src/plugintest/org/scribble/conformance/model/
   trunk/bundles/org.scribble.conformance/src/plugintest/org/scribble/conformance/model/transform/
   trunk/bundles/org.scribble.conformance/src/plugintest/org/scribble/conformance/model/transform/TransformTest.java
   trunk/bundles/org.scribble.conformance/src/plugintest/org/scribble/conformance/model/transform/results/
   trunk/bundles/org.scribble.conformance/src/plugintest/org/scribble/conformance/model/transform/results/Interaction1 at R1.scv
   trunk/bundles/org.scribble.conformance/src/plugintest/org/scribble/conformance/model/transform/results/Interaction1 at R2.scv
   trunk/bundles/org.scribble.conformance/src/plugintest/org/scribble/conformance/model/transform/results/Interaction2 at R2.scv
   trunk/bundles/org.scribble.conformance/src/plugintest/org/scribble/conformance/model/transform/testmodels/
   trunk/bundles/org.scribble.conformance/src/plugintest/org/scribble/conformance/model/transform/testmodels/Interaction1 at R1.scv
   trunk/bundles/org.scribble.conformance/src/plugintest/org/scribble/conformance/model/transform/testmodels/Interaction1 at R2.scv
   trunk/bundles/org.scribble.conformance/src/plugintest/org/scribble/conformance/model/transform/testmodels/Interaction2 at R2.scv
   trunk/bundles/org.scribble.conformance/src/test/
   trunk/bundles/org.scribble.conformance/src/test/org/
   trunk/bundles/org.scribble.conformance/src/test/org/scribble/
   trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/
   trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/comparator/
   trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/comparator/BehaviourListComparatorRuleTest.java
   trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/comparator/TestBehaviour1ComparatorRule.java
   trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/comparator/TestBehaviour2ComparatorRule.java
   trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/comparator/TestMultiPathComparatorRule.java
   trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/comparator/TestSinglePathComparatorRule.java
   trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/model/
   trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/model/BehaviourListTest.java
   trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/model/TestBehaviour1.java
   trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/model/TestBehaviour2.java
   trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/model/TestBehaviourList.java
   trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/model/TestDefinition.java
   trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/model/TestModelInclude.java
   trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/model/TestMultiPath.java
   trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/model/TestSinglePath.java
   trunk/bundles/org.scribble.conversation.comparator/
   trunk/bundles/org.scribble.conversation.comparator/.classpath
   trunk/bundles/org.scribble.conversation.comparator/.project
   trunk/bundles/org.scribble.conversation.comparator/LICENSE.txt
   trunk/bundles/org.scribble.conversation.comparator/META-INF/
   trunk/bundles/org.scribble.conversation.comparator/META-INF/MANIFEST.MF
   trunk/bundles/org.scribble.conversation.comparator/build.properties
   trunk/bundles/org.scribble.conversation.comparator/pom.xml
   trunk/bundles/org.scribble.conversation.comparator/src/
   trunk/bundles/org.scribble.conversation.comparator/src/main/
   trunk/bundles/org.scribble.conversation.comparator/src/main/java/
   trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/
   trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/
   trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/
   trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/
   trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/CatchBlockComparatorRule.java
   trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/ConditionalBlockComparatorRule.java
   trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/ConversationComparatorRule.java
   trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/IfComparatorRule.java
   trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/InterruptBlockComparatorRule.java
   trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/ParallelComparatorRule.java
   trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/RaiseComparatorRule.java
   trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/SpawnComparatorRule.java
   trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/TryEscapeComparatorRule.java
   trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/WhenComparatorRule.java
   trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/WhileComparatorRule.java
   trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/model/
   trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/model/transform/
   trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/model/transform/ConversationInteractionStatelessTransformationRule.java
   trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/model/transform/ConversationStatelessTransformationRule.java
   trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/model/transform/IfStatelessTransformationRule.java
   trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/model/transform/ParallelStatelessTransformationRule.java
   trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/model/transform/RunStatelessTransformationRule.java
   trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/model/transform/SpawnStatelessTransformationRule.java
   trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/model/transform/WhileStatelessTransformationRule.java
   trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/osgi/
   trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/osgi/Activator.java
   trunk/bundles/org.scribble.conversation.comparator/src/plugintest/
   trunk/bundles/org.scribble.conversation.comparator/src/plugintest/org/
   trunk/bundles/org.scribble.conversation.comparator/src/plugintest/org/scribble/
   trunk/bundles/org.scribble.conversation.comparator/src/plugintest/org/scribble/conversation/
   trunk/bundles/org.scribble.conversation.comparator/src/plugintest/org/scribble/conversation/comparator/
   trunk/bundles/org.scribble.conversation.comparator/src/plugintest/org/scribble/conversation/comparator/model/
   trunk/bundles/org.scribble.conversation.comparator/src/plugintest/org/scribble/conversation/comparator/model/transform/
   trunk/bundles/org.scribble.conversation.comparator/src/plugintest/org/scribble/conversation/comparator/model/transform/TransformTest.java
   trunk/bundles/org.scribble.conversation.comparator/src/plugintest/org/scribble/conversation/comparator/model/transform/results/
   trunk/bundles/org.scribble.conversation.comparator/src/plugintest/org/scribble/conversation/comparator/model/transform/results/ESBBroker at Broker.scv
   trunk/bundles/org.scribble.conversation.comparator/src/plugintest/org/scribble/conversation/comparator/model/transform/results/InteractionRun1 at R2.scv
   trunk/bundles/org.scribble.conversation.comparator/src/plugintest/org/scribble/conversation/comparator/model/transform/testmodels/
   trunk/bundles/org.scribble.conversation.comparator/src/plugintest/org/scribble/conversation/comparator/model/transform/testmodels/ESBBroker at Broker.scv
   trunk/bundles/org.scribble.conversation.comparator/src/plugintest/org/scribble/conversation/comparator/model/transform/testmodels/InteractionRun1 at R2.scv
   trunk/bundles/org.scribble.conversation.comparator/src/test/
   trunk/bundles/org.scribble.conversation.comparator/src/test/org/
   trunk/bundles/org.scribble.conversation.comparator/src/test/org/scribble/
   trunk/bundles/org.scribble.conversation.comparator/src/test/org/scribble/conversation/
   trunk/bundles/org.scribble.conversation.comparator/src/test/org/scribble/conversation/comparator/
   trunk/bundles/org.scribble.conversation.comparator/src/test/org/scribble/conversation/comparator/CatchBlockComparatorRuleTest.java
   trunk/bundles/org.scribble.conversation.comparator/src/test/org/scribble/conversation/comparator/ConditionalBlockComparatorRuleTest.java
   trunk/bundles/org.scribble.conversation.comparator/src/test/org/scribble/conversation/comparator/ConversationComparatorRuleTest.java
   trunk/bundles/org.scribble.conversation.comparator/src/test/org/scribble/conversation/comparator/IfComparatorRuleTest.java
   trunk/bundles/org.scribble.conversation.comparator/src/test/org/scribble/conversation/comparator/InterruptBlockComparatorRuleTest.java
   trunk/bundles/org.scribble.conversation.comparator/src/test/org/scribble/conversation/comparator/ParallelComparatorRuleTest.java
   trunk/bundles/org.scribble.conversation.comparator/src/test/org/scribble/conversation/comparator/RaiseComparatorRuleTest.java
   trunk/bundles/org.scribble.conversation.export.text/
   trunk/bundles/org.scribble.conversation.export.text/.classpath
   trunk/bundles/org.scribble.conversation.export.text/.project
   trunk/bundles/org.scribble.conversation.export.text/LICENSE.txt
   trunk/bundles/org.scribble.conversation.export.text/META-INF/
   trunk/bundles/org.scribble.conversation.export.text/META-INF/MANIFEST.MF
   trunk/bundles/org.scribble.conversation.export.text/build.properties
   trunk/bundles/org.scribble.conversation.export.text/pom.xml
   trunk/bundles/org.scribble.conversation.export.text/src/
   trunk/bundles/org.scribble.conversation.export.text/src/main/
   trunk/bundles/org.scribble.conversation.export.text/src/main/java/
   trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/
   trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/
   trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/
   trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/
   trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/stream/
   trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/stream/ConversationModelStreamExportRule.java
   trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/
   trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/AssignmentTextExportRule.java
   trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/CatchBlockTextExportRule.java
   trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/ConditionalBlockTextExportRule.java
   trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/ConversationInteractionTextExportRule.java
   trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/ConversationModelTextExportRule.java
   trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/ConversationReferenceTextExportRule.java
   trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/ConversationTextExportRule.java
   trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/IfTextExportRule.java
   trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/InterruptBlockTextExportRule.java
   trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/ParallelTextExportRule.java
   trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/RaiseTextExportRule.java
   trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/RunTextExportRule.java
   trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/SpawnTextExportRule.java
   trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/TryEscapeTextExportRule.java
   trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/VariableListTextExportRule.java
   trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/VariableTextExportRule.java
   trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/WhenTextExportRule.java
   trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/WhileTextExportRule.java
   trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/osgi/
   trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/osgi/Activator.java
   trunk/bundles/org.scribble.conversation.model/
   trunk/bundles/org.scribble.conversation.model/.classpath
   trunk/bundles/org.scribble.conversation.model/.project
   trunk/bundles/org.scribble.conversation.model/LICENSE.txt
   trunk/bundles/org.scribble.conversation.model/META-INF/
   trunk/bundles/org.scribble.conversation.model/META-INF/MANIFEST.MF
   trunk/bundles/org.scribble.conversation.model/build.properties
   trunk/bundles/org.scribble.conversation.model/pom.xml
   trunk/bundles/org.scribble.conversation.model/src/
   trunk/bundles/org.scribble.conversation.model/src/main/
   trunk/bundles/org.scribble.conversation.model/src/main/java/
   trunk/bundles/org.scribble.conversation.model/src/main/java/org/
   trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/
   trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/
   trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/
   trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/Assignment.java
   trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/CatchBlock.java
   trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/Compose.java
   trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/ConditionalBlock.java
   trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/Conversation.java
   trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/ConversationInteraction.java
   trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/ConversationModel.java
   trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/ConversationNotation.java
   trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/ConversationReference.java
   trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/EscapeBlock.java
   trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/Expression.java
   trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/Identity.java
   trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/IdentityLocator.java
   trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/IdentityType.java
   trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/If.java
   trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/InterruptBlock.java
   trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/Parallel.java
   trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/Raise.java
   trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/Run.java
   trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/Spawn.java
   trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/TryEscape.java
   trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/Variable.java
   trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/VariableList.java
   trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/When.java
   trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/While.java
   trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/osgi/
   trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/osgi/Activator.java
   trunk/bundles/org.scribble.conversation.model/src/test/
   trunk/bundles/org.scribble.conversation.model/src/test/org/
   trunk/bundles/org.scribble.conversation.model/src/test/org/scribble/
   trunk/bundles/org.scribble.conversation.model/src/test/org/scribble/conversation/
   trunk/bundles/org.scribble.conversation.model/src/test/org/scribble/conversation/model/
   trunk/bundles/org.scribble.conversation.model/src/test/org/scribble/conversation/model/IfTest.java
   trunk/bundles/org.scribble.conversation.model/src/test/org/scribble/conversation/model/WhileTest.java
   trunk/bundles/org.scribble.conversation.parser/
   trunk/bundles/org.scribble.conversation.parser/.classpath
   trunk/bundles/org.scribble.conversation.parser/.project
   trunk/bundles/org.scribble.conversation.parser/LICENSE.txt
   trunk/bundles/org.scribble.conversation.parser/META-INF/
   trunk/bundles/org.scribble.conversation.parser/META-INF/MANIFEST.MF
   trunk/bundles/org.scribble.conversation.parser/build.properties
   trunk/bundles/org.scribble.conversation.parser/pom.xml
   trunk/bundles/org.scribble.conversation.parser/src/
   trunk/bundles/org.scribble.conversation.parser/src/main/
   trunk/bundles/org.scribble.conversation.parser/src/main/java/
   trunk/bundles/org.scribble.conversation.parser/src/main/java/org/
   trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/
   trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/
   trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/
   trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/CatchBlockParserRule.java
   trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/ConversationInteractionParserRule.java
   trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/ConversationKeyWordProvider.java
   trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/ConversationModelParserRule.java
   trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/ConversationParserRule.java
   trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/ConversationReferenceParserRule.java
   trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/IdentityLocatorParserRule.java
   trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/IfParserRule.java
   trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/InterruptBlockParserRule.java
   trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/Messages.properties
   trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/ParallelParserRule.java
   trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/RaiseParserRule.java
   trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/RunConversationParserRule.java
   trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/RunParserRule.java
   trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/SpawnConversationParserRule.java
   trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/SpawnParserRule.java
   trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/TryEscapeParserRule.java
   trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/VariableListParserRule.java
   trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/WhenParserRule.java
   trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/WhileParserRule.java
   trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/osgi/
   trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/osgi/Activator.java
   trunk/bundles/org.scribble.conversation.projector/
   trunk/bundles/org.scribble.conversation.projector/.classpath
   trunk/bundles/org.scribble.conversation.projector/.project
   trunk/bundles/org.scribble.conversation.projector/LICENSE.txt
   trunk/bundles/org.scribble.conversation.projector/META-INF/
   trunk/bundles/org.scribble.conversation.projector/META-INF/MANIFEST.MF
   trunk/bundles/org.scribble.conversation.projector/build.properties
   trunk/bundles/org.scribble.conversation.projector/pom.xml
   trunk/bundles/org.scribble.conversation.projector/src/
   trunk/bundles/org.scribble.conversation.projector/src/main/
   trunk/bundles/org.scribble.conversation.projector/src/main/java/
   trunk/bundles/org.scribble.conversation.projector/src/main/java/org/
   trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/
   trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/
   trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/
   trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/CatchBlockProjectorRule.java
   trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/ComposeProjectorRule.java
   trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/ConditionalBlockProjectorRule.java
   trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/ConversationInteractionProjectorRule.java
   trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/ConversationModelProjectorRule.java
   trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/ConversationProjectorRule.java
   trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/ConversationReferenceProjectorRule.java
   trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/IdentityLocatorProjectorRule.java
   trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/IdentityProjectorRule.java
   trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/IfProjectorRule.java
   trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/InterruptBlockProjectorRule.java
   trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/ParallelProjectorRule.java
   trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/RaiseProjectorRule.java
   trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/RunProjectorRule.java
   trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/SpawnProjectorRule.java
   trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/TryEscapeProjectorRule.java
   trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/VariableListProjectorRule.java
   trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/WhenProjectorRule.java
   trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/WhileProjectorRule.java
   trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/osgi/
   trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/osgi/Activator.java
   trunk/bundles/org.scribble.conversation.validation/
   trunk/bundles/org.scribble.conversation.validation/.classpath
   trunk/bundles/org.scribble.conversation.validation/.project
   trunk/bundles/org.scribble.conversation.validation/LICENSE.txt
   trunk/bundles/org.scribble.conversation.validation/META-INF/
   trunk/bundles/org.scribble.conversation.validation/META-INF/MANIFEST.MF
   trunk/bundles/org.scribble.conversation.validation/build.properties
   trunk/bundles/org.scribble.conversation.validation/pom.xml
   trunk/bundles/org.scribble.conversation.validation/src/
   trunk/bundles/org.scribble.conversation.validation/src/main/
   trunk/bundles/org.scribble.conversation.validation/src/main/java/
   trunk/bundles/org.scribble.conversation.validation/src/main/java/org/
   trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/
   trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/
   trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/
   trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/BehaviourValidationRule.java
   trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/ComposeValidationRule.java
   trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/ConditionalBlockValidationRule.java
   trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/ConversationInteractionValidationRule.java
   trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/ConversationModelValidationRule.java
   trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/ConversationValidationRule.java
   trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/IfValidationRule.java
   trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/Messages.properties
   trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/ParallelValidationRule.java
   trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/RaiseValidationRule.java
   trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/TryEscapeValidationRule.java
   trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/VariableListValidationRule.java
   trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/VariableValidationRule.java
   trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/WhenValidationRule.java
   trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/WhileValidationRule.java
   trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/osgi/
   trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/osgi/Activator.java
   trunk/bundles/org.scribble.core/
   trunk/bundles/org.scribble.core/.classpath
   trunk/bundles/org.scribble.core/.project
   trunk/bundles/org.scribble.core/Issues.txt
   trunk/bundles/org.scribble.core/LICENSE.txt
   trunk/bundles/org.scribble.core/META-INF/
   trunk/bundles/org.scribble.core/META-INF/MANIFEST.MF
   trunk/bundles/org.scribble.core/build.properties
   trunk/bundles/org.scribble.core/pom.xml
   trunk/bundles/org.scribble.core/schema/
   trunk/bundles/org.scribble.core/src/
   trunk/bundles/org.scribble.core/src/main/
   trunk/bundles/org.scribble.core/src/main/java/
   trunk/bundles/org.scribble.core/src/main/java/org/
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/BlockComparatorRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/ChannelComparatorRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/Comparator.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/ComparatorContext.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/ComparatorRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/DefaultComparator.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/DefaultComparatorContext.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/DefaultNameMap.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/GlobalToLocalModelComparatorRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/InteractionComparatorRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/LocalToLocalModelComparatorRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/MessageSignatureComparatorRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/Messages.properties
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/NameMap.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/NamespaceComparatorRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/RoleComparatorRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/TypeReferenceComparatorRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/editor/
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/editor/AbstractEditorManager.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/editor/EditorManager.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/AbstractFormatter.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/DefaultExporter.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/DefaultExporterContext.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/ExportRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/Exporter.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/ExporterContext.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/Formatter.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/stream/
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/stream/AbstractModelStreamExportRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/stream/StreamFormatter.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/AbstractBlockTextExportRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/AbstractModelReferenceTextExportRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/AbstractModelTextExportRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/BlockTextExportRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/ChannelListTextExportRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/ChannelTextExportRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/ConformanceReferenceTextExportRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/ImplementsReferenceTextExportRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/ImportTextExportRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/InteractionTextExportRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/MessageSignatureTextExportRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/ModelNameTextExportRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/NamespaceTextExportRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/RoleListTextExportRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/RoleTextExportRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/TextFormatter.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/TypeReferenceTextExportRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/extensions/
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/extensions/AbstractRegistry.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/extensions/ClasspathRegistry.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/extensions/OSGiRegistry.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/extensions/Registry.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/extensions/RegistryException.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/extensions/RegistryFactory.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/extensions/RegistryInfo.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/AbstractNotation.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Activity.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Annotations.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Behaviour.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Block.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Channel.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/ChannelList.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/ConformanceReference.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/ContainmentList.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Declaration.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/DeclarationBinding.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Definition.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/ImplementsReference.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Import.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Interaction.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/LocatedName.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/MessageSignature.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Model.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/ModelInclude.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/ModelObject.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/ModelReference.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/MultiPathBehaviour.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/NameMappingReference.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Namespace.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Notation.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/OrderingConstraint.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Reference.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Role.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/RoleList.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/SinglePathBehaviour.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/SourceRef.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Statement.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/SubDefinitionPath.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/TypeModel.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/TypeNotation.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/TypeReference.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Visitor.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/admin/
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/admin/AbstractModelRepository.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/admin/Context.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/admin/DefaultModelChangeListener.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/admin/DefaultModelListener.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/admin/DefaultResolution.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/admin/Messages.properties
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/admin/ModelChangeListener.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/admin/ModelIssue.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/admin/ModelListener.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/admin/ModelRepository.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/admin/ModelResource.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/analysis/
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/analysis/BlockLookaheadRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/analysis/DefaultLookaheadAnalyser.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/analysis/DefaultLookaheadContext.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/analysis/InteractionLookaheadRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/analysis/LookaheadAnalyser.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/analysis/LookaheadContext.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/analysis/LookaheadRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/analysis/ModelIncludeLookaheadRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/analysis/MultiPathBehaviourLookaheadRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/analysis/SinglePathBehaviourLookaheadRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/change/
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/change/AbstractModelChangeRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/change/DefaultModelChangeContext.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/change/DefaultModelGenerator.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/change/ModelChangeContext.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/change/ModelChangeRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/change/ModelGenerator.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/filter/
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/filter/DefaultModelFilter.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/filter/ModelFilter.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/resolutions/
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/resolutions/DeleteFromModel.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/resolutions/InsertFromReferencedDescription.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/resolutions/Messages.properties
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/resolutions/Resolution.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/resolutions/ResolutionException.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/resolutions/ShowComposedIssue.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/resolutions/ShowReferencedDescription.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/resolutions/UpdateFromReferencedDescription.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/types/
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/types/DefaultTypeResolver.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/types/TypeInformation.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/types/TypeResolver.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/types/TypeResolverRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/types/TypeSystem.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/util/
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/util/InteractionUtil.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/osgi/
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/osgi/Activator.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/AbstractImplementsReferenceParserRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/AbstractModelParserRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/AbstractModelReferenceParserRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/AbstractParserRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/ChannelListParserRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/ConformanceReferenceParserRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/DefaultKeyWordProvider.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/DefaultParser.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/DefaultParserContext.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/DefaultTokenizer.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/ImportParserRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/InteractionParserRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/KeyWordProvider.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/MessageSignatureParserRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/Messages.properties
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/ModelNameParserRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/NamespaceParserRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/Parser.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/ParserConstants.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/ParserContext.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/ParserRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/ParserRuleType.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/RoleListParserRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/Token.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/TokenType.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/Tokenizer.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/TypeReferenceParserRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/AbstractBlockProjectorRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/BlockProjectorRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/ChannelListProjectorRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/ConformanceReferenceProjectorRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/DefaultProjector.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/DefaultProjectorContext.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/ImplementsReferenceProjectorRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/ImportProjectorRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/InteractionProjectorRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/LocatedNameProjectorRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/MessageSignatureProjectorRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/Messages.properties
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/ModelIncludeProjectorRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/ModelProjectorRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/ModelReferenceProjectorRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/NamespaceProjectorRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/Projector.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/ProjectorContext.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/ProjectorRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/RoleListProjectorRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/RoleProjectorRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/TypeReferenceProjectorRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/util/
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/util/MessageUtil.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/util/ModelIssueUtil.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/util/ResourceUtil.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/util/Scope.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/AbstractValidationRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/BlockValidationRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/ChannelListValidationRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/ChannelValidationRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/DefaultValidationContext.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/DefaultValidator.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/InteractionValidationRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/MessageSignatureValidationRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/Messages.properties
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/ModelReferenceValidationRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/ModelValidationRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/RoleListValidationRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/RoleValidationRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/TypeReferenceValidationRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/ValidationContext.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/ValidationRule.java
   trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/Validator.java
   trunk/bundles/org.scribble.core/src/test/
   trunk/bundles/org.scribble.core/src/test/org/
   trunk/bundles/org.scribble.core/src/test/org/scribble/
   trunk/bundles/org.scribble.core/src/test/org/scribble/ScribbleCoreAllTests.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/comparator/
   trunk/bundles/org.scribble.core/src/test/org/scribble/comparator/BlockComparatorRuleTest.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/comparator/ChannelComparatorRuleTest.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/comparator/DefaultNameMapTest.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/comparator/GlobalToLocalModelComparatorRuleTest.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/comparator/InteractionComparatorRuleTest.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/comparator/MessageSignatureComparatorRuleTest.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/comparator/NamespaceComparatorRuleTest.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/comparator/RoleComparatorRuleTest.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/comparator/TestComparatorRule.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/comparator/TypeReferenceComparatorRuleTest.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/
   trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/AbstractRegistryTest.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/TestRegistry.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/TestSingleExtensionRegistry.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/TestTypeMapRegistry.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/test/
   trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/test/Extension1.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/test/Extension1Rule.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/test/Extension1Rule_Derived_SN1A.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/test/Extension1Rule_MN1.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/test/Extension1Rule_MN2.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/test/Extension1Rule_SN1A.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/test/MainNotation1.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/test/MainNotation2.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/test/SubNotation1A.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/model/
   trunk/bundles/org.scribble.core/src/test/org/scribble/model/InteractionTest.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/model/ModelObjectTest.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/model/ModelReferenceTest.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/model/ModelTest.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/model/TestDefinition.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/model/TestModel.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/model/TestMultiPathBehaviour.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/model/TestSinglePathBehaviour.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/model/admin/
   trunk/bundles/org.scribble.core/src/test/org/scribble/model/admin/DefaultModelListenerTest.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/model/admin/ErrorRecorder.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/model/admin/TestModelResource.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/model/analysis/
   trunk/bundles/org.scribble.core/src/test/org/scribble/model/analysis/TestLookaheadAnalyser.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/model/change/
   trunk/bundles/org.scribble.core/src/test/org/scribble/model/change/TestChangeInformation.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/model/change/TestModelChangeContext.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/model/filter/
   trunk/bundles/org.scribble.core/src/test/org/scribble/model/filter/DefaultModelFilterTest.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/model/util/
   trunk/bundles/org.scribble.core/src/test/org/scribble/model/util/InteractionUtilTest.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/parser/
   trunk/bundles/org.scribble.core/src/test/org/scribble/parser/ChannelListParserRuleTest.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/parser/ConformanceReferenceParserRuleTest.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/parser/DefaultParserContextTest.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/parser/GenericKeyWordProvider.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/parser/GenericParser.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/parser/ImportParserRuleTest.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/parser/InteractionParserRuleTest.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/parser/MessageSignatureParserRuleTest.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/parser/ModelNameParserRuleTest.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/parser/NamespaceParserRuleTest.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/parser/RoleListParserRuleTest.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/parser/TestModelRepository.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/parser/TestParserContext.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/parser/TestTypeReferenceParserRule.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/parser/TypeReferenceParserRuleTest.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/projector/
   trunk/bundles/org.scribble.core/src/test/org/scribble/projector/TestProjector.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/util/
   trunk/bundles/org.scribble.core/src/test/org/scribble/util/ModelIssueUtilTest.java
   trunk/bundles/org.scribble.core/src/test/org/scribble/util/ScopeTest.java
   trunk/bundles/pom.xml
Log:
New trunk with updated build scripts to create OSGi bundles using standard maven, and only the Eclipse plugins and update site using Tycho, to enable the bundles to be uploaded to Nexus and used in other contexts.

Added: trunk/bundles/org.savara.bpel/.classpath
===================================================================
--- trunk/bundles/org.savara.bpel/.classpath	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/.classpath	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src/main/java"/>
+	<classpathentry kind="src" path="src/test/java"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

Added: trunk/bundles/org.savara.bpel/.project
===================================================================
--- trunk/bundles/org.savara.bpel/.project	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/.project	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.savara.bpel</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.ManifestBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.SchemaBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.pde.PluginNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

Added: trunk/bundles/org.savara.bpel/Copyright.txt
===================================================================
--- trunk/bundles/org.savara.bpel/Copyright.txt	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/Copyright.txt	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,17 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */

Added: trunk/bundles/org.savara.bpel/META-INF/MANIFEST.MF
===================================================================
--- trunk/bundles/org.savara.bpel/META-INF/MANIFEST.MF	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/META-INF/MANIFEST.MF	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,34 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: SAVARA BPEL
+Bundle-SymbolicName: org.savara.bpel
+Bundle-Version: 1.2.0.qualifier
+Bundle-Activator: org.savara.bpel.osgi.Activator
+Bundle-Vendor: www.savara.org
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Import-Package: org.osgi.framework;version="1.3.0"
+Require-Bundle: org.scribble.conversation.model;bundle-version="[1.0.0,2.0.0)",
+ org.scribble.core;bundle-version="[1.0.0,2.0.0)",
+ org.scribble.lang.model;bundle-version="[1.0.0,2.0.0)",
+ org.scribble.conversation.parser;bundle-version="[1.0.0,2.0.0)",
+ org.apache.commons.logging,
+ org.scribble.expression.xpath;bundle-version="[1.0.0,2.0.0)",
+ org.savara.pi4soa.cdm;resolution:=optional,
+ org.savara.contract.model,
+ org.savara.wsdl,
+ org.savara.core,
+ org.junit
+Scribble-Extensions: org.savara.bpel.parser.BPELTokenizer,
+  org.savara.bpel.parser.BPELModelParserRule,
+  org.savara.bpel.model.BPELNotation,
+  org.savara.bpel.model.change.LanguageToConversationModelChangeRule,
+  org.savara.bpel.model.change.ConversationChangeRule,
+  org.savara.bpel.model.change.WhileModelChangeRule,
+  org.savara.bpel.model.change.WhenModelChangeRule,
+  org.savara.bpel.model.change.IfModelChangeRule,
+  org.savara.bpel.model.change.RunModelChangeRule,
+  org.savara.bpel.model.change.SpawnModelChangeRule,
+  org.savara.bpel.model.change.ConversationInteractionModelChangeRule
+Export-Package: org.savara.bpel.model;x-friends:="org.savara.tools.bpel.tests",
+ org.savara.bpel.model.change;x-friends:="org.savara.tools.bpel.tests",
+ org.savara.bpel.model.component;x-friends:="org.savara.tools.bpel.tests"

Added: trunk/bundles/org.savara.bpel/build.properties
===================================================================
--- trunk/bundles/org.savara.bpel/build.properties	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/build.properties	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,4 @@
+source.. = src/main/java/
+output.. = bin/
+bin.includes = META-INF/,\
+               .

Added: trunk/bundles/org.savara.bpel/pom.xml
===================================================================
--- trunk/bundles/org.savara.bpel/pom.xml	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/pom.xml	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,76 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  	<modelVersion>4.0.0</modelVersion>
+	<groupId>org.savara.bundles</groupId>
+	<artifactId>org.savara.bpel</artifactId> 
+	<version>1.2.0-SNAPSHOT</version>
+	<packaging>jar</packaging>
+	<name>Savara::Bundles::BPEL</name>
+
+	<parent>
+		<groupId>org.savara</groupId>
+		<artifactId>bundles</artifactId>
+		<version>1.2.0-SNAPSHOT</version>
+	</parent>
+  
+	<dependencies>
+		<dependency>
+			<groupId>org.savara.bundles</groupId>
+			<artifactId>org.scribble.core</artifactId>
+			<version>1.2.0-SNAPSHOT</version>
+		</dependency>
+		<dependency>
+			<groupId>org.savara.bundles</groupId>
+			<artifactId>org.scribble.conversation.model</artifactId>
+			<version>1.2.0-SNAPSHOT</version>
+		</dependency>
+		<dependency>
+			<groupId>org.savara.bundles</groupId>
+			<artifactId>org.scribble.conversation.parser</artifactId>
+			<version>1.2.0-SNAPSHOT</version>
+		</dependency>
+		<dependency>
+			<groupId>org.savara.bundles</groupId>
+			<artifactId>org.scribble.lang.model</artifactId>
+			<version>1.2.0-SNAPSHOT</version>
+		</dependency>
+		<dependency>
+			<groupId>org.savara.bundles</groupId>
+			<artifactId>org.scribble.expression.xpath</artifactId>
+			<version>1.2.0-SNAPSHOT</version>
+		</dependency>
+		<dependency>
+			<groupId>org.savara.bundles</groupId>
+			<artifactId>org.savara.core</artifactId>
+			<version>1.2.0-SNAPSHOT</version>
+		</dependency>
+		<dependency>
+			<groupId>org.savara.bundles</groupId>
+			<artifactId>org.savara.wsdl</artifactId>
+			<version>1.2.0-SNAPSHOT</version>
+		</dependency>
+		<dependency>
+			<groupId>org.savara.bundles</groupId>
+			<artifactId>org.savara.contract.model</artifactId>
+			<version>1.2.0-SNAPSHOT</version>
+		</dependency>
+		<!--
+		<dependency>
+			<groupId>org.savara.tools</groupId>
+			<artifactId>org.savara.pi4soa.cdm</artifactId>
+			<version>1.2.0-SNAPSHOT</version>
+		</dependency>
+		-->
+	    <dependency>
+	      <groupId>org.apache.felix</groupId>
+	      <artifactId>org.osgi.core</artifactId>
+	      <version>${osgi.version}</version>
+	    </dependency>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+           	<version>${junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+   </dependencies>
+</project>

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/export/BPELLanguageModelStreamExportRule.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/export/BPELLanguageModelStreamExportRule.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/export/BPELLanguageModelStreamExportRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.export;
+
+import java.io.IOException;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.savara.bpel.model.BPELNotation;
+import org.savara.util.XMLUtils;
+import org.scribble.export.ExportRule;
+import org.scribble.export.ExporterContext;
+import org.scribble.export.Formatter;
+import org.scribble.export.stream.AbstractModelStreamExportRule;
+import org.scribble.export.stream.StreamFormatter;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.ModelObject;
+
+/**
+ * This class implements the stream based export rule for the
+ * BPELLanguageModel entity.
+ */
+ at RegistryInfo(extension=ExportRule.class,notation=BPELNotation.NOTATION_CODE)
+public class BPELLanguageModelStreamExportRule extends AbstractModelStreamExportRule {
+
+	/**
+	 * This method determines whether the exporter rule is appropriate
+	 * for the supplied model object and format.
+	 * 
+	 * @param modelObject The model object
+	 * @param format The format
+	 * @return Whether the rule is appropriate for the model object and
+	 * 						format
+	 */
+	public boolean isSupported(ModelObject modelObject, Formatter format) {
+		return(super.isSupported(modelObject, format) &&
+				BPELLanguageModel.class.isAssignableFrom(modelObject.getClass()));
+	}
+	
+	/**
+	 * This method exports the model object.
+	 * 
+	 * @param modelObject The model object
+	 * @param context The context
+	 * @throws IOException Failed to record export information
+	 */
+	public void export(ModelObject modelObject, ExporterContext context)
+							throws java.io.IOException {
+		BPELLanguageModel model=(BPELLanguageModel)modelObject;
+		StreamFormatter formatter=(StreamFormatter)context.getFormatter();
+		
+		try {
+			String text=XMLUtils.toText(model.getBPELProcess().getDOMElement());			
+			formatter.record(text.getBytes());
+			
+		} catch(Exception e) {
+			throw new java.io.IOException("Failed to get BPEL process text");
+		}
+	}
+
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/generator/GeneratorUtil.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/generator/GeneratorUtil.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/generator/GeneratorUtil.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.generator;
+
+import org.scribble.model.Role;
+
+/**
+ * This class provides general utility functions for
+ * use when generating artefacts.
+ */
+public class GeneratorUtil {
+
+	/**
+	 * This method returns the WSDL file name for the supplied role and local
+	 * conversation model.
+	 * 
+	 * @param role The role
+	 * @param localcm The local conversation model
+	 * @param fileNum The file name (zero being the main wsdl file)
+	 * @return The file name
+	 */
+	public static String getWSDLFileName(Role role, String modelName, String suffix) {
+		return(modelName+"_"+role.getName()+suffix+".wsdl");
+	}
+
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/BPELLanguageModel.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/BPELLanguageModel.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/BPELLanguageModel.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model;
+
+import org.savara.bpel.model.component.Process;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class represents a BPEL model.
+ *  
+ * @author gary
+ */
+public interface BPELLanguageModel {
+
+	/**
+	 * This method validates the ESB model and reports warnings or
+	 * errors to the supplied model listener.
+	 * 
+	 * @param l The model listener
+	 */
+	public void validate(ModelListener l);
+	
+	/**
+	 * This method returns the source model reference.
+	 * 
+	 * @return The source model reference
+	 */
+	public ModelReference getModelReference();
+
+	/**
+	 * This textual contents of the model.
+	 * 
+	 * @return The textual contents
+	 */
+	public String getOriginalContents();
+	
+	/**
+	 * This method returns the BPEL Process.
+	 * 
+	 * @return The BPEL Process
+	 */
+	public Process getBPELProcess();
+
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/BPELNotation.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/BPELNotation.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/BPELNotation.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model;
+
+import org.scribble.extensions.*;
+import org.scribble.model.ModelReference;
+import org.scribble.model.Notation;
+
+/**
+ * The notation class for the BPEL language.
+ */
+ at RegistryInfo(extension=org.scribble.model.Notation.class)
+public class BPELNotation extends org.scribble.model.AbstractNotation {
+
+	public static final String NOTATION_CODE = "bpel";
+
+	/**
+	 * This is the default constructor for the BPEL notation.
+	 */
+	public BPELNotation() {
+		super(NOTATION_CODE, "BPEL", false);
+	}
+	
+	/**
+	 * This method returns the initial description associated
+	 * with the supplied reference.
+	 * 
+	 * @param ref The reference
+	 * @return The initial description, or null if no description
+	 */
+	@Override
+	public String getInitialDescription(ModelReference ref) {
+		StringBuffer buf=new StringBuffer();
+				
+		return(buf.toString());
+	}
+
+	/**
+	 * This method returns the optional 'super' notation.
+	 * If defined, then this notation is a derived notation
+	 * from the 'super' notation.
+	 * 
+	 * @return The optional 'super' notation
+	 */
+	@Override
+	public Notation getSuperNotation() {
+		return(m_superNotation);
+	}
+
+	private Notation m_superNotation=new org.scribble.conversation.model.ConversationNotation();
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/DefaultBPELLanguageModel.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/DefaultBPELLanguageModel.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/DefaultBPELLanguageModel.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,188 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model;
+
+//import org.apache.commons.logging.*;
+import org.savara.bpel.model.component.Process;
+import org.scribble.conversation.model.Conversation;
+import org.scribble.model.*;
+import org.scribble.model.admin.Context;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.model.resolutions.*;
+
+/**
+ * This class represents a BPEL model.
+ *  
+ * @author gary
+ */
+public class DefaultBPELLanguageModel extends org.scribble.lang.model.LanguageModel
+					implements BPELLanguageModel {
+
+	private static final long serialVersionUID = 7625564863751533521L;
+
+	public static final String BPEL_NOTATION = "bpel";
+
+	/**
+	 * This constructor is initialized with the BPEL description.
+	 * 
+	 * @param source The model reference for the BPEL source
+	 * @param elem The BPEL document
+	 * @param contents The textual contents
+	 */
+	public DefaultBPELLanguageModel(ModelReference source, org.w3c.dom.Element elem,
+							String contents, Context context) {
+		m_source = source;
+		m_contents = contents;
+		m_bpelProcess = new Process(this, elem);
+		
+		Namespace ns=new Namespace();
+		ns.setName(source.getNamespace());
+		setNamespace(ns);
+		
+		// Initialize the existing model
+		Conversation conv=m_bpelProcess.convert(context);
+		
+		if (conv != null) {
+			getConversations().add(conv);
+		} else {
+			// Log error?
+		}
+	}
+	
+	/**
+	 * This constructor initializes a new BPEL process.
+	 * 
+	 * @param source The model reference for the BPEL description
+	 */
+	public DefaultBPELLanguageModel(ModelReference source) {
+		m_source = source;
+		
+		m_bpelProcess = new Process(this);
+	}
+	
+	/**
+	 * This method returns the source model reference.
+	 * 
+	 * @return The source model reference
+	 */
+	public ModelReference getModelReference() {
+		return(m_source);
+	}
+
+	/**
+	 * Generate a key for use in accessing the service related to
+	 * the supplied category and name.
+	 * 
+	 * @param category The category
+	 * @param name The service name
+	 * @return The key
+	 */
+	protected String getKey(String category, String name) {
+		return(category+"/"+name);
+	}
+	
+	/**
+	 * This method validates the ESB model and reports warnings or
+	 * errors to the supplied model listener.
+	 * 
+	 * @param l The model listener
+	 */
+	public void validate(ModelListener l) {
+
+	}
+	
+	/**
+	 * This textual contents of the model.
+	 * 
+	 * @return The textual contents
+	 */
+	public String getOriginalContents() {
+		return(m_contents);
+	}
+	
+	/**
+	 * This method returns the BPEL Process.
+	 * 
+	 * @return The BPEL Process
+	 */
+	public Process getBPELProcess() {
+		return(m_bpelProcess);
+	}
+		
+	//private static Log logger = LogFactory.getLog(DefaultBPELLanguageModel.class);
+
+	private ModelReference m_source=null;
+	private Process m_bpelProcess=null;
+	private String m_contents=null;
+	
+	public class InnerModelListener implements ModelListener {
+
+		public InnerModelListener(ModelListener l) {
+			m_listener = l;
+		}
+		
+		public void error(ModelIssue issue) {
+						
+			/*
+			issue.getProperties().put(ModelListener.RESOLUTIONS, ModelListener.SHOW_REFERENCE_DESCRIPTION_RESOLUTION);
+			issue.getProperties().put(ModelListener.REFERENCE_MODEL, m_source);
+			issue.getProperties().put(ModelListener.REFERENCE_MODEL_START_POSITION,
+						issue.getModelObject().getSource().getStartPosition());
+			issue.getProperties().put(ModelListener.REFERENCE_MODEL_END_POSITION,
+						issue.getModelObject().getSource().getEndPosition());
+			if (issue.getModelObject().getSource().getComponentURI() != null) {
+				issue.getProperties().put(ModelListener.REFERENCE_MODEL_COMPONENT,
+						issue.getModelObject().getSource().getComponentURI());
+			}
+			*/
+			ShowReferencedDescription res=new ShowReferencedDescription();
+			res.setModel(m_source);
+			res.setSourceReference(issue.getModelObject().getSource());
+			
+			issue.getResolutions().add(res);
+			
+			m_listener.error(issue);
+		}
+
+		public void warning(ModelIssue issue) {
+			/*
+			issue.getProperties().put(ModelListener.RESOLUTIONS, ModelListener.SHOW_REFERENCE_DESCRIPTION_RESOLUTION);
+			issue.getProperties().put(ModelListener.REFERENCE_MODEL, m_source);
+			issue.getProperties().put(ModelListener.REFERENCE_MODEL_START_POSITION,
+						issue.getModelObject().getSource().getStartPosition());
+			issue.getProperties().put(ModelListener.REFERENCE_MODEL_END_POSITION,
+						issue.getModelObject().getSource().getEndPosition());
+			if (issue.getModelObject().getSource().getComponentURI() != null) {
+				issue.getProperties().put(ModelListener.REFERENCE_MODEL_COMPONENT,
+						issue.getModelObject().getSource().getComponentURI());
+			}
+			*/
+			
+			ShowReferencedDescription res=new ShowReferencedDescription();
+			res.setModel(m_source);
+			res.setSourceReference(issue.getModelObject().getSource());
+						
+			issue.getResolutions().add(res);
+
+			m_listener.warning(issue);
+		}
+		
+		private ModelListener m_listener=null;
+	}
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/AbstractBPELModelChangeRule.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/AbstractBPELModelChangeRule.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/AbstractBPELModelChangeRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.change;
+
+import org.savara.bpel.model.*;
+import org.savara.bpel.model.component.Sequence;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+
+/**
+ * This is the abstract ESB model change rule.
+ */
+public abstract class AbstractBPELModelChangeRule extends AbstractModelChangeRule {
+
+	/**
+	 * This method determines whether the rule is appropriate
+	 * for the supplied type of model, parent (in the context) and inserted
+	 * model object.
+	 *
+	 * @param context The context
+	 * @param model The model
+	 * @param mobj The model object being inserted
+	 * @param ref The optional reference model object
+	 * @return Whether the rule supports the supplied information
+	 */
+	@Override
+	public boolean isInsertSupported(ModelChangeContext context,
+				Model model, ModelObject mobj, ModelObject ref) {
+		boolean ret=false;
+		
+		if (context.getParent() instanceof Sequence &&
+					model instanceof BPELLanguageModel) {
+			ret = true;
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method determines whether the rule is appropriate
+	 * for the supplied type of model, parent (in the context)
+	 * and deleted model object.
+	 * 
+	 * @param context The context
+	 * @param model The model
+	 * @param mobj The model object to be removed
+	 * @return Whether the rule supports the supplied information
+	 */
+	@Override
+	public boolean isDeleteSupported(ModelChangeContext context,
+						Model model, ModelObject mobj) {
+		boolean ret=false;
+		
+		return(ret);
+	}
+
+	/**
+	 * This method removes the supplied model object from the
+	 * supplied model. The model object representation must
+	 * contain the necessary model specific to remove the 
+	 * object from the underlying model representation.
+	 * 
+	 * @param context The context
+	 * @param model The model being changed
+	 * @param mobj The model object to be deleted
+	 * @return Whether the change has been applied
+	 */
+	@Override
+	public boolean delete(ModelChangeContext context,
+				Model model, ModelObject mobj) {
+		boolean ret=false;
+
+		return(ret);
+	}
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/ConversationChangeRule.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/ConversationChangeRule.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/ConversationChangeRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,243 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.change;
+
+import org.savara.bpel.generator.GeneratorUtil;
+import org.savara.bpel.model.*;
+import org.savara.bpel.model.component.*;
+import org.savara.bpel.model.component.Import;
+import org.savara.contract.model.Contract;
+import org.savara.contract.model.Interface;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This is the model change rule for the Conversation.
+ */
+ at RegistryInfo(extension=ModelChangeRule.class,notation=BPELNotation.NOTATION_CODE)
+public class ConversationChangeRule extends AbstractModelChangeRule {
+
+	//private static final String NAME_SUFFIX = "_main";
+
+	/**
+	 * This method determines whether the rule is appropriate
+	 * for the supplied type of model, parent (in the context) and
+	 * model object.
+	 *
+	 * @param context The context
+	 * @param model The model
+	 * @param mobj The model object causing the change
+	 * @param ref The optional reference model object
+	 * @return Whether the rule supports the supplied information
+	 */
+	@Override
+	public boolean isInsertSupported(ModelChangeContext context,
+				Model model, ModelObject mobj, ModelObject ref) {
+		boolean ret=false;
+		
+		if (mobj instanceof Conversation &&
+				model instanceof DefaultBPELLanguageModel) {
+			ret = true;
+		}
+		
+		return(ret);
+	}
+
+	/**
+	 * This method adds a new model object, within a
+	 * parent model object, with the details supplied in
+	 * another model object. The supplied model object
+	 * will usually be from a different model representation
+	 * (e.g. due to a merge), so the details will be
+	 * copied and placed in the representation associated
+	 * with the supplied model and parent model object.<p>
+	 * <p>
+	 * If a reference model object is supplied, then the
+	 * insertion will occur relative to it. If the reference
+	 * object is a block, then it means that the insertion
+	 * should occur at the end of the block. Otherwise the
+	 * new model object should be inserted before the
+	 * reference object, within the containing block.<p>
+	 * <p>
+	 * If the reference object is not supplied, then the
+	 * new model object should be inserted at the end of
+	 * the behaviour associated with the parent in the model
+	 * change context.
+	 * 
+	 * @param context The context
+	 * @param model The model being changed
+	 * @param mobj The model object details to be inserted
+	 * @param ref The optional reference model object
+	 * @return Whether the change has been applied
+	 */
+	@Override
+	public boolean insert(ModelChangeContext context,
+				Model model, ModelObject mobj, ModelObject ref) {
+		DefaultBPELLanguageModel bpelModel=(DefaultBPELLanguageModel)model;
+		Conversation conv=(Conversation)mobj;
+		String roleNamespace=null;
+		
+		Sequence seq=new Sequence(bpelModel);
+		
+		// Check if root conversation
+		if (conv.getParent() instanceof Model) {
+			
+			// Set the name of the process
+			bpelModel.getBPELProcess().setName(conv.getLocatedName().getName()+"_"+
+					conv.getLocatedName().getRole().getName());
+			
+			// Get contract
+			Contract contract=ModelChangeUtils.getContract(context, conv.getLocatedName().getRole().getName());
+			
+			if (contract != null) {
+				roleNamespace = contract.getNamespace();
+				
+				// Set namespace
+				bpelModel.getBPELProcess().setTargetNamespace(contract.getNamespace());
+				
+				// Add other namespaces
+				for (org.savara.contract.model.Namespace ns : contract.getNamespaces()) {
+					bpelModel.getBPELProcess().initNamespace(ns.getURI(), ns.getPrefix());
+				}
+			}
+			
+			String namespace=((Model)conv.getModel()).
+						getNamespace().getName();
+
+			String ctype=null;
+			
+			// Check if conversation has a 'conforms to' reference
+			if (conv.getConformsTo().size() > 0) {
+				// Set conversation type based on first 'conforms to'
+				// reference
+				ConformanceReference cref=conv.getConformsTo().get(0);
+				
+				ctype = cref.getNamespace()+"."+
+						cref.getLocalpart()+"@"+
+						cref.getLocatedRole();
+			} else {
+				// Set conversation type based on conversation
+				// namespace and name
+				ctype = namespace+"."+
+						conv.getLocatedName().getName()+"@"+
+						conv.getLocatedName().getRole().getName();
+			}
+			
+			if (ctype != null) {
+				bpelModel.getBPELProcess().setConversationType(ctype);
+			}
+			
+			// Add import for this role
+			addImport(context, bpelModel, conv, context.getRole());
+
+			// Add import statements for partner roles
+			java.util.List<Role> roles=conv.getRoles();
+			
+			for (int i=0; i < roles.size(); i++) {
+				addImport(context, bpelModel, conv, roles.get(i));
+			}
+			
+			// Add import for partner link types
+			Import imp=new Import(bpelModel);
+			imp.setLocation(bpelModel.getBPELProcess().getName()+"Artifacts.wsdl");
+			imp.setNamespace(roleNamespace);
+			imp.setImportType("http://schemas.xmlsoap.org/wsdl/");
+			
+			bpelModel.getBPELProcess().addImport(imp, -1);
+			
+			// Add sequence to model
+			bpelModel.getBPELProcess().setActivity(seq);
+			
+		} else if (context.getParent() instanceof Sequence) {
+			
+			// Create a scope
+			Scope scope=new Scope(bpelModel);
+
+			((Sequence)context.getParent()).addActivity(scope, -1);
+			
+			// NOTE: Currently needs to be added after adding scope
+			// to parent sequence, as otherwise the DOM element
+			// associated with the 'seq' sequence becomes
+			// disconnected from the actual document - due to
+			// the fact that added elements are copied (in
+			// turn due to an xml parser exception).
+			scope.setActivity(seq);
+		}
+
+		// Process the activities within the conversation
+		java.util.List<Activity> acts=conv.getBlock().getContents();
+		
+		Object parent=context.getParent();
+		
+		context.setParent(seq);
+		
+		for (int i=0; i < acts.size(); i++) {
+			if ((acts.get(i) instanceof Definition) == false) {
+				context.insert(model, acts.get(i), null);
+			}
+		}
+		
+		// Reset old parent
+		context.setParent(parent);
+		
+		return(true);
+	}
+	
+	/**
+	 * This method adds an import statement for the contract associated with the
+	 * supplied role.
+	 * 
+	 * @param context The context
+	 * @param bpelModel The model
+	 * @param conv The conversation
+	 * @param role The role
+	 */
+	protected void addImport(ModelChangeContext context, DefaultBPELLanguageModel bpelModel,
+								Conversation conv, Role role) {
+		if (role.getAnnotations().containsKey(Contract.class.getName())) {
+			Contract contract=(Contract)role.getAnnotations().get(Contract.class.getName());
+
+			boolean gen=false;
+			
+			java.util.Iterator<Interface> iter=contract.getInterfaces().iterator();
+			
+			while (gen == false && iter.hasNext()) {
+				Interface intf=iter.next();
+				
+				if (intf.getMessageExchangePatterns().size() > 0) {
+					gen = true;
+				}
+			}
+			
+			if (gen) {
+				String fileName=GeneratorUtil.getWSDLFileName(role,
+								conv.getLocatedName().getName(), "");
+				
+				Import imp=new Import(bpelModel);
+				
+				imp.setLocation(fileName);
+				imp.setNamespace(contract.getNamespace());
+				imp.setImportType("http://schemas.xmlsoap.org/wsdl/");
+				
+				bpelModel.getBPELProcess().addImport(imp, -1);
+			}
+		}
+	}
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/ConversationInteractionModelChangeRule.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/ConversationInteractionModelChangeRule.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/ConversationInteractionModelChangeRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,472 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.change;
+
+import javax.xml.namespace.QName;
+
+import org.savara.bpel.model.*;
+import org.savara.bpel.model.component.*;
+import org.savara.bpel.model.util.*;
+import org.savara.contract.model.Contract;
+import org.savara.contract.model.Interface;
+import org.savara.wsdl.util.WSDLGeneratorUtil;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This is the model change rule for the Conversation Interaction.
+ */
+ at RegistryInfo(extension=ModelChangeRule.class,notation=BPELNotation.NOTATION_CODE)
+public class ConversationInteractionModelChangeRule extends AbstractBPELModelChangeRule {
+
+	private static final String INTERFACE_NAME = "interfaceName";
+
+	/**
+	 * This method determines whether the rule is appropriate
+	 * for the supplied type of model, parent (in the context) and inserted
+	 * model object.
+	 *
+	 * @param context The context
+	 * @param model The model
+	 * @param mobj The model object being inserted
+	 * @param ref The optional reference model object
+	 * @return Whether the rule supports the supplied information
+	 */
+	@Override
+	public boolean isInsertSupported(ModelChangeContext context,
+					Model model, ModelObject mobj,
+					ModelObject ref) {
+		boolean ret=false;
+		
+		if (mobj instanceof ConversationInteraction &&
+				super.isInsertSupported(context, model, mobj, ref)) {
+			ret = true;
+		}
+		
+		return(ret);
+	}
+
+	/**
+	 * This method adds a new model object, within a
+	 * parent model object, with the details supplied in
+	 * another model object. The supplied model object
+	 * will usually be from a different model representation
+	 * (e.g. due to a merge), so the details will be
+	 * copied and placed in the representation associated
+	 * with the supplied model and parent model object.<p>
+	 * <p>
+	 * If a reference model object is supplied, then the
+	 * insertion will occur relative to it. If the reference
+	 * object is a block, then it means that the insertion
+	 * should occur at the end of the block. Otherwise the
+	 * new model object should be inserted before the
+	 * reference object, within the containing block.<p>
+	 * <p>
+	 * If the reference object is not supplied, then the
+	 * new model object should be inserted at the end of
+	 * the behaviour associated with the parent in the model
+	 * change context.
+	 * 
+	 * @param context The context
+	 * @param model The model being changed
+	 * @param mobj The model object details to be inserted
+	 * @param ref The optional reference model object
+	 * @return Whether the change has been applied
+	 */
+	@Override
+	public boolean insert(ModelChangeContext context,
+				Model model, ModelObject mobj, ModelObject ref) {
+		BPELLanguageModel bpelModel=(BPELLanguageModel)model;
+		ConversationInteraction interaction=(ConversationInteraction)mobj;
+		boolean ret=false;
+		AbstractInteraction act=null;
+		PartnerLink pl=new PartnerLink(bpelModel);
+		Role role=null;
+		String portType=null;	
+		String varName=null; //InteractionPatterns.getVariableName(interaction);
+		Interface intf=null;
+			
+		if (interaction.getEnclosingDefinition() != null) {
+			role = interaction.getEnclosingDefinition().
+						getLocatedName().getRole();
+		}
+		
+		// Identify port type role
+		String prefix=null;
+		
+		String mainPrefix=null;
+		
+		Contract contract=ModelChangeUtils.getContract(context, context.getRole().getName());
+		if (contract != null) {
+			mainPrefix = bpelModel.getBPELProcess().addNamespace(contract.getNamespace());
+		}
+		
+		Role roleType=null;
+		
+		if (InteractionUtil.isRequest(interaction)) {
+			roleType = interaction.getToRole();
+			if (roleType == null) {
+				roleType = role;
+			}
+		} else {
+			roleType = interaction.getFromRole();
+			if (roleType == null) {
+				roleType = role;
+			}
+		}
+		
+		if (roleType != null) {
+			contract = ModelChangeUtils.getContract(context, roleType.getName());
+
+			if (contract != null) {			
+				if (interaction.getAnnotations().containsKey(INTERFACE_NAME)) {
+					String intfName=(String)interaction.getAnnotations().get(INTERFACE_NAME);
+					intf = contract.getInterface(intfName);
+					
+					if (intf == null) {
+						// Try localpart
+						javax.xml.namespace.QName qname=javax.xml.namespace.QName.valueOf(intfName);
+						intf = contract.getInterface(qname.getLocalPart());
+					}
+				} else if (contract.getInterfaces().size() > 0) {
+					intf = contract.getInterfaces().iterator().next();
+				}
+			}
+		}
+		
+		if (intf != null) {
+			portType = intf.getName();
+			
+			prefix = bpelModel.getBPELProcess().addNamespace(intf.getNamespace());
+			
+			if (prefix != null) {
+				portType = prefix+":"+portType;
+			}
+		}
+
+		// Create variable
+		//if (varName != null) {
+			QName qname=null;
+			if (InteractionUtil.isRequest(interaction)) {
+				qname = WSDLGeneratorUtil.getRequestMessageType(contract.getNamespace(),
+									interaction.getMessageSignature().getOperation());
+			} else if (InteractionPatterns.isFaultResponse(interaction)) {
+				qname = WSDLGeneratorUtil.getFaultMessageType(contract.getNamespace(),
+						InteractionPatterns.getFaultName(interaction));
+			} else {
+				qname = WSDLGeneratorUtil.getResponseMessageType(contract.getNamespace(),
+									interaction.getMessageSignature().getOperation());
+			}
+			
+			varName = qname.getLocalPart()+"Var";
+
+			org.savara.bpel.model.component.Variable var=
+					bpelModel.getBPELProcess().getVariable(varName);
+
+			if (var == null) {
+				var = new org.savara.bpel.model.component.Variable(bpelModel);
+				var.setName(varName);
+				
+				String mesgType=qname.getLocalPart();
+				
+				// Find namespace prefix
+				if (qname.getNamespaceURI() != null) {
+					String pfix=bpelModel.getBPELProcess().addNamespace(qname.getNamespaceURI());
+					
+					if (pfix != null) {
+						mesgType = pfix+":"+mesgType;
+					}
+				}
+				
+				var.setMessageType(mesgType);
+				
+				bpelModel.getBPELProcess().addVariable(var, -1);
+			}
+		//}
+
+		// Check if send or receive
+		if (InteractionUtil.isSend(interaction)) {
+			
+			// TODO: Record variables against relevant interaction
+			// based activity - probably only mechanism for
+			// establishing message type
+
+			if (InteractionUtil.isRequest(interaction)) {
+				
+				if (InteractionPatterns.isFaultHandlerRequired(interaction)) {
+					
+					Scope scope=new Scope(bpelModel);
+					
+					if (context.getParent() instanceof Sequence) {
+						((Sequence)context.getParent()).addActivity(scope, -1);
+					}
+					
+					FaultHandlers fhs=new FaultHandlers(bpelModel);
+					
+					Sequence seq=new Sequence(bpelModel);
+					
+					scope.setActivity(seq);
+					scope.setFaultHandlers(fhs);
+					
+					context.setParent(scope.getActivity());
+				}
+				
+				act = new Invoke(bpelModel);
+				
+				pl.setPartnerRole(interaction.getToRole().getName()+"Requester");
+				pl.setName(role.getName()+"To"+interaction.getToRole().getName());
+				
+				String plt=role.getName()+"To"+interaction.getToRole().getName()+"LT";
+				
+				if (mainPrefix != null) {
+					plt = mainPrefix+":"+plt;
+				}
+				
+				pl.setPartnerLinkType(plt);
+
+				//portType = interaction.getToRole().getName()+"PT";
+				
+				if (varName != null) {
+					((Invoke)act).setInputVariable(varName);
+				}
+				
+			} else {
+				act = new Reply(bpelModel);
+		
+				pl.setMyRole(role.getName()+"Service");
+				pl.setName(interaction.getToRole().getName()+"To"+role.getName());
+				
+				String plt=interaction.getToRole().getName()+"To"+role.getName()+"Service"+"LT";
+				
+				if (mainPrefix != null) {
+					plt = mainPrefix+":"+plt;
+				}
+				
+				pl.setPartnerLinkType(plt);
+
+				//portType = role.getName()+"PT";
+				
+				if (InteractionPatterns.isFaultResponse(interaction)) {
+					String faultName=InteractionPatterns.getFaultName(interaction);
+					
+					// Find namespace prefix
+					//if (intf != null) {
+					//	String prefix=bpelModel.getBPELProcess().addNamespace(intf.getNamespace());
+						
+						if (prefix != null) {
+							faultName = prefix+":"+faultName;
+						}
+					//}
+					
+					((Reply)act).setFaultName(faultName);
+				}
+				
+				if (varName != null) {
+					((Reply)act).setVariable(varName);
+				}
+			}
+		} else if (InteractionPatterns.isResponseInFaultHandler(interaction) == false) {
+			
+			if (InteractionPatterns.isSyncNormalResponse(interaction)) {
+				
+				//System.out.println("ADD RESP VAR TO PRECEDING");
+				if (context.getParent() instanceof Sequence) {
+					java.util.List<BPELActivity> acts=
+							((Sequence)context.getParent()).getActivities();
+					
+					if (acts.size() > 0 &&
+							acts.get(acts.size()-1) instanceof Invoke) {
+						Invoke invoke=(Invoke)acts.get(acts.size()-1);
+						
+						invoke.setOutputVariable(varName);
+					}
+				}
+				
+			} else if (InteractionPatterns.isInteractionPickPathTrigger(interaction) == false) {
+				act = new Receive(bpelModel);
+				
+				String intfName=(String)interaction.getAnnotations().get("interfaceName");
+				
+				if (intfName != null && intfName.trim().length() > 0) {
+					intfName = javax.xml.namespace.QName.valueOf(intfName).getLocalPart();
+				} else {
+					intfName = role.getName();
+				}
+	
+				if (InteractionUtil.isRequest(interaction)) {
+		
+					pl.setMyRole(intfName); //role.getName()+"Service");
+					//pl.setPartnerRole(interaction.getToRole().getName());
+					pl.setName(interaction.getFromRole().getName()+"To"+role.getName());
+					
+					String plt=interaction.getFromRole().getName()+"To"+role.getName()+"Service"+"LT";
+					
+					if (mainPrefix != null) {
+						plt = mainPrefix+":"+plt;
+					}
+					
+					pl.setPartnerLinkType(plt);
+	
+					//portType = role.getName()+"PT";
+				} else {
+					pl.setMyRole(intfName); //role.getName()+"Requester");
+					pl.setPartnerRole(interaction.getFromRole().getName()+"Service");
+					pl.setName(role.getName()+"To"+interaction.getFromRole().getName());
+					
+					String plt=role.getName()+"To"+interaction.getFromRole().getName()+"Requester"+"LT";
+					
+					if (mainPrefix != null) {
+						plt = mainPrefix+":"+plt;
+					}
+					
+					pl.setPartnerLinkType(plt);
+	
+					//portType = role.getName()+
+					//		interaction.getFromRole().getName()+"CallbackPT";				
+				}
+
+				if (varName != null) {
+					((Receive)act).setVariable(varName);
+				}
+				
+				// Check if create instance
+				if (org.scribble.model.util.InteractionUtil.isInitialInteraction(interaction)) {
+					((Receive)act).setCreateInstance(true);
+				}
+			}
+		}
+		
+		// TODO: Possibly if the channel is set, then
+		// might be a callback channel, so could use
+		// channel name to reflect callback port
+
+		// TODO: If both myRole and partnerRole are specified
+		// then one is a callback porttype
+		
+		if (act != null) {
+			
+			// Set the name
+			act.setName(InteractionUtil.getName(interaction));
+			
+			if (context.getParent() instanceof Sequence) {
+				((Sequence)context.getParent()).addActivity(act, -1);
+				
+				ret = true;
+			}	
+
+			// Create partner link
+			PartnerLink other=
+					bpelModel.getBPELProcess().getPartnerLink(pl.getName());
+			if (other == null) {
+				bpelModel.getBPELProcess().addPartnerLink(pl, -1);
+			} else {
+				if (other.getPartnerRole() == null &&
+						pl.getPartnerRole() != null) {
+					other.setPartnerRole(pl.getPartnerRole());
+				}
+				if (other.getMyRole() == null &&
+						pl.getMyRole() != null) {
+					other.setMyRole(pl.getMyRole());
+				}
+			}
+			
+			// Set details on interaction
+			act.setPartnerLink(pl.getName());
+			
+			act.setPortType(portType);
+	
+			if (interaction.getMessageSignature() != null) {
+				act.setOperation(interaction.getMessageSignature().getOperation());
+			}
+		}
+		
+		return(ret);
+	}
+
+	/**
+	 * This method determines whether the rule is appropriate
+	 * for the supplied type of model, parent (in the context)
+	 * and modified model object.
+	 *
+	 * @param context The context
+	 * @param model The model
+	 * @param fromObj The source model object
+	 * @param toObj The model object to be updated
+	 * @return Whether the rule supports the supplied information
+	 */
+	@Override
+	public boolean isUpdateSupported(ModelChangeContext context,
+					Model model, ModelObject fromObj, ModelObject toObj) {
+		boolean ret=false;
+		
+		if (fromObj instanceof ConversationInteraction &&
+				toObj instanceof ConversationInteraction &&
+				model instanceof BPELLanguageModel) {
+			ret = true;
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method modifies an existing model object, within a
+	 * parent model object, with the details supplied in
+	 * another model object.
+	 * 
+	 * @param context The context
+	 * @param model The model being changed
+	 * @param fromObj The source model object
+	 * @param toObj The model object to be updated
+	 * @return Whether the change has been applied
+	 */
+	@Override
+	public boolean update(ModelChangeContext context,
+				Model model, ModelObject fromObj, ModelObject toObj) {
+		boolean ret=false;
+		//BPELLanguageModel bpelModel=(BPELLanguageModel)model;
+		//ConversationInteraction fromInteraction=(ConversationInteraction)fromObj;
+		//ConversationInteraction toInteraction=(ConversationInteraction)toObj;
+		
+		return(ret);
+	}
+		
+	/**
+	 * This method determines whether the rule is appropriate
+	 * for the supplied type of model, parent (in the context)
+	 * and deleted model object.
+	 * 
+	 * @param context The context
+	 * @param model The model
+	 * @param mobj The model object to be removed
+	 * @return Whether the rule supports the supplied information
+	 */
+	@Override
+	public boolean isDeleteSupported(ModelChangeContext context,
+						Model model, ModelObject mobj) {
+		boolean ret=false;
+		
+		if (mobj instanceof ConversationInteraction &&
+				super.isDeleteSupported(context, model, mobj)) {
+			ret = true;
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/IfModelChangeRule.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/IfModelChangeRule.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/IfModelChangeRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,483 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.change;
+
+import javax.xml.namespace.QName;
+
+import org.savara.bpel.model.*;
+import org.savara.bpel.model.component.*;
+import org.savara.bpel.model.util.InteractionUtil;
+import org.savara.contract.model.Contract;
+import org.savara.contract.model.Interface;
+import org.savara.wsdl.util.WSDLGeneratorUtil;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This is the model change rule for the If.
+ */
+ at RegistryInfo(extension=ModelChangeRule.class,notation=BPELNotation.NOTATION_CODE)
+public class IfModelChangeRule extends AbstractModelChangeRule {
+
+	/**
+	 * This method determines whether the rule is appropriate
+	 * for the supplied type of model, parent (in the context) and
+	 * model object.
+	 *
+	 * @param context The context
+	 * @param model The model
+	 * @param mobj The model object causing the change
+	 * @param ref The optional reference model object
+	 * @return Whether the rule supports the supplied information
+	 */
+	@Override
+	public boolean isInsertSupported(ModelChangeContext context,
+				Model model, ModelObject mobj, ModelObject ref) {
+		boolean ret=false;
+		
+		if (mobj instanceof org.scribble.conversation.model.If &&
+				model instanceof DefaultBPELLanguageModel) {
+			ret = true;
+		}
+		
+		return(ret);
+	}
+
+	/**
+	 * This method adds a new model object, within a
+	 * parent model object, with the details supplied in
+	 * another model object. The supplied model object
+	 * will usually be from a different model representation
+	 * (e.g. due to a merge), so the details will be
+	 * copied and placed in the representation associated
+	 * with the supplied model and parent model object.<p>
+	 * <p>
+	 * If a reference model object is supplied, then the
+	 * insertion will occur relative to it. If the reference
+	 * object is a block, then it means that the insertion
+	 * should occur at the end of the block. Otherwise the
+	 * new model object should be inserted before the
+	 * reference object, within the containing block.<p>
+	 * <p>
+	 * If the reference object is not supplied, then the
+	 * new model object should be inserted at the end of
+	 * the behaviour associated with the parent in the model
+	 * change context.
+	 * 
+	 * @param context The context
+	 * @param model The model being changed
+	 * @param mobj The model object details to be inserted
+	 * @param ref The optional reference model object
+	 * @return Whether the change has been applied
+	 */
+	@Override
+	public boolean insert(ModelChangeContext context,
+				Model model, ModelObject mobj, ModelObject ref) {
+		DefaultBPELLanguageModel bpelModel=(DefaultBPELLanguageModel)model;
+		org.scribble.conversation.model.If elem=
+					 (org.scribble.conversation.model.If)mobj;
+		java.util.List<Block> paths=elem.getPaths();
+		
+		// Check if the 'If' construct is to handle responses
+		// to a preceding request being sent
+		if (InteractionPatterns.isResponseAndFaultHandler(elem)) {
+			
+			if (context.getParent() instanceof Sequence) {
+				// Find fault handler
+				Sequence seq=(Sequence)context.getParent();
+				Scope scope=new Scope(bpelModel,
+						(org.w3c.dom.Element)seq.getDOMElement().getParentNode());
+				FaultHandlers fh=scope.getFaultHandlers();
+				
+				for (int i=0; i < paths.size(); i++) {
+					Block path=paths.get(i);
+					
+					if (path.getContents().size() > 0) {
+						Activity act=path.getContents().get(0);
+						Sequence subseq=null;
+						
+						if (act instanceof Interaction &&
+								InteractionPatterns.isFaultResponse(
+										(Interaction)act)) {
+							String faultName=InteractionPatterns.getFaultName((Interaction)act);
+							
+							Contract contract = ModelChangeUtils.getContract(context,
+										((Interaction)act).getFromRole().getName());
+							
+							// Define fault message type
+							QName qname= WSDLGeneratorUtil.getFaultMessageType(contract.getNamespace(),
+												faultName);
+							
+							String faultVarName=qname.getLocalPart()+"Var";
+							String mesgType=InteractionPatterns.getMessageTypeLocalPart((Interaction)act);
+							//String namespace=InteractionPatterns.getMessageTypeNameSpace((Interaction)act);
+					
+							Catch c=new Catch(bpelModel);
+							c.setFaultVariable(faultVarName);
+							
+							// Find namespace prefix
+							if (qname != null) {
+								String prefix=bpelModel.getBPELProcess().addNamespace(qname.getNamespaceURI());
+								
+								if (prefix != null) {
+									mesgType = prefix+":"+qname.getLocalPart();
+									faultName = prefix+":"+faultName;
+								}
+							}
+							
+							c.setFaultName(faultName);
+							c.setFaultMessageType(mesgType);
+							
+							// Add catch to fault handler
+							fh.addCatch(c);
+							
+							subseq = new Sequence(bpelModel);
+							c.setActivity(subseq);
+						} else {
+							subseq = seq;
+
+							java.util.List<BPELActivity> acts=
+								((Sequence)context.getParent()).getActivities();
+							
+							if (acts.size() > 0 && act instanceof Interaction &&
+									acts.get(acts.size()-1) instanceof Invoke) {
+								Contract contract = ModelChangeUtils.getContract(context,
+										((Interaction)act).getFromRole().getName());
+							
+								QName qname=null;
+								if (InteractionUtil.isRequest((Interaction)act)) {
+									qname = WSDLGeneratorUtil.getRequestMessageType(contract.getNamespace(),
+											((Interaction)act).getMessageSignature().getOperation());
+								} else if (InteractionPatterns.isFaultResponse((Interaction)act)) {
+									qname = WSDLGeneratorUtil.getFaultMessageType(contract.getNamespace(),
+											InteractionPatterns.getFaultName((Interaction)act));
+								} else {
+									qname = WSDLGeneratorUtil.getResponseMessageType(contract.getNamespace(),
+														((Interaction)act).getMessageSignature().getOperation());
+								}
+
+								String varName=qname.getLocalPart()+"Var"; //InteractionPatterns.getVariableName((Interaction)act);
+								Invoke invoke=(Invoke)acts.get(acts.size()-1);
+								
+								invoke.setOutputVariable(varName);
+
+								// Create variable
+								if (varName != null) {
+									createVariable(context, varName, (Interaction)act, bpelModel);
+								}
+							}
+						}
+						
+						Object parent=context.getParent();
+						
+						context.setParent(subseq);
+						
+						for (int j=1; j < path.getContents().size(); j++) {
+							context.insert(model, path.getContents().get(j), null);
+						}
+						
+						context.setParent(parent);
+					}
+				}
+			} else {
+				// TODO: Error handling
+			}
+		} else if (InteractionPatterns.isSwitch(elem)) {
+			Pick act=new Pick(bpelModel);
+			
+			if (context.getParent() instanceof Sequence) {
+				((Sequence)context.getParent()).addActivity(act, -1);
+			}
+			
+			Role role=null;
+		
+			if (elem.getEnclosingDefinition() != null) {
+				role = elem.getEnclosingDefinition().
+							getLocatedName().getRole();
+			}
+
+			for (int i=0; i < paths.size(); i++) {
+				Block path=paths.get(i);
+				
+				Sequence seq=new Sequence(bpelModel);
+				
+				// Process the activities within the conversation
+				java.util.List<Activity> acts=path.getContents();
+							
+				Object parent=context.getParent();
+				
+				context.setParent(seq);
+				
+				for (int j=0; j < acts.size(); j++) {
+					context.insert(model, acts.get(j), null);
+				}
+				
+				context.setParent(parent);
+				
+				Interaction recv=InteractionPatterns.getPickPathInteraction(path);
+				
+				OnMessage onm=new OnMessage(bpelModel);
+				onm.setActivity(seq);
+				
+				PartnerLink pl=new PartnerLink(bpelModel);
+				String portType=null;
+				
+				String prevPLName=role.getName()+"To"+recv.getFromRole().getName();
+				
+				String mainPrefix=null;
+				
+				Contract contract=ModelChangeUtils.getContract(context, context.getRole().getName());
+				if (contract != null) {
+					mainPrefix = bpelModel.getBPELProcess().addNamespace(contract.getNamespace());
+				}
+				
+				// Check if partner link already exists in
+				// other direction
+				PartnerLink prev=
+					bpelModel.getBPELProcess().getPartnerLink(prevPLName);
+
+				if (InteractionUtil.isRequest(recv) && prev == null) {
+					
+					pl.setMyRole(role.getName()+"Service");
+					//pl.setPartnerRole(interaction.getToRole().getName());
+					pl.setName(recv.getFromRole().getName()+"To"+role.getName());
+					
+					String plt=recv.getFromRole().getName()+"To"+role.getName()+"Service"+"LT";
+					
+					if (mainPrefix != null) {
+						plt = mainPrefix+":"+plt;
+					}
+					
+					pl.setPartnerLinkType(plt);
+
+					contract = ModelChangeUtils.getContract(context, role.getName());
+					
+					if (contract != null && contract.getInterfaces().size() > 0) {
+						Interface intf = contract.getInterfaces().iterator().next();
+						
+						portType = intf.getName();
+						
+						String prefix = bpelModel.getBPELProcess().addNamespace(intf.getNamespace());
+						
+						if (prefix != null) {
+							portType = prefix+":"+portType;
+						}
+					}
+				} else {
+					pl.setMyRole(role.getName()+"Requester");
+					pl.setPartnerRole(recv.getFromRole().getName()+"Service");
+					pl.setName(role.getName()+"To"+recv.getFromRole().getName());
+					
+					String plt=role.getName()+"To"+recv.getFromRole().getName()+"Requester"+"LT";
+					
+					if (mainPrefix != null) {
+						plt = mainPrefix+":"+plt;
+					}
+					
+					pl.setPartnerLinkType(plt);
+
+					//portType = role.getName()+
+					//		recv.getFromRole().getName()+"CallbackPT";				
+
+					contract = ModelChangeUtils.getContract(context, recv.getFromRole().getName());
+					if (contract != null && contract.getInterfaces().size() > 0) {
+						Interface intf = contract.getInterfaces().iterator().next();
+						
+						portType = intf.getName();
+						
+						String prefix = bpelModel.getBPELProcess().addNamespace(intf.getNamespace());
+						
+						if (prefix != null) {
+							portType = prefix+":"+portType;
+						}
+					}
+				}
+				
+				QName qname=null;
+				if (InteractionUtil.isRequest(recv)) {
+					qname = WSDLGeneratorUtil.getRequestMessageType(contract.getNamespace(),
+							recv.getMessageSignature().getOperation());
+				} else if (InteractionPatterns.isFaultResponse(recv)) {
+					qname = WSDLGeneratorUtil.getFaultMessageType(contract.getNamespace(),
+							InteractionPatterns.getFaultName(recv));
+				} else {
+					qname = WSDLGeneratorUtil.getResponseMessageType(contract.getNamespace(),
+							recv.getMessageSignature().getOperation());
+				}
+
+				String varName=qname.getLocalPart()+"Var"; //InteractionPatterns.getVariableName(recv);
+				
+				if (varName != null) {
+					onm.setVariable(varName);
+				}
+				
+				// Create partner link
+				PartnerLink other=
+					bpelModel.getBPELProcess().getPartnerLink(pl.getName());
+
+				if (other == null) {
+					bpelModel.getBPELProcess().addPartnerLink(pl, -1);
+				} else {
+					if (other.getPartnerRole() == null &&
+							pl.getPartnerRole() != null) {
+						other.setPartnerRole(pl.getPartnerRole());
+					}
+					if (other.getMyRole() == null &&
+							pl.getMyRole() != null) {
+						other.setMyRole(pl.getMyRole());
+					}
+				}
+				
+				// Create variable
+				if (varName != null) {
+					createVariable(context, varName, recv, bpelModel);
+				}
+				
+				// Check if create instance
+				if (org.scribble.model.util.InteractionUtil.isInitialInteraction(recv)) {
+					act.setCreateInstance(true);
+				}
+				
+				// Set details on interaction
+				onm.setPartnerLink(pl.getName());
+				onm.setPortType(portType);
+
+				MessageSignature ms=recv.getMessageSignature();
+				if (ms.getOperation() != null) {
+					onm.setOperation(ms.getOperation());
+				}
+				
+				act.addOnMessage(onm, -1);
+			}
+			
+		} else {
+			If act=new If(bpelModel);
+			
+			if (context.getParent() instanceof Sequence) {
+				((Sequence)context.getParent()).addActivity(act, -1);
+			}
+			
+			for (int i=0; i < paths.size(); i++) {
+				Block path=paths.get(i);
+				
+				Sequence seq=new Sequence(bpelModel);
+				
+				// Process the activities within the conversation
+				java.util.List<Activity> acts=path.getContents();
+							
+				Object parent=context.getParent();
+				
+				context.setParent(seq);
+				
+				for (int j=0; j < acts.size(); j++) {
+					context.insert(model, acts.get(j), null);
+				}
+				
+				context.setParent(parent);
+	
+				if (i == 0) {
+					act.setActivity(seq);
+				} else if (i == elem.getPaths().size()-1) {
+					Else construct=new Else(bpelModel);
+					construct.setActivity(seq);
+					
+					act.setElsePath(construct);
+				} else {
+					Elseif construct=new Elseif(bpelModel);
+					
+					construct.setActivity(seq);
+					
+					act.addElseIfPath(construct);
+				}
+			}
+		}
+				
+		return(true);
+	}
+	
+	/**
+	 * This method creates a variable, if one does not already exist for the
+	 * supplied name, with the message type associated with the supplied
+	 * interaction.
+	 * 
+	 * @param varName The variable name
+	 * @param interaction The interaction associated with the variable
+	 * @param bpelModel The BPEL model
+	 */
+	protected void createVariable(ModelChangeContext context, String varName,
+						Interaction interaction, BPELLanguageModel bpelModel) {
+		org.savara.bpel.model.component.Variable var=
+					bpelModel.getBPELProcess().getVariable(varName);
+
+		if (var == null) {
+			Role role=null;
+			
+			if (interaction.getEnclosingDefinition() != null) {
+				role = interaction.getEnclosingDefinition().
+							getLocatedName().getRole();
+			}
+
+			var = new org.savara.bpel.model.component.Variable(bpelModel);
+			var.setName(varName);
+			
+			Role roleType=null;
+			Contract contract=null;
+			
+			if (InteractionUtil.isRequest(interaction)) {
+				roleType = interaction.getToRole();
+				if (roleType == null) {
+					roleType = role;
+				}
+			} else {
+				roleType = interaction.getFromRole();
+				if (roleType == null) {
+					roleType = role;
+				}
+			}
+			
+			if (roleType != null) {
+				contract = ModelChangeUtils.getContract(context, roleType.getName());
+			}
+
+			QName qname=null;
+			if (InteractionUtil.isRequest(interaction)) {
+				qname = WSDLGeneratorUtil.getRequestMessageType(contract.getNamespace(),
+									interaction.getMessageSignature().getOperation());
+			} else {
+				qname = WSDLGeneratorUtil.getResponseMessageType(contract.getNamespace(),
+									interaction.getMessageSignature().getOperation());
+			}
+
+			String mesgType=qname.getLocalPart();
+			
+			// Find namespace prefix
+			if (qname.getNamespaceURI() != null) {
+				String pfix=bpelModel.getBPELProcess().addNamespace(qname.getNamespaceURI());
+				
+				if (pfix != null) {
+					mesgType = pfix+":"+mesgType;
+				}
+			}
+			
+			var.setMessageType(mesgType);
+			
+			bpelModel.getBPELProcess().addVariable(var, -1);
+		}
+	}
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/InteractionPatterns.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/InteractionPatterns.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/InteractionPatterns.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,382 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.change;
+
+import org.savara.bpel.model.util.InteractionUtil;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class provides utility functions for detecting
+ * patterns related to interactions.
+ */
+public class InteractionPatterns {
+
+	private static final String FAULT_NAME = "faultName";
+	private static final String MESSAGE_TYPE_LOCALPART = "messageTypeLocalPart";
+	private static final String MESSAGE_TYPE_NAMESPACE = "messageTypeNameSpace";
+
+	/**
+	 * This method checks whether the supplied interaction
+	 * is a request that requires a scope with associated
+	 * fault handlers.
+	 * 
+	 * @param interaction The interaction
+	 * @return Whether the interaction is a request requiring
+	 * 			an outer fault handler
+	 */
+	public static boolean isFaultHandlerRequired(org.scribble.model.Interaction interaction) {
+		boolean ret=false;
+		
+		// Check if interaction is an invoke, and followed
+		// by a choice representing a normal and multiple
+		// fault responses
+		if (InteractionUtil.isRequest(interaction) &&
+				interaction.getRequestLabel() != null) {
+			
+			if (interaction.getParent() instanceof
+						org.scribble.model.Block) {
+				org.scribble.model.Block block=
+					(org.scribble.model.Block)interaction.getParent();
+				
+				int pos=block.getContents().indexOf(interaction);
+				
+				if (pos != -1 && pos < block.getContents().size()-1) {
+					org.scribble.model.Activity act=
+						block.getContents().get(pos+1);
+					
+					if (act instanceof org.scribble.conversation.model.If) {
+						
+						// Need to check if each path receives a
+						// response (normal and fault)
+						org.scribble.conversation.model.If choice=
+							(org.scribble.conversation.model.If)act;
+						
+						if (choice.getPaths().size() > 0) {
+							ret = true;							
+						}
+						
+						for (int i=0; ret &&
+								i < choice.getPaths().size(); i++) {
+							
+							org.scribble.model.Block path=
+								choice.getPaths().get(i);
+							
+							if (path.getContents().size() == 0 ||
+									(path.getContents().get(0) instanceof Interaction) == false ||
+									InteractionUtil.isRequest((Interaction)
+											path.getContents().get(0))) {
+								ret = false;
+							}
+						}
+					}
+				}
+			}
+		}
+		
+		return(ret);
+	}
+	
+	// TODO: Method to detect if normal response, which needs
+	// to enhance the invoke (and subsequent activities following
+	// the invoke), or a fault response needing to
+	// place itself and subsequent activities in a fault handler.
+	// Methods need to return (and set) the relevant sequence
+	// to use for subsequent activities.
+	
+	public static boolean isResponseAndFaultHandler(If choice) {
+		boolean ret=false;
+		
+		// Obtain interaction prior to 'If'
+		if (choice.getPaths().size() > 0 &&
+				choice.getParent() instanceof
+				org.scribble.model.Block) {
+			org.scribble.model.Block block=
+				(org.scribble.model.Block)choice.getParent();
+		
+			int pos=block.getContents().indexOf(choice);
+		
+			if (pos != -1 && pos > 0) {
+				org.scribble.model.Activity act=
+					block.getContents().get(pos-1);
+			
+				if (act instanceof Interaction &&
+						InteractionUtil.isSend((Interaction)act) &&
+						InteractionUtil.isRequest((Interaction)act) &&
+						((Interaction)act).getRequestLabel() != null) {
+					
+					// Check if each path has a response/fault associated
+					// with the preceding request
+					String requestLabel=
+						((Interaction)act).getRequestLabel();
+					
+					java.util.List<Block> paths=choice.getPaths();
+					int matched=0;
+					
+					for (int i=0; i < paths.size(); i++) {
+						if (paths.get(i).getContents().size() > 0) {
+							Interaction in=getPickPathInteraction(paths.get(i));
+							
+							if (in != null &&
+									InteractionUtil.isResponse(in) &&
+									in.getReplyToLabel().equals(requestLabel)) {
+								matched++;
+							}
+						}
+					}
+					
+					if (matched == paths.size()) {
+						ret = true;
+					}
+				}
+			}
+		}
+
+		return(ret);
+	}
+	
+	/**
+	 * This method obtains the interaction that triggers a
+	 * specified path in a BPEL pick activity.
+	 * 
+	 * @param path The path
+	 * @return The interaction that triggers the path in
+	 * 				the pick activity
+	 */
+	public static Interaction getPickPathInteraction(Block path) {
+		Interaction ret=null;
+		
+		// TODO: This method is the opposite of the
+		// 'isInteractionPickPathTrigger', so needs to be
+		// updated to reflect any changes to that method
+		
+		if (path.getContents().size() > 0) {
+			org.scribble.model.Activity sub=
+				path.getContents().get(0);
+								
+			// Check if scope
+			if (sub instanceof Compose) {
+				Definition defn=((Compose)sub).getDefinition();
+				org.scribble.model.Behaviour b=null;
+				
+				for (int j=0; b == null &&
+							j < defn.getBlock().getContents().size(); j++) {
+					if (defn.getBlock().getContents().get(j) instanceof org.scribble.model.Behaviour) {
+						b = (org.scribble.model.Behaviour)
+									defn.getBlock().getContents().get(j);
+					}
+				}
+				
+				if (b != null) {
+					sub = b;
+				}
+			}
+			
+			if (sub instanceof Interaction) {
+				ret = (Interaction)sub;
+			}
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method determines whether the supplied interaction
+	 * is the trigger interaction within a BPEL pick activity.
+	 * 
+	 * @param in The interaction
+	 * @return Whether the interaction is a pick trigger activity
+	 */
+	public static boolean isInteractionPickPathTrigger(Interaction in) {
+		boolean ret=false;
+		
+		// TODO: Need to determine all situations and ensure
+		// is generic enough to cope with extensions to Scribble
+		// model
+		
+		Block path=(Block)in.getParent();
+		
+		if (path.getParent() instanceof If &&
+				InteractionPatterns.isSwitch((If)path.getParent())) {
+			ret = true;
+			
+		// Check if receive is directly contained within a
+		// sub-definition
+		} else if (InteractionUtil.isSend(in) == false &&
+				path.getParent() instanceof org.scribble.model.Definition &&
+				path.getParent().getParent() instanceof Block &&
+				path.getParent().getParent().getParent() instanceof 
+						org.scribble.model.Definition) {
+			ret = true;
+		}
+		
+		return(ret);
+	}
+	
+	public static boolean isSwitch(If choice) {
+		boolean ret=false;
+		
+		if (choice.getPaths().size() > 0) {
+			java.util.List<Block> paths=choice.getPaths();
+			int matched=0;
+			
+			for (int i=0; i < paths.size(); i++) {
+				if (paths.get(i).getContents().size() > 0) {
+					Interaction in=getPickPathInteraction(paths.get(i));
+					
+					if (in != null &&
+							InteractionUtil.isSend(in) == false) {
+						matched++;
+					}
+				}
+			}
+			
+			if (matched == paths.size()) {
+				ret = true;
+			}
+		}
+
+		return(ret);
+	}
+	
+	public static Interaction getRequestForResponseInFaultHandler(Interaction interaction) {
+		Interaction ret=null;
+		
+		if (InteractionUtil.isRequest(interaction) == false &&
+				interaction.getReplyToLabel() != null) {
+			
+			// Find if contained in 'if' path
+			if (interaction.getParent() instanceof Block &&
+					interaction.getParent().getParent() instanceof If) {
+				
+				If choice=(If)interaction.getParent().getParent();
+				
+				// Obtain interaction prior to 'If'
+				if (choice.getParent() instanceof
+						org.scribble.model.Block) {
+					org.scribble.model.Block block=
+						(org.scribble.model.Block)choice.getParent();
+				
+					int pos=block.getContents().indexOf(choice);
+				
+					if (pos != -1 && pos > 0) {
+						org.scribble.model.Activity act=
+							block.getContents().get(pos-1);
+					
+						if (act instanceof Interaction &&
+								InteractionUtil.isRequest((Interaction)act) &&
+								((Interaction)act).getRequestLabel() != null &&
+								interaction.getReplyToLabel().equals(
+										((Interaction)act).getRequestLabel())) {
+							ret = (Interaction)act;
+						}
+					}
+				}
+			}	
+		}
+		
+		return(ret);
+	}
+	
+	public static boolean isResponseInFaultHandler(Interaction interaction) {
+		return(getRequestForResponseInFaultHandler(interaction) != null);
+	}
+	
+	public static boolean isFaultResponse(Interaction interaction) {
+		boolean ret=false;
+		
+		if (InteractionUtil.isRequest(interaction) == false &&
+				interaction.getMessageSignature().getAnnotations().
+						keySet().contains(FAULT_NAME)) {
+			ret = true;
+		}
+
+		return(ret);
+	}
+	
+	public static String getFaultName(Interaction interaction) {
+		return((String)interaction.
+			getMessageSignature().getAnnotations().get(FAULT_NAME));
+	}
+	
+	public static String getMessageTypeLocalPart(Interaction interaction) {
+		return((String)interaction.
+			getMessageSignature().getAnnotations().get(MESSAGE_TYPE_LOCALPART));
+	}
+	
+	public static String getMessageTypeNameSpace(Interaction interaction) {
+		return((String)interaction.
+			getMessageSignature().getAnnotations().get(MESSAGE_TYPE_NAMESPACE));
+	}
+	
+	/*
+	public static String getVariableName(Interaction interaction) {
+		String varName=getMessageTypeLocalPart(interaction);
+		
+		if (varName != null) {
+			int ind=varName.lastIndexOf('}');
+		
+			if (ind != -1) {
+				varName = varName.substring(ind+1);
+			}
+			
+			varName += "Var";
+			
+			if (Character.isLowerCase(varName.charAt(0)) == false) {
+				varName = Character.toLowerCase(varName.charAt(0))+
+							varName.substring(1);
+			}
+		}
+		
+		return(varName);
+	}
+	*/
+	
+	public static boolean isSyncNormalResponse(Interaction interaction) {
+		boolean ret=false;
+
+		if (InteractionUtil.isResponse(interaction) &&
+				interaction.getParent() instanceof Block) {
+			Block block=(Block)interaction.getParent();
+		
+			int pos=block.getContents().indexOf(interaction);
+			
+			if (pos > 0 && block.getContents().get(pos-1) instanceof Interaction) {
+				Interaction req=(Interaction)block.getContents().get(pos-1);
+				
+				ret = isResponseForRequest(interaction, req);
+			}
+		}
+		
+		return(ret);
+	}
+	
+	public static boolean isResponseForRequest(Interaction resp,
+							Interaction req) {
+		boolean ret=false;
+		
+		if (InteractionUtil.isRequest(req) &&
+				InteractionUtil.isResponse(resp) &&
+				resp.getReplyToLabel().equals(
+						req.getRequestLabel())) {
+			ret = true;
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/LanguageToConversationModelChangeRule.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/LanguageToConversationModelChangeRule.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/LanguageToConversationModelChangeRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,100 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.change;
+
+import org.savara.bpel.model.*;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This is the model change rule for the Language Model to
+ * Conversation Model.
+ */
+ at RegistryInfo(extension=ModelChangeRule.class,notation=BPELNotation.NOTATION_CODE)
+public class LanguageToConversationModelChangeRule extends AbstractModelChangeRule {
+
+	/**
+	 * This method determines whether the rule is appropriate
+	 * for the supplied type of model, parent (in the context) and inserted
+	 * model object.
+	 *
+	 * @param context The context
+	 * @param model The model
+	 * @param mobj The model object being inserted
+	 * @param ref The optional reference model object
+	 * @return Whether the rule supports the supplied information
+	 */
+	@Override
+	public boolean isInsertSupported(ModelChangeContext context,
+				Model model, ModelObject mobj, ModelObject ref) {
+		boolean ret=false;
+		
+		if (mobj instanceof ConversationModel &&
+				model instanceof BPELLanguageModel) {
+			ret = true;
+		}
+		
+		return(ret);
+	}
+
+	/**
+	 * This method adds a new model object, within a
+	 * parent model object, with the details supplied in
+	 * another model object. The supplied model object
+	 * will usually be from a different model representation
+	 * (e.g. due to a merge), so the details will be
+	 * copied and placed in the representation associated
+	 * with the supplied model and parent model object.<p>
+	 * <p>
+	 * If a reference model object is supplied, then the
+	 * insertion will occur relative to it. If the reference
+	 * object is a block, then it means that the insertion
+	 * should occur at the end of the block. Otherwise the
+	 * new model object should be inserted before the
+	 * reference object, within the containing block.<p>
+	 * <p>
+	 * If the reference object is not supplied, then the
+	 * new model object should be inserted at the end of
+	 * the behaviour associated with the parent in the model
+	 * change context.
+	 * 
+	 * @param context The context
+	 * @param model The model being changed
+	 * @param mobj The model object details to be inserted
+	 * @param ref The optional reference model object
+	 * @return Whether the change has been applied
+	 */
+	@Override
+	public boolean insert(ModelChangeContext context,
+				Model model, ModelObject mobj, ModelObject ref) {
+		ConversationModel cm=(ConversationModel)mobj;
+		
+		if (cm.getConversation() != null) {
+			ModelChangeUtils.addContracts(context, cm.getConversation(), true);
+
+			context.insert(model, cm.getConversation(), null);
+
+			ModelChangeUtils.removeContracts(context, cm.getConversation(), true);
+		}
+		
+		return(true);
+	}
+	
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/ModelChangeUtils.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/ModelChangeUtils.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/ModelChangeUtils.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,239 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.change;
+
+import org.savara.contract.model.Contract;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * Model change utilities.
+ */
+public class ModelChangeUtils {
+
+	/**
+	 * This method adds any contracts associated with roles defined in the
+	 * supplied conversation.
+	 * 
+	 * @param context The context
+	 * @param conv The conversation
+	 * @param root Whether this is the root conversation
+	 */
+	@SuppressWarnings("unchecked")
+	public static void addContracts(ModelChangeContext context, Conversation conv, boolean root) {
+		
+		java.util.Map<String,Contract> contracts=(java.util.Map<String,Contract>)
+							context.getProperties().get(Contract.class.getName());
+		
+		if (contracts == null) {
+			contracts = new java.util.HashMap<String, Contract>();
+			
+			context.getProperties().put(Contract.class.getName(), contracts);
+		}
+		
+		if (conv.getLocatedName().getRole() != null && root) {
+			addRoleContract(conv.getLocatedName().getRole(), contracts);
+		}
+		
+		// Get list of roles
+		java.util.List<Role> roles=getRoles(conv);
+		
+		for (Role r : roles) {
+			addRoleContract(r, contracts);
+		}
+	}
+	
+	// NOTE: Return all the roles defined in the scope of this conversation
+	// Would be better to incrementally add contracts for roles, as defined
+	// in their own scope, but need to refactor how blocks are dealt with
+	// first - which is different in some cases, so not straightforward.
+	protected static java.util.List<Role> getRoles(final Conversation conv) {
+		final java.util.List<Role> roles=new java.util.Vector<Role>();
+		
+		conv.visit(new Visitor() {
+
+			public boolean visit(ModelObject obj) {
+				boolean ret=true;
+				
+				if (obj instanceof RoleList) {
+					roles.addAll(((RoleList)obj).getRoles());
+				} else if (obj instanceof Conversation &&
+						obj != conv) {
+					ret = false;
+				}
+				
+				return(ret);
+			}
+		});
+		
+		return(roles);
+	}
+	
+	/**
+	 * This method initializes the contract associated with the supplied role.
+	 * 
+	 * @param role The role
+	 * @param contracts The map of roles to contracts
+	 */
+	protected static void addRoleContract(Role role, java.util.Map<String,Contract> contracts) {
+		if (role != null && role.getAnnotations().containsKey(Contract.class.getName())) {
+			contracts.put(role.getName(),
+					(Contract)role.getAnnotations().get(Contract.class.getName()));
+		}
+	}
+
+	/**
+	 * This method removes the contract associated with the supplied role.
+	 * 
+	 * @param role The role
+	 * @param contracts The map of roles to contracts
+	 */
+	protected static void removeRoleContract(Role role, java.util.Map<String,Contract> contracts) {
+		if (role != null && role.getAnnotations().containsKey(Contract.class.getName())) {
+			contracts.remove(role.getName());
+		}
+	}
+
+	/**
+	 * This method removes any contracts associated with roles defined in the
+	 * supplied conversation.
+	 * 
+	 * @param context The context
+	 * @param conv The conversation
+	 * @param root Whether this is the root conversation
+	 */
+	@SuppressWarnings("unchecked")
+	public static void removeContracts(ModelChangeContext context, Conversation conv, boolean root) {
+		
+		java.util.Map<String,Contract> contracts=(java.util.Map<String,Contract>)
+							context.getProperties().get(Contract.class.getName());
+		
+		if (contracts != null) {
+		
+			if (conv.getLocatedName().getRole() != null && root) {
+				removeRoleContract(conv.getLocatedName().getRole(), contracts);
+			}
+		
+			// Get list of roles
+			java.util.List<Role> roles=getRoles(conv);
+			
+			for (Role r : roles) {
+				removeRoleContract(r, contracts);
+			}
+		}
+	}
+	
+	/**
+	 * This method returns the contract associated with the supplied role.
+	 * 
+	 * @param contezt The context
+	 * @param roleName The role name
+	 * @return The contract, or null if not found
+	 */
+	@SuppressWarnings("unchecked")
+	public static Contract getContract(ModelChangeContext context, String roleName) {
+		Contract ret=null;
+		
+		if (context.getProperties().containsKey(Contract.class.getName())) {
+			java.util.Map<String,Contract> contracts=
+					(java.util.Map<String,Contract>)
+					context.getProperties().get(Contract.class.getName());
+			
+			ret = contracts.get(roleName);
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method updates the role mapping based on the supplied list of
+	 * declaration bindings.
+	 * 
+	 * @param context The context
+	 * @param run The run construct
+	 */
+	@SuppressWarnings("unchecked")
+	public static void pushRoleContractMapping(ModelChangeContext context,
+							Compose run) {
+
+		if (context.getProperties().containsKey(Contract.class.getName())) {
+			java.util.Map<String,Contract> contracts=
+					(java.util.Map<String,Contract>)
+					context.getProperties().get(Contract.class.getName());
+
+			if (run.getEnclosingDefinition().getLocatedName().getRole() != null &&
+					run.getDefinition().getLocatedName().getRole() != null) {
+				Contract c=contracts.remove(run.getEnclosingDefinition().getLocatedName().getRole().getName());
+				
+				if (c != null) {
+					contracts.put(run.getDefinition().getLocatedName().getRole().getName(), c);
+				}
+			}
+			
+			for (DeclarationBinding db : run.getBindings()) {
+				if (db.getDeclaration() instanceof Role) {
+					Contract c=contracts.remove(db.getDeclaration().getName());
+					
+					if (c != null) {
+						contracts.put(db.getBoundName(), c);
+					}
+				}
+			}
+			
+		}
+	}
+
+	/**
+	 * This method resets the role mapping based on the supplied list of
+	 * declaration bindings.
+	 * 
+	 * @param context The context
+	 * @param run The run construct
+	 */
+	@SuppressWarnings("unchecked")
+	public static void popRoleContractMapping(ModelChangeContext context,
+									Compose run) {
+
+		if (context.getProperties().containsKey(Contract.class.getName())) {
+			java.util.Map<String,Contract> contracts=
+					(java.util.Map<String,Contract>)
+					context.getProperties().get(Contract.class.getName());
+
+			if (run.getEnclosingDefinition().getLocatedName().getRole() != null &&
+					run.getDefinition().getLocatedName().getRole() != null) {
+				Contract c=contracts.remove(run.getDefinition().getLocatedName().getRole().getName());
+				
+				if (c != null) {
+					contracts.put(run.getEnclosingDefinition().getLocatedName().getRole().getName(), c);
+				}
+			}
+			
+			for (DeclarationBinding db : run.getBindings()) {
+				if (db.getDeclaration() instanceof Role) {
+					Contract c=contracts.remove(db.getBoundName());
+					
+					if (c != null) {
+						contracts.put(db.getDeclaration().getName(), c);
+					}
+				}
+			}
+			
+		}
+	}
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/RunModelChangeRule.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/RunModelChangeRule.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/RunModelChangeRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,106 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.change;
+
+import org.savara.bpel.model.*;
+import org.savara.bpel.model.component.*;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This is the model change rule for the Run.
+ */
+ at RegistryInfo(extension=ModelChangeRule.class,notation=BPELNotation.NOTATION_CODE)
+public class RunModelChangeRule extends AbstractModelChangeRule {
+
+	/**
+	 * This method determines whether the rule is appropriate
+	 * for the supplied type of model, parent (in the context) and
+	 * model object.
+	 *
+	 * @param context The context
+	 * @param model The model
+	 * @param mobj The model object causing the change
+	 * @param ref The optional reference model object
+	 * @return Whether the rule supports the supplied information
+	 */
+	@Override
+	public boolean isInsertSupported(ModelChangeContext context,
+				Model model, ModelObject mobj, ModelObject ref) {
+		boolean ret=false;
+		
+		if (mobj instanceof Run &&
+				model instanceof DefaultBPELLanguageModel) {
+			ret = true;
+		}
+		
+		return(ret);
+	}
+
+	/**
+	 * This method adds a new model object, within a
+	 * parent model object, with the details supplied in
+	 * another model object. The supplied model object
+	 * will usually be from a different model representation
+	 * (e.g. due to a merge), so the details will be
+	 * copied and placed in the representation associated
+	 * with the supplied model and parent model object.<p>
+	 * <p>
+	 * If a reference model object is supplied, then the
+	 * insertion will occur relative to it. If the reference
+	 * object is a block, then it means that the insertion
+	 * should occur at the end of the block. Otherwise the
+	 * new model object should be inserted before the
+	 * reference object, within the containing block.<p>
+	 * <p>
+	 * If the reference object is not supplied, then the
+	 * new model object should be inserted at the end of
+	 * the behaviour associated with the parent in the model
+	 * change context.
+	 * 
+	 * @param context The context
+	 * @param model The model being changed
+	 * @param mobj The model object details to be inserted
+	 * @param ref The optional reference model object
+	 * @return Whether the change has been applied
+	 */
+	@Override
+	public boolean insert(ModelChangeContext context,
+				Model model, ModelObject mobj, ModelObject ref) {
+		DefaultBPELLanguageModel bpelModel=(DefaultBPELLanguageModel)model;
+		Run elem=(Run)mobj;
+
+		if (elem.getDefinition() != null) {
+			
+			ModelChangeUtils.pushRoleContractMapping(context, elem);
+			
+			ModelChangeUtils.addContracts(context, elem.getDefinition(), false);
+			
+			context.insert(bpelModel, elem.getDefinition(), ref);
+
+			ModelChangeUtils.removeContracts(context, elem.getDefinition(), false);
+			
+			ModelChangeUtils.popRoleContractMapping(context, elem);
+		}
+		
+		return(true);
+	}
+	
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/SpawnModelChangeRule.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/SpawnModelChangeRule.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/SpawnModelChangeRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,105 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.change;
+
+import org.savara.bpel.model.*;
+import org.savara.bpel.model.component.*;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This is the model change rule for the Run.
+ */
+ at RegistryInfo(extension=ModelChangeRule.class,notation=BPELNotation.NOTATION_CODE)
+public class SpawnModelChangeRule extends AbstractModelChangeRule {
+
+	/**
+	 * This method determines whether the rule is appropriate
+	 * for the supplied type of model, parent (in the context) and
+	 * model object.
+	 *
+	 * @param context The context
+	 * @param model The model
+	 * @param mobj The model object causing the change
+	 * @param ref The optional reference model object
+	 * @return Whether the rule supports the supplied information
+	 */
+	@Override
+	public boolean isInsertSupported(ModelChangeContext context,
+				Model model, ModelObject mobj, ModelObject ref) {
+		boolean ret=false;
+		
+		if (mobj instanceof Spawn &&
+				model instanceof DefaultBPELLanguageModel) {
+			ret = true;
+		}
+		
+		return(ret);
+	}
+
+	/**
+	 * This method adds a new model object, within a
+	 * parent model object, with the details supplied in
+	 * another model object. The supplied model object
+	 * will usually be from a different model representation
+	 * (e.g. due to a merge), so the details will be
+	 * copied and placed in the representation associated
+	 * with the supplied model and parent model object.<p>
+	 * <p>
+	 * If a reference model object is supplied, then the
+	 * insertion will occur relative to it. If the reference
+	 * object is a block, then it means that the insertion
+	 * should occur at the end of the block. Otherwise the
+	 * new model object should be inserted before the
+	 * reference object, within the containing block.<p>
+	 * <p>
+	 * If the reference object is not supplied, then the
+	 * new model object should be inserted at the end of
+	 * the behaviour associated with the parent in the model
+	 * change context.
+	 * 
+	 * @param context The context
+	 * @param model The model being changed
+	 * @param mobj The model object details to be inserted
+	 * @param ref The optional reference model object
+	 * @return Whether the change has been applied
+	 */
+	@Override
+	public boolean insert(ModelChangeContext context,
+				Model model, ModelObject mobj, ModelObject ref) {
+		DefaultBPELLanguageModel bpelModel=(DefaultBPELLanguageModel)model;
+		Spawn elem=(Spawn)mobj;
+
+		if (elem.getDefinition() != null) {
+			ModelChangeUtils.pushRoleContractMapping(context, elem);
+			
+			ModelChangeUtils.addContracts(context, elem.getDefinition(), false);
+			
+			context.insert(bpelModel, elem.getDefinition(), ref);
+
+			ModelChangeUtils.removeContracts(context, elem.getDefinition(), false);
+			
+			ModelChangeUtils.popRoleContractMapping(context, elem);
+		}
+		
+		return(true);
+	}
+	
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/WhenModelChangeRule.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/WhenModelChangeRule.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/WhenModelChangeRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,108 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.change;
+
+import org.savara.bpel.model.*;
+import org.savara.bpel.model.component.*;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This is the model change rule for the When.
+ */
+ at RegistryInfo(extension=ModelChangeRule.class,notation=BPELNotation.NOTATION_CODE)
+public class WhenModelChangeRule extends AbstractModelChangeRule {
+
+	/**
+	 * This method determines whether the rule is appropriate
+	 * for the supplied type of model, parent (in the context) and
+	 * model object.
+	 *
+	 * @param context The context
+	 * @param model The model
+	 * @param mobj The model object causing the change
+	 * @param ref The optional reference model object
+	 * @return Whether the rule supports the supplied information
+	 */
+	@Override
+	public boolean isInsertSupported(ModelChangeContext context,
+				Model model, ModelObject mobj, ModelObject ref) {
+		boolean ret=false;
+		
+		if (mobj instanceof When &&
+				model instanceof DefaultBPELLanguageModel) {
+			ret = true;
+		}
+		
+		return(ret);
+	}
+
+	/**
+	 * This method adds a new model object, within a
+	 * parent model object, with the details supplied in
+	 * another model object. The supplied model object
+	 * will usually be from a different model representation
+	 * (e.g. due to a merge), so the details will be
+	 * copied and placed in the representation associated
+	 * with the supplied model and parent model object.<p>
+	 * <p>
+	 * If a reference model object is supplied, then the
+	 * insertion will occur relative to it. If the reference
+	 * object is a block, then it means that the insertion
+	 * should occur at the end of the block. Otherwise the
+	 * new model object should be inserted before the
+	 * reference object, within the containing block.<p>
+	 * <p>
+	 * If the reference object is not supplied, then the
+	 * new model object should be inserted at the end of
+	 * the behaviour associated with the parent in the model
+	 * change context.
+	 * 
+	 * @param context The context
+	 * @param model The model being changed
+	 * @param mobj The model object details to be inserted
+	 * @param ref The optional reference model object
+	 * @return Whether the change has been applied
+	 */
+	@Override
+	public boolean insert(ModelChangeContext context,
+				Model model, ModelObject mobj, ModelObject ref) {
+		DefaultBPELLanguageModel bpelModel=(DefaultBPELLanguageModel)model;
+		When elem=(When)mobj;
+		
+		// TODO: Need to decide best way to deal with single
+		// and multi-path when constructs.
+		
+		if (elem.getPaths().size() == 1) {
+			// Single path - so ignore it for now
+			Block path=elem.getPaths().get(0);
+			
+			// Process the activities within the conversation
+			java.util.List<Activity> acts=path.getContents();
+						
+			for (int i=0; i < acts.size(); i++) {
+				context.insert(model, acts.get(i), null);
+			}
+		}
+				
+		return(true);
+	}
+	
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/WhileModelChangeRule.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/WhileModelChangeRule.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/WhileModelChangeRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,117 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.change;
+
+import org.savara.bpel.model.*;
+import org.savara.bpel.model.component.*;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This is the model change rule for the While.
+ */
+ at RegistryInfo(extension=ModelChangeRule.class,notation=BPELNotation.NOTATION_CODE)
+public class WhileModelChangeRule extends AbstractModelChangeRule {
+
+	/**
+	 * This method determines whether the rule is appropriate
+	 * for the supplied type of model, parent (in the context) and
+	 * model object.
+	 *
+	 * @param context The context
+	 * @param model The model
+	 * @param mobj The model object causing the change
+	 * @param ref The optional reference model object
+	 * @return Whether the rule supports the supplied information
+	 */
+	@Override
+	public boolean isInsertSupported(ModelChangeContext context,
+				Model model, ModelObject mobj, ModelObject ref) {
+		boolean ret=false;
+		
+		if (mobj instanceof org.scribble.conversation.model.While &&
+				model instanceof DefaultBPELLanguageModel) {
+			ret = true;
+		}
+		
+		return(ret);
+	}
+
+	/**
+	 * This method adds a new model object, within a
+	 * parent model object, with the details supplied in
+	 * another model object. The supplied model object
+	 * will usually be from a different model representation
+	 * (e.g. due to a merge), so the details will be
+	 * copied and placed in the representation associated
+	 * with the supplied model and parent model object.<p>
+	 * <p>
+	 * If a reference model object is supplied, then the
+	 * insertion will occur relative to it. If the reference
+	 * object is a block, then it means that the insertion
+	 * should occur at the end of the block. Otherwise the
+	 * new model object should be inserted before the
+	 * reference object, within the containing block.<p>
+	 * <p>
+	 * If the reference object is not supplied, then the
+	 * new model object should be inserted at the end of
+	 * the behaviour associated with the parent in the model
+	 * change context.
+	 * 
+	 * @param context The context
+	 * @param model The model being changed
+	 * @param mobj The model object details to be inserted
+	 * @param ref The optional reference model object
+	 * @return Whether the change has been applied
+	 */
+	@Override
+	public boolean insert(ModelChangeContext context,
+				Model model, ModelObject mobj, ModelObject ref) {
+		DefaultBPELLanguageModel bpelModel=(DefaultBPELLanguageModel)model;
+		org.scribble.conversation.model.While elem=
+			(org.scribble.conversation.model.While)mobj;
+		
+		While act=new While(bpelModel);
+		
+		Sequence seq=new Sequence(bpelModel);
+		
+		if (context.getParent() instanceof Sequence) {		
+			((Sequence)context.getParent()).addActivity(act, -1);
+		}
+
+		// Process the activities within the conversation
+		java.util.List<Activity> acts=elem.getBlock().getContents();
+		
+		Object parent=context.getParent();
+		
+		context.setParent(seq);
+		
+		for (int i=0; i < acts.size(); i++) {
+			context.insert(model, acts.get(i), null);
+		}
+		
+		act.setActivity(seq);
+
+		// Reset old parent
+		context.setParent(parent);
+		
+		return(true);
+	}
+	
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/AbstractCondition.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/AbstractCondition.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/AbstractCondition.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,126 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import java.util.List;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.scribble.model.Activity;
+
+/**
+ * This class represents the BPEL condition element.
+ */
+public abstract class AbstractCondition extends BPELElement {
+
+	private static final long serialVersionUID = 178873060670041144L;
+
+	private static final String EXPRESSION_LANGUAGE = "expressionLanguage";
+
+	/**
+	 * The constructor for the element.
+	 * 
+	 * @param model The BPEL model
+	 * @param elem The XML configuration details for the element
+	 */
+	public AbstractCondition(BPELLanguageModel model,
+					org.w3c.dom.Element elem) {
+		super(model, elem);
+	}
+
+	/**
+	 * The constructor for the element.
+	 * 
+	 * @param model The BPEL model
+	 * @param elemName The condition's element name
+	 */
+	public AbstractCondition(BPELLanguageModel model, String elemName) {
+		super(model, elemName);
+	}
+
+	/**
+	 * This method returns the expression associated
+	 * with the condition.
+	 * 
+	 * @return The expression
+	 */
+	public String getExpression() {
+		String ret=null;
+		
+		getDOMElement().normalize();
+		
+		if (getDOMElement().getFirstChild() instanceof org.w3c.dom.Text) {
+			org.w3c.dom.Text text=(org.w3c.dom.Text)
+							getDOMElement().getFirstChild();
+			
+			ret = text.getNodeValue();
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method sets the expression.
+	 * 
+	 * @param expr The expression
+	 */
+	public void setExpression(String expr) {
+		
+		getDOMElement().normalize();
+		
+		if (getDOMElement().getFirstChild() == null) {
+			org.w3c.dom.Text text=
+				getDOMElement().getOwnerDocument().createTextNode(expr);
+			
+			getDOMElement().appendChild(text);
+			
+		} else if (getDOMElement().getFirstChild() instanceof org.w3c.dom.Text) {
+			org.w3c.dom.Text text=(org.w3c.dom.Text)
+							getDOMElement().getFirstChild();
+			
+			text.setNodeValue(expr);
+		}
+	}
+	
+	/**
+	 * This method returns the expression language associated
+	 * with the condition.
+	 * 
+	 * @return The expression language
+	 */
+	public String getExpressionLanguage() {
+		return(getDOMElement().hasAttribute(EXPRESSION_LANGUAGE)?
+				getDOMElement().getAttribute(EXPRESSION_LANGUAGE):null);
+	}
+	
+	/**
+	 * This method sets the expression language.
+	 * 
+	 * @param lang The expression language
+	 */
+	public void setExpressionLanguage(String lang) {
+		getDOMElement().setAttribute(EXPRESSION_LANGUAGE, lang);
+	}
+	
+	@Override
+	public void convert(List<Activity> activities, ConversionContext context) {
+		// TODO Auto-generated method stub
+		
+	}
+
+
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/AbstractInteraction.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/AbstractInteraction.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/AbstractInteraction.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,159 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import javax.xml.namespace.QName;
+
+import org.savara.bpel.model.*;
+import org.scribble.model.TypeReference;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class represents an abstract interaction activity.
+ *  
+ * @author gary
+ */
+public abstract class AbstractInteraction extends BPELActivity {
+
+	private static final String PARTNER_LINK = "partnerLink";
+	private static final String PORT_TYPE = "portType";
+	private static final String OPERATION = "operation";
+	
+	private static final long serialVersionUID = -5048477859609625462L;
+
+	/**
+	 * The constructor for the activity.
+	 * 
+	 * @param model The BPEL model
+	 * @param activity The XML configuration details for the activity
+	 */
+	public AbstractInteraction(BPELLanguageModel model,
+					org.w3c.dom.Element activity) {
+		super(model, activity);
+	}
+
+	/**
+	 * The constructor for the activity.
+	 * 
+	 * @param model The BPEL model
+	 */
+	public AbstractInteraction(BPELLanguageModel model,
+			String name) {
+		super(model, name);
+	}
+	
+	/**
+	 * This method sets the operation.
+	 * 
+	 * @param op The operation
+	 */
+	public void setOperation(String op) {		
+		getDOMElement().setAttribute(OPERATION, op);
+	}
+	
+	/**
+	 * This method returns the operation.
+	 * 
+	 * @return The operation
+	 */
+	public String getOperation() {
+		return(getDOMElement().hasAttribute(OPERATION)?
+				getDOMElement().getAttribute(OPERATION):null);
+	}
+
+	/**
+	 * This method sets the partner link.
+	 * 
+	 * @param pl The partner link
+	 */
+	public void setPartnerLink(String pl) {		
+		getDOMElement().setAttribute(PARTNER_LINK, pl);
+	}
+	
+	/**
+	 * This method returns the partner link.
+	 * 
+	 * @return The partner link
+	 */
+	public String getPartnerLink() {
+		return(getDOMElement().hasAttribute(PARTNER_LINK)?
+				getDOMElement().getAttribute(PARTNER_LINK):null);
+	}
+
+	/**
+	 * This method sets the port type.
+	 * 
+	 * @param pt The port type
+	 */
+	public void setPortType(String pt) {		
+		getDOMElement().setAttribute(PORT_TYPE, pt);
+	}
+	
+	/**
+	 * This method returns the port type.
+	 * 
+	 * @return The port type
+	 */
+	public String getPortType() {
+		return(getDOMElement().hasAttribute(PORT_TYPE)?
+				getDOMElement().getAttribute(PORT_TYPE):null);
+	}
+	
+	/**
+	 * This method attempts to identify the client's partner role name.
+	 * 
+	 * @return The partner role
+	 */
+	protected String getClientPartnerRole() {
+		String ret=getPartnerLink();
+		int index=-1;
+		
+		if (ret != null && (index=ret.indexOf("To")) != -1) {
+			ret = ret.substring(index+2);
+		}
+		
+		return(ret);
+	}
+
+	/**
+	 * This method attempts to identify the server's partner role name.
+	 * 
+	 * @return The partner role
+	 */
+	protected String getServerPartnerRole() {
+		String ret=getPartnerLink();
+		int index=-1;
+		
+		if (ret != null && (index=ret.indexOf("To")) != -1) {
+			ret = ret.substring(0, index);
+		}
+		
+		return(ret);
+	}
+
+	/**
+	 * This method validates the BPEL activity and reports warnings or
+	 * errors to the supplied model listener.
+	 * 
+	 * @param l The model listener
+	 */
+	@Override
+	public void validate(ModelListener l) {
+	}
+
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/BPELActivity.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/BPELActivity.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/BPELActivity.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,405 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.scribble.model.Activity;
+
+/**
+ * This class represents the base class for all BPEL
+ * activities.
+ */
+public abstract class BPELActivity extends BPELElement {
+
+	private static final String SOURCES = "sources";
+
+	private static final String TARGETS = "targets";
+
+	private static final String SUPPRESS_JOIN_FAILURE = "suppressJoinFailure";
+
+	private static final String NAME = "name";
+	
+	private static final long serialVersionUID = 2885165314780298048L;
+
+	/**
+	 * The constructor for the activity.
+	 * 
+	 * @param model The BPEL model
+	 * @param activity The XML configuration details for the activity
+	 */
+	public BPELActivity(BPELLanguageModel model,
+					org.w3c.dom.Element activity) {
+		super(model, activity);
+
+		org.w3c.dom.Element targets=findChildElement(TARGETS);
+		
+		if (targets != null) {
+			org.w3c.dom.NodeList nl=targets.getChildNodes();
+		
+			for (int i=0; i < nl.getLength(); i++) {
+				if (nl.item(i) instanceof org.w3c.dom.Element &&
+						nl.item(i).getLocalName().equals(Target.TARGET)
+						&& nl.item(i) instanceof org.w3c.dom.Element) {
+					m_targets.add(new Target(model,
+							(org.w3c.dom.Element)nl.item(i)));
+				}
+			}
+		}
+		
+		org.w3c.dom.Element sources=findChildElement(SOURCES);
+		
+		if (sources != null) {
+			org.w3c.dom.NodeList nl=sources.getChildNodes();
+		
+			for (int i=0; i < nl.getLength(); i++) {
+				if (nl.item(i) instanceof org.w3c.dom.Element &&
+						nl.item(i).getLocalName().equals(Source.SOURCE)
+						&& nl.item(i) instanceof org.w3c.dom.Element) {
+					m_sources.add(new Source(model,
+							(org.w3c.dom.Element)nl.item(i)));
+				}
+			}
+		}
+	}
+
+	/**
+	 * The constructor for the activity.
+	 * 
+	 * @param model The BPEL model
+	 */
+	public BPELActivity(BPELLanguageModel model,
+			String name) {
+		super(model, name);
+	}
+	
+	/**
+	 * This method identifies whether the BPEL element
+	 * is an activity.
+	 * 
+	 * @return Whether the element is an activity
+	 */
+	@Override
+	public boolean isActivity() {
+		return(true);
+	}
+
+	/**
+	 * This method sets the name.
+	 * 
+	 * @param name The name
+	 */
+	public void setName(String name) {		
+		getDOMElement().setAttribute(NAME, name);
+	}
+	
+	/**
+	 * This method returns the name.
+	 * 
+	 * @return The name
+	 */
+	public String getName() {
+		return(getDOMElement().hasAttribute(NAME)?
+				getDOMElement().getAttribute(NAME):null);
+	}
+
+	/**
+	 * This method sets the 'suppress join failure'
+	 * attribute.
+	 * 
+	 * @param b Whether to suppress join failure
+	 */
+	public void setSuppressJoinFailure(boolean b) {
+		String suppress=(b?"yes":"no");
+		
+		getDOMElement().setAttribute(SUPPRESS_JOIN_FAILURE, suppress);
+	}
+	
+	/**
+	 * This method returns whether the join should
+	 * be suppressed.
+	 * 
+	 * @return Whether the join should be suppressed
+	 */
+	public boolean getSuppressJoinFailure() {
+		boolean ret=false;
+		String suppress=
+			getDOMElement().getAttribute(SUPPRESS_JOIN_FAILURE);
+
+		if (suppress != null &&
+				suppress.equals("yes")) {
+			ret = true;
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method adds a target to the activity.
+	 * 
+	 * @param target The target to be added
+	 * @param pos The position to add, or -1 if at the end
+	 */
+	public void addTarget(Target target, int pos) {
+		
+		org.w3c.dom.Element targets=null;
+		
+		if (m_targets.size() == 0) {
+			targets = getDOMElement().getOwnerDocument().
+						createElementNS(BPEL_NS, TARGETS);
+			
+			if (getDOMElement().getFirstChild() == null) {
+				getDOMElement().appendChild(targets);
+			} else {
+				getDOMElement().insertBefore(targets,
+						getDOMElement().getFirstChild());
+			}
+		} else {
+			targets = findChildElement(TARGETS);
+		}
+		
+		org.w3c.dom.Node newNode=target.getDOMElement().cloneNode(true);
+		
+		getDOMElement().getOwnerDocument().adoptNode(newNode);
+		
+		target.setDOMElement((org.w3c.dom.Element)newNode);
+		
+		if (pos == -1 && pos < m_targets.size()) {
+			m_targets.add(target);
+			
+			targets.appendChild(newNode);
+		} else {
+			
+			Target cur=m_targets.get(pos);
+			
+			m_targets.add(pos, target);
+			
+			if (cur != null) {
+				targets.insertBefore(newNode,
+							cur.getDOMElement());
+			} else {
+				targets.appendChild(newNode);
+			}
+		}
+	}
+	
+	/**
+	 * This method removes a target from the activity.
+	 * 
+	 * @param target The target to be removed
+	 * @return Whether the target was removed
+	 */
+	public boolean removeTarget(Target target) {
+		boolean ret=m_targets.remove(target);
+		
+		if (ret) {
+			org.w3c.dom.Element targets=
+						findChildElement(TARGETS);
+			
+			if (targets != null) {
+				targets.removeChild(target.getDOMElement());
+				
+				if (m_targets.size() == 0) {
+					getDOMElement().removeChild(targets);
+				}
+			}
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the list of targets associated
+	 * with the activity.
+	 * 
+	 * @return The list of targets
+	 */
+	public java.util.List<Target> getTargets() {
+		return(m_targets);
+	}
+
+	/**
+	 * This method adds a source to the activity.
+	 * 
+	 * @param source The source to be added
+	 * @param pos The position to add, or -1 if at the end
+	 */
+	public void addSource(Source source, int pos) {
+		
+		org.w3c.dom.Element sources=null;
+		
+		if (m_sources.size() == 0) {
+			sources = getDOMElement().getOwnerDocument().
+						createElementNS(BPEL_NS, SOURCES);
+			
+			if (getDOMElement().getFirstChild() == null) {
+				getDOMElement().appendChild(sources);
+			} else {
+				getDOMElement().insertBefore(sources,
+						getDOMElement().getFirstChild());
+			}
+		} else {
+			sources = findChildElement(SOURCES);
+		}
+		
+		org.w3c.dom.Node newNode=source.getDOMElement().cloneNode(true);
+		
+		getDOMElement().getOwnerDocument().adoptNode(newNode);
+		
+		source.setDOMElement((org.w3c.dom.Element)newNode);
+		
+		if (pos == -1 && pos < m_sources.size()) {
+			m_sources.add(source);
+			
+			sources.appendChild(newNode);
+		} else {
+			
+			Source cur=m_sources.get(pos);
+			
+			m_sources.add(pos, source);
+			
+			if (cur != null) {
+				sources.insertBefore(newNode,
+							cur.getDOMElement());
+			} else {
+				sources.appendChild(newNode);
+			}
+		}
+	}
+	
+	/**
+	 * This method removes a source from the activity.
+	 * 
+	 * @param source The source to be removed
+	 * @return Whether the source was removed
+	 */
+	public boolean removesource(Source source) {
+		boolean ret=m_sources.remove(source);
+		
+		if (ret) {
+			org.w3c.dom.Element sources=
+						findChildElement(SOURCES);
+			
+			if (sources != null) {
+				sources.removeChild(source.getDOMElement());
+				
+				if (m_sources.size() == 0) {
+					getDOMElement().removeChild(sources);
+				}
+			}
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the list of sources associated
+	 * with the activity.
+	 * 
+	 * @return The list of sources
+	 */
+	public java.util.List<Source> getSources() {
+		return(m_sources);
+	}
+	
+	/**
+	 * This method converts the BPEL activity into an equivalent
+	 * behavioural description for conformance checking.
+	 * 
+	 * @param activities The list of activities that will contain
+	 * 				the converted action(s)
+	 * @param context The conversion context
+	 */
+	public void convert(java.util.List<Activity> activities,
+			ConversionContext context) {
+		
+		if (getTargets().size() > 0) {
+			
+			// Create 'when' construct to wait for inbound links
+			// to be satisfied
+			org.scribble.expression.xpath.model.XPathExpression expr=
+				new org.scribble.expression.xpath.model.XPathExpression();
+	
+			String query="";
+			
+			for (int i=0; i < getTargets().size(); i++) {
+				if (i > 0) {
+					query += " and ";
+				}
+				query += "$"+getTargets().get(i).getLinkName();
+			}
+				
+			expr.setQuery(query);
+
+			org.scribble.conversation.model.When elem=
+				new org.scribble.conversation.model.When();
+			
+			org.scribble.conversation.model.ConditionalBlock block=
+					new org.scribble.conversation.model.ConditionalBlock();
+			block.setExpression(expr);
+			
+			elem.getConditionalBlocks().add(block);
+			
+			activities.add(elem);
+			
+			activities = block.getContents();
+		}
+		
+		convertActivity(activities, context);
+		
+		// If sources, then set boolean variable
+		for (int i=0; i < getSources().size(); i++) {
+			
+			org.scribble.conversation.model.Assignment assign=
+				new org.scribble.conversation.model.Assignment();
+			
+			org.scribble.conversation.model.Variable var=
+				new org.scribble.conversation.model.Variable();
+			
+			var.setName(getSources().get(i).getLinkName());
+			
+			assign.setVariable(var);
+			
+			org.scribble.expression.xpath.model.XPathExpression expr=
+						new org.scribble.expression.xpath.model.XPathExpression();
+			
+			expr.setQuery("true()");
+			assign.setExpression(expr);
+			
+			activities.add(assign);
+		}
+	}
+	
+	/**
+	 * This method does the actual work of converting the specific
+	 * BPEL activity into an equivalent behavioural description for 
+	 * conformance checking. The 'convert' method provides
+	 * a wrapper around this method, to handle the standard elements
+	 * that can be associated with any BPEL activity.
+	 * 
+	 * @param activities The list of activities that will contain
+	 * 				the converted action(s)
+	 * @param context The conversion context
+	 */
+	protected abstract void convertActivity(java.util.List<Activity> activities,
+			ConversionContext context);
+		
+	private java.util.List<Target> m_targets=
+		new java.util.Vector<Target>();
+	private java.util.List<Source> m_sources=
+		new java.util.Vector<Source>();
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/BPELElement.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/BPELElement.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/BPELElement.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,404 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.*;
+import org.savara.util.XMLUtils;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.apache.commons.logging.*;
+
+/**
+ * This is the generic BPEL element class.
+ *  
+ * @author gary
+ */
+public abstract class BPELElement extends ModelObject {
+
+	public static final String BPEL_NS = "http://docs.oasis-open.org/wsbpel/2.0/process/executable";
+
+	private static final long serialVersionUID = -7306844554703224704L;
+
+	/**
+	 * The constructor for initializing the BPEL element based on
+	 * an existing DOM element.
+	 */
+	protected BPELElement(BPELLanguageModel model,
+					org.w3c.dom.Element elem) {
+		m_model = model;
+		
+		m_element = elem;
+		
+		// Set the start/end position information
+		// in the source details
+		XMLUtils.setStartAndEndPosition(this, model.getOriginalContents(), elem);
+			
+		getSource().setObject(this);
+	}
+	
+	/**
+	 * The contructor for initializing a new element.
+	 */
+	protected BPELElement(BPELLanguageModel model,
+								String elemName) {
+		m_model = model;
+
+		org.w3c.dom.Document doc=null;
+		
+		if (model.getBPELProcess() == null) {
+			try {
+				javax.xml.parsers.DocumentBuilderFactory factory=
+					javax.xml.parsers.DocumentBuilderFactory.
+								newInstance();
+				factory.setNamespaceAware(true);
+				
+				doc = factory.newDocumentBuilder().newDocument();
+			} catch(Exception e) {
+				logger.error("Failed to create document", e);
+			}
+		} else {
+			doc = model.getBPELProcess().getDOMElement().
+							getOwnerDocument();
+		}
+		
+		m_element = doc.createElementNS(BPEL_NS, elemName);
+
+		getSource().setObject(this);
+	}
+	
+	/**
+	 * This method validates the ESB action and reports warnings or
+	 * errors to the supplied model listener.
+	 * 
+	 * @param l The model listener
+	 */
+	public void validate(ModelListener l) {		
+	}
+		
+	/**
+	 * This method returns the XML configuration representation 
+	 * of the activity.
+	 * 
+	 * @return The XML configuration for the BPEL node
+	 */
+	public org.w3c.dom.Element getDOMElement() {
+		return(m_element);
+	}
+	
+	/**
+	 * This method sets the XML configuration representation
+	 * of the activity.
+	 * 
+	 * @param elem The XML configuration
+	 */
+	protected void setDOMElement(org.w3c.dom.Element elem) {
+		m_element = elem;
+	}
+	
+	/**
+	 * This method identifies whether the BPEL element
+	 * is an activity.
+	 * 
+	 * @return Whether the element is an activity
+	 */
+	public boolean isActivity() {
+		return(false);
+	}
+	
+	/**
+	 * This method returns the model.
+	 * 
+	 * @return The model
+	 */
+	protected BPELLanguageModel getModel() {
+		return(m_model);
+	}
+	
+	/**
+	 * This method returns the BPEL process in which the BPEL element
+	 * is contained.
+	 * 
+	 * @return The BPEL process, or null if not found
+	 */
+	protected Process getProcess() {
+		Process ret=null;
+		ModelObject cur=this;
+		
+		while (ret == null && cur != null) {
+			if (cur instanceof Process) {
+				ret = (Process)cur;
+			} else {
+				cur = cur.getParent();
+			}
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the element associated with
+	 * the supplied name.
+	 * 
+	 * @param name The name
+	 * @return The element, or null if not found
+	 */
+	public org.w3c.dom.Element findChildElement(String name) {
+		org.w3c.dom.Element ret=null;
+		
+		org.w3c.dom.NodeList nl=getDOMElement().getChildNodes();
+		
+		for (int i=0; ret == null && i < nl.getLength(); i++) {
+			org.w3c.dom.Node n=nl.item(i);
+			
+			if (n instanceof org.w3c.dom.Element &&
+					n.getLocalName() != null &&
+					n.getLocalName().equals(name)) {
+				ret = (org.w3c.dom.Element)nl.item(i);
+			}
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the first child BPEL activity
+	 * found within the DOM element.
+	 * 
+	 * @return The child BPEL activity, or null if not found
+	 */
+	public BPELActivity findChildActivity() {
+		BPELActivity ret=null;
+		
+		org.w3c.dom.NodeList nl=getDOMElement().getChildNodes();
+		
+		for (int i=0; ret == null &&
+					i < nl.getLength(); i++) {
+			if (nl.item(i) instanceof org.w3c.dom.Element) {
+				BPELElement elem = BPELElementFactory.createBPELElement(m_model,
+								(org.w3c.dom.Element)nl.item(i));
+				
+				if (elem != null && elem.isActivity() &&
+						elem instanceof BPELActivity) {
+					ret = (BPELActivity)elem;
+				}
+			}
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the child elements that conform to
+	 * the supplied class.
+	 * 
+	 * @param cls The class
+	 * @return The list of child elements of the type specified
+	 * 			by the supplied class
+	 */
+	public java.util.List<BPELElement> findChildElements(Class<? extends BPELElement> cls) {
+		return(findChildElements(getDOMElement(), cls));
+	}
+
+	/**
+	 * This method returns the child elements that conform to
+	 * the supplied class.
+	 * 
+	 * @param root The root element
+	 * @param cls The class
+	 * @return The list of child elements of the type specified
+	 * 			by the supplied class
+	 */
+	public java.util.List<BPELElement> findChildElements(org.w3c.dom.Element root,
+						Class<? extends BPELElement> cls) {
+		java.util.List<BPELElement> ret=new java.util.Vector<BPELElement>();
+		
+		org.w3c.dom.NodeList nl=root.getChildNodes();
+		
+		for (int i=0; i < nl.getLength(); i++) {
+			
+			if (nl.item(i) instanceof org.w3c.dom.Element) {
+				BPELElement elem=BPELElementFactory.createBPELElement(m_model,
+						(org.w3c.dom.Element)nl.item(i));
+				
+				if (elem != null &&
+						cls.isAssignableFrom(elem.getClass())) {
+					ret.add(elem);
+				}
+			}
+		}
+		
+		return(ret);
+	}
+
+	/**
+	 * This method sets a new element. If an existing element
+	 * is specified, then it is replaced with the new element.
+	 * Otherwise if an insertBefore node is specified, then
+	 * the new element is inserted before it. If no existing
+	 * or insertBefore parameters are specified, then the
+	 * new element will be appended.<b>
+	 * <b>
+	 * The new BPEL element will be updated to be associated
+	 * with a DOM element that is adopted by the document
+	 * into which it is being added.
+	 * 
+	 * @param existing The optional existing element to be
+	 * 						replaced
+	 * @param newelem The new element
+	 * @param insertBefore Optional location to insert new element
+	 */
+	public void setChildElement(org.w3c.dom.Element existing,
+				BPELElement newelem, org.w3c.dom.Node insertBefore) {
+		
+		setChildElement(getDOMElement(), existing, newelem, insertBefore);
+	}
+	
+	/**
+	 * This method sets a new element. If an existing element
+	 * is specified, then it is replaced with the new element.
+	 * Otherwise if an insertBefore node is specified, then
+	 * the new element is inserted before it. If no existing
+	 * or insertBefore parameters are specified, then the
+	 * new element will be appended.<b>
+	 * <b>
+	 * The new BPEL element will be updated to be associated
+	 * with a DOM element that is adopted by the document
+	 * into which it is being added.
+	 * 
+	 * @param root The root element to add child to
+	 * @param existing The optional existing element to be
+	 * 						replaced
+	 * @param newelem The new element
+	 * @param insertBefore Optional location to insert new element
+	 */
+	public void setChildElement(org.w3c.dom.Element root,
+					org.w3c.dom.Element existing,
+				BPELElement newelem, org.w3c.dom.Node insertBefore) {
+			
+		if (newelem != null) {
+			org.w3c.dom.Node newNode=newelem.getDOMElement().cloneNode(true);
+			
+			root.getOwnerDocument().adoptNode(newNode);
+			
+			newelem.setDOMElement((org.w3c.dom.Element)newNode);
+			
+			if (existing != null) {
+				root.replaceChild(newNode, existing);
+			} else if (insertBefore != null) {
+				root.insertBefore(newNode, insertBefore);
+			} else {
+				root.appendChild(newNode);
+			}
+		}
+	}
+	
+	/**
+	 * This method converts the BPEL activity into an equivalent
+	 * behavioural description for conformance checking.
+	 * 
+	 * @param activities The list of activities that will contain
+	 * 				the converted action(s)
+	 * @param context The conversion context
+	 */
+	public abstract void convert(java.util.List<Activity> activities,
+					ConversionContext context);
+		
+	/**
+	 * This method returns the URI fragment to the activity within the
+	 * BPEL model.
+	 * 
+	 * @return The URI
+	 */
+	public String getURI() {
+		String ret="";
+		
+		BPELElement parent=null;
+		
+		if (getParent() != null) {
+			if (getParent() instanceof BPELElement) {
+				parent = (BPELElement)getParent();
+			}
+		} else if (getDOMElement().getParentNode() instanceof org.w3c.dom.Element) {
+			parent = BPELElementFactory.createBPELElement(getModel(),
+								(org.w3c.dom.Element)getDOMElement().getParentNode());
+		}
+		
+		if (parent != null) {
+			ret = parent.getParentURI(this);
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method recursively builds up the URI using the local URI
+	 * parts for each BPEL element up to the root node.
+	 * 
+	 * @param elem The child element
+	 * @return The URI for the parent element
+	 */
+	protected String getParentURI(BPELElement elem) {
+		String ret="";
+		
+		BPELElement parent=null;
+		
+		if (getParent() != null) {
+			if (getParent() instanceof BPELElement) {
+				parent = (BPELElement)getParent();
+			}
+		} else if (elem.getDOMElement().getParentNode() instanceof org.w3c.dom.Element) {
+			parent = BPELElementFactory.createBPELElement(getModel(),
+								(org.w3c.dom.Element)getDOMElement().getParentNode());
+		}
+		
+		if (parent != null) {
+			ret = parent.getParentURI(this)+"/"+getLocalURIPart(elem);
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the URI part associated with the supplied child element.
+	 * 
+	 * @param elem The child element
+	 * @return The URI part
+	 */
+	protected String getLocalURIPart(BPELElement elem) {
+		return("");
+	}
+	
+	public int hashCode() {
+		return(m_element.hashCode());
+	}
+	
+	public boolean equals(Object obj) {
+		boolean ret=false;
+		
+		if (obj instanceof BPELElement) {
+			ret = m_element.equals(((BPELElement)obj).getDOMElement());
+		}
+		
+		return(ret);
+	}
+	
+	private static Log logger = LogFactory.getLog(BPELElement.class);
+
+	private BPELLanguageModel m_model=null;
+	private org.w3c.dom.Element m_element=null;
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/BPELElementFactory.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/BPELElementFactory.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/BPELElementFactory.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.apache.commons.logging.*;
+import org.savara.bpel.model.BPELLanguageModel;
+
+public class BPELElementFactory {
+
+	public static final String MODEL_COMPONENTS_PACKAGE = BPELElementFactory.class.getPackage().getName();
+	
+	/**
+	* This method creates a BPELElement instance relevant to the
+	* supplied JBossESB action, associated with the supplied
+	* service.
+	* 
+	* @param model The BPEL model
+	* @param elem The XML configuration of the BPEL activity
+	* @return The BPEL element instance
+	*/
+	public static BPELElement createBPELElement(BPELLanguageModel model,
+					org.w3c.dom.Element elem) {
+		BPELElement ret=null;
+		String activityType=elem.getNodeName();
+		
+		// Make first character capitalised
+		char ch=Character.toUpperCase(activityType.charAt(0));
+		
+		activityType = ch+activityType.substring(1);
+		
+		String clsName=MODEL_COMPONENTS_PACKAGE+"."+activityType;
+	
+		try {
+			Class<?> cls=(Class<?>)
+					Class.forName(clsName);
+			
+			java.lang.reflect.Constructor<?> con=
+				cls.getConstructor(new Class<?>[]{BPELLanguageModel.class,
+									org.w3c.dom.Element.class});
+			
+			ret = (BPELElement)con.newInstance(new Object[]{model, elem});
+			
+		} catch(Exception e) {
+			logger.warn("Unable to find BPEL element class '"+
+							clsName+"'");
+		}
+		
+		return(ret);
+	}
+
+	private static Log logger = LogFactory.getLog(BPELElementFactory.class);
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/BPELGroupingConstruct.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/BPELGroupingConstruct.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/BPELGroupingConstruct.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.apache.commons.logging.*;
+import org.savara.bpel.model.*;
+
+/**
+ * This is the generic BPEL activity class.
+ *  
+ * @author gary
+ */
+public abstract class BPELGroupingConstruct extends BPELActivity {
+
+	private static final long serialVersionUID = -5550042312010190598L;
+
+	/**
+	 * The constructor for initializing the activity based on
+	 * an existing DOM element.
+	 */
+	protected BPELGroupingConstruct(BPELLanguageModel model,
+					org.w3c.dom.Element activity) {
+		super(model, activity);
+	}
+	
+	/**
+	 * The contructor for initializing a new activity.
+	 */
+	protected BPELGroupingConstruct(BPELLanguageModel model,
+								String activityName) {
+		super(model, activityName);
+	}
+	
+	/**
+	 * This method sets the contained activity.
+	 * 
+	 * @param act The contained activity
+	 */
+	public void setActivity(BPELElement act) {
+		m_activity = act;
+		
+		getDOMElement().appendChild(act.getDOMElement());
+	}
+	
+	/**
+	 * This method returns the contained activity.
+	 * 
+	 * @return The contained activity
+	 */
+	public BPELElement getActivity() {
+		return(m_activity);
+	}
+	
+	private static Log logger = LogFactory.getLog(BPELGroupingConstruct.class);
+
+	private BPELElement m_activity=null;
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Catch.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Catch.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Catch.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,187 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import java.util.List;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.scribble.model.Activity;
+
+/**
+ * This class represents the 'catch' construct contained
+ * within the 'faultHandlers' element.
+ */
+public class Catch extends BPELElement {
+
+	private static final long serialVersionUID = 8191152745680660045L;
+
+	public static final String CATCH="catch";
+	
+	private static final String FAULT_NAME = "faultName";
+	private static final String FAULT_VARIABLE = "faultVariable";
+	private static final String FAULT_MESSAGE_TYPE = "faultMessageType";
+	private static final String FAULT_MESSAGE_ELEMENT = "faultMessageElement";
+
+	/**
+	 * The constructor for the element.
+	 * 
+	 * @param model The BPEL model
+	 * @param activity The XML configuration details for the element
+	 */
+	public Catch(BPELLanguageModel model,
+					org.w3c.dom.Element activity) {
+		super(model, activity);
+		
+		m_activity = findChildActivity();
+	}
+
+	/**
+	 * The constructor for the element.
+	 * 
+	 * @param model The BPEL model
+	 */
+	public Catch(BPELLanguageModel model) {
+		super(model, CATCH);
+	}
+
+	@Override
+	public void convert(List<Activity> activities, ConversionContext context) {
+		// Catch is not directly converted, only its contents indirectly as
+		// a fault response in a scope
+	}
+	
+	/**
+	 * This method sets the activity associated with
+	 * the 'else' construct.
+	 * 
+	 * @param act The activity
+	 */
+	public void setActivity(BPELActivity act) {
+		m_activity = act;
+		
+		BPELElement existing=findChildActivity();
+		org.w3c.dom.Element existingElem=null;
+		
+		if (existing != null) {
+			existingElem = existing.getDOMElement();
+		}
+
+		org.w3c.dom.Element insertBefore=null;
+		
+		setChildElement(existingElem, act,
+						insertBefore);
+	}
+	
+	/**
+	 * This method returns the activity associated with
+	 * the 'else' construct.
+	 * 
+	 * @return The activity
+	 */
+	public BPELActivity getActivity() {
+		return(m_activity);
+	}
+	
+	/**
+	 * This method sets the fault name.
+	 * 
+	 * @param faultName The fault name
+	 */
+	public void setFaultName(String faultName) {		
+		getDOMElement().setAttribute(FAULT_NAME, faultName);
+	}
+	
+	/**
+	 * This method returns the fault name.
+	 * 
+	 * @return The fault name
+	 */
+	public String getFaultName() {
+		return(getDOMElement().hasAttribute(FAULT_NAME)?
+				getDOMElement().getAttribute(FAULT_NAME):null);
+	}
+
+	/**
+	 * This method sets the fault variable.
+	 * 
+	 * @param faultVariable The fault variable
+	 */
+	public void setFaultVariable(String faultVariable) {		
+		getDOMElement().setAttribute(FAULT_VARIABLE, faultVariable);
+	}
+	
+	/**
+	 * This method returns the fault variable.
+	 * 
+	 * @return The fault variable
+	 */
+	public String getFaultVariable() {
+		return(getDOMElement().hasAttribute(FAULT_VARIABLE)?
+				getDOMElement().getAttribute(FAULT_VARIABLE):null);
+	}
+
+	/**
+	 * This method sets the fault message type.
+	 * 
+	 * @param faultName The fault message type
+	 */
+	public void setFaultMessageType(String faultMessageType) {		
+		getDOMElement().setAttribute(FAULT_MESSAGE_TYPE, faultMessageType);
+	}
+	
+	/**
+	 * This method returns the fault message type.
+	 * 
+	 * @return The fault message type
+	 */
+	public String getFaultMessageType() {
+		return(getDOMElement().hasAttribute(FAULT_MESSAGE_TYPE)?
+				getDOMElement().getAttribute(FAULT_MESSAGE_TYPE):null);
+	}
+
+	/**
+	 * This method sets the fault message element.
+	 * 
+	 * @param faultName The fault message element
+	 */
+	public void setFaultMessageElement(String faultMessageElement) {		
+		getDOMElement().setAttribute(FAULT_MESSAGE_ELEMENT, faultMessageElement);
+	}
+	
+	/**
+	 * This method returns the fault message element.
+	 * 
+	 * @return The fault message element
+	 */
+	public String getFaultMessageElement() {
+		return(getDOMElement().hasAttribute(FAULT_MESSAGE_ELEMENT)?
+				getDOMElement().getAttribute(FAULT_MESSAGE_ELEMENT):null);
+	}
+
+	protected String getLocalURIPart(BPELElement elem) {
+		String ret="";
+		
+		if (elem instanceof BPELActivity) {
+			ret = "@activity";
+		}
+		
+		return(ret);
+	}
+	
+	private BPELActivity m_activity;
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/CatchAll.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/CatchAll.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/CatchAll.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,106 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import java.util.List;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.scribble.model.Activity;
+
+/**
+ * This class represents the 'catchAll' construct contained
+ * within the 'faultHandlers' element.
+ */
+public class CatchAll extends BPELElement {
+
+	private static final long serialVersionUID = 975038289163694699L;
+
+	public static final String CATCHALL="catchAll";
+	
+	/**
+	 * The constructor for the element.
+	 * 
+	 * @param model The BPEL model
+	 * @param activity The XML configuration details for the element
+	 */
+	public CatchAll(BPELLanguageModel model,
+					org.w3c.dom.Element activity) {
+		super(model, activity);
+		
+		m_activity = findChildActivity();
+	}
+
+	/**
+	 * The constructor for the element.
+	 * 
+	 * @param model The BPEL model
+	 */
+	public CatchAll(BPELLanguageModel model) {
+		super(model, CATCHALL);
+	}
+
+	@Override
+	public void convert(List<Activity> activities, ConversionContext context) {
+		// TODO Auto-generated method stub
+		
+	}
+	
+	/**
+	 * This method sets the activity associated with
+	 * the 'else' construct.
+	 * 
+	 * @param act The activity
+	 */
+	public void setActivity(BPELActivity act) {
+		m_activity = act;
+		
+		BPELElement existing=findChildActivity();
+		org.w3c.dom.Element existingElem=null;
+		
+		if (existing != null) {
+			existingElem = existing.getDOMElement();
+		}
+
+		org.w3c.dom.Element insertBefore=null;
+		
+		setChildElement(existingElem, act,
+						insertBefore);
+	}
+	
+	/**
+	 * This method returns the activity associated with
+	 * the 'else' construct.
+	 * 
+	 * @return The activity
+	 */
+	public BPELActivity getActivity() {
+		return(m_activity);
+	}
+	
+	protected String getLocalURIPart(BPELElement elem) {
+		String ret="";
+		
+		if (elem instanceof BPELActivity) {
+			ret = "@activity";
+		}
+		
+		return(ret);
+	}
+	
+	private BPELActivity m_activity;
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/CompensationHandler.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/CompensationHandler.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/CompensationHandler.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import java.util.List;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.scribble.model.Activity;
+
+/**
+ * This class represents the 'compensationHandler' construct contained
+ * within the 'scope' activity.
+ */
+public class CompensationHandler extends BPELElement {
+
+	private static final long serialVersionUID = -1994083560689296558L;
+
+	public static final String COMPENSATIONHANDLER="compensationHandler";
+	
+	/**
+	 * The constructor for the element.
+	 * 
+	 * @param model The BPEL model
+	 * @param activity The XML configuration details for the element
+	 */
+	public CompensationHandler(BPELLanguageModel model,
+					org.w3c.dom.Element activity) {
+		super(model, activity);
+		
+		m_activity = findChildActivity();
+	}
+
+	/**
+	 * The constructor for the element.
+	 * 
+	 * @param model The BPEL model
+	 */
+	public CompensationHandler(BPELLanguageModel model) {
+		super(model, COMPENSATIONHANDLER);
+	}
+
+	@Override
+	public void convert(List<Activity> activities, ConversionContext context) {
+		// TODO Auto-generated method stub
+		
+	}
+	
+	/**
+	 * This method sets the activity associated with
+	 * the 'else' construct.
+	 * 
+	 * @param act The activity
+	 */
+	public void setActivity(BPELElement act) {
+		m_activity = act;
+		
+		BPELElement existing=findChildActivity();
+		org.w3c.dom.Element existingElem=null;
+		
+		if (existing != null) {
+			existingElem = existing.getDOMElement();
+		}
+
+		org.w3c.dom.Element insertBefore=null;
+		
+		setChildElement(existingElem, act,
+						insertBefore);
+	}
+	
+	/**
+	 * This method returns the activity associated with
+	 * the 'else' construct.
+	 * 
+	 * @return The activity
+	 */
+	public BPELElement getActivity() {
+		return(m_activity);
+	}
+	
+	private BPELElement m_activity;
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Condition.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Condition.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Condition.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.BPELLanguageModel;
+
+/**
+ * This class represents the BPEL condition element.
+ */
+public class Condition extends AbstractCondition {
+
+	private static final long serialVersionUID = 8666349106632652777L;
+
+	public static final String CONDITION="condition";
+	
+	/**
+	 * The constructor for the element.
+	 * 
+	 * @param model The BPEL model
+	 * @param elem The XML configuration details for the element
+	 */
+	public Condition(BPELLanguageModel model,
+					org.w3c.dom.Element elem) {
+		super(model, elem);
+	}
+
+	/**
+	 * The constructor for the element.
+	 * 
+	 * @param model The BPEL model
+	 */
+	public Condition(BPELLanguageModel model) {
+		super(model, CONDITION);
+	}
+
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/ConversionContext.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/ConversionContext.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/ConversionContext.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.scribble.model.admin.Context;
+
+public interface ConversionContext {
+
+	/**
+	 * This method returns a reference to the environment context.
+	 * 
+	 * @return The environment context
+	 */
+	public Context getEnvironmentContext();
+	
+	/**
+	 * This method returns the process.
+	 * 
+	 * @return The process
+	 */
+	public Process getProcess();
+	
+	/**
+	 * This method returns the role associated with the
+	 * endpoint being converted.
+	 * 
+	 *@return The role
+	 */
+	public String getRole();
+
+	/**
+	 * This method returns the variable associated with the
+	 * supplied name.
+	 * 
+	 * @param name The name
+	 * @return The variable, or null if not found
+	 */
+	public Variable getVariable(String name);
+	
+	/**
+	 * This method adds a variable to the context.
+	 * 
+	 * @param var The variable
+	 */
+	public void addVariable(Variable var);
+
+	/**
+	 * This method removes a variable from the context.
+	 * 
+	 * @param var The variable
+	 */
+	public void removeVariable(Variable var);
+
+	/**
+	 * This method returns the namespace for the supplied prefix.
+	 * 
+	 * @param prefix The prefix
+	 * @return The namespace, or null if not found
+	 */
+	public String getNamespace(String prefix);
+
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/DefaultConversionContext.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/DefaultConversionContext.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/DefaultConversionContext.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,114 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.scribble.model.admin.Context;
+
+/**
+ * This class provides a default implementation of the conversation
+ * context.
+ */
+public class DefaultConversionContext implements ConversionContext {
+
+	/**
+	 * This is the constructor for the conversion context, initialised
+	 * with the role being played by the converted BPEL process.
+	 * 
+	 * @param role The role
+	 * @param proc The process
+	 * @param envContext The environment context
+	 */
+	public DefaultConversionContext(String role, Process proc, Context envContext) {
+		m_role = role;
+		m_process = proc;
+		m_environmentContext = envContext;
+	}
+	
+	/**
+	 * This method returns a reference to the environment context.
+	 * 
+	 * @return The environment context
+	 */
+	public Context getEnvironmentContext() {
+		return(m_environmentContext);
+	}
+	
+	/**
+	 * This method returns the process.
+	 * 
+	 * @return The process
+	 */
+	public Process getProcess() {
+		return(m_process);
+	}
+	
+	/**
+	 * This method returns the role associated with the
+	 * endpoint being converted.
+	 * 
+	 *@return The role
+	 */
+	public String getRole() {
+		return(m_role);
+	}
+	
+	/**
+	 * This method returns the variable associated with the
+	 * supplied name.
+	 * 
+	 * @param name The name
+	 * @return The variable, or null if not found
+	 */
+	public Variable getVariable(String name) {
+		return(m_variables.get(name));
+	}
+	
+	/**
+	 * This method adds a variable to the context.
+	 * 
+	 * @param var The variable
+	 */
+	public void addVariable(Variable var) {
+		m_variables.put(var.getName(), var);
+	}
+	
+	/**
+	 * This method removes a variable from the context.
+	 * 
+	 * @param var The variable
+	 */
+	public void removeVariable(Variable var) {
+		m_variables.remove(var.getName());
+	}
+	
+	/**
+	 * This method returns the namespace for the supplied prefix.
+	 * 
+	 * @param prefix The prefix
+	 * @return The namespace, or null if not found
+	 */
+	public String getNamespace(String prefix) {
+		return(m_process.getNamespace(prefix));
+	}
+	
+	private String m_role=null;
+	private Process m_process=null;
+	private Context m_environmentContext=null;
+	private java.util.Map<String,Variable> m_variables=
+					new java.util.HashMap<String,Variable>();
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Else.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Else.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Else.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,108 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import java.util.List;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.scribble.model.Activity;
+
+/**
+ * This class represents the 'else' construct contained
+ * within the 'if' activity.
+ */
+public class Else extends BPELElement {
+
+	private static final long serialVersionUID = 1243775332210724718L;
+
+	public static final String ELSE="else";
+	
+	/**
+	 * The constructor for the element.
+	 * 
+	 * @param model The BPEL model
+	 * @param activity The XML configuration details for the element
+	 */
+	public Else(BPELLanguageModel model,
+					org.w3c.dom.Element activity) {
+		super(model, activity);
+		
+		m_activity = findChildActivity();
+	}
+
+	/**
+	 * The constructor for the element.
+	 * 
+	 * @param model The BPEL model
+	 */
+	public Else(BPELLanguageModel model) {
+		super(model, ELSE);
+	}
+
+	@Override
+	public void convert(List<Activity> activities, ConversionContext context) {
+		
+		if (getActivity() != null) {
+			getActivity().convert(activities, context);
+		}
+	}
+	
+	/**
+	 * This method sets the activity associated with
+	 * the 'else' construct.
+	 * 
+	 * @param act The activity
+	 */
+	public void setActivity(BPELElement act) {
+		m_activity = act;
+		
+		BPELElement existing=findChildActivity();
+		org.w3c.dom.Element existingElem=null;
+		
+		if (existing != null) {
+			existingElem = existing.getDOMElement();
+		}
+
+		org.w3c.dom.Element insertBefore=null;
+		
+		setChildElement(existingElem, act,
+						insertBefore);
+	}
+	
+	/**
+	 * This method returns the activity associated with
+	 * the 'else' construct.
+	 * 
+	 * @return The activity
+	 */
+	public BPELElement getActivity() {
+		return(m_activity);
+	}
+	
+	protected String getLocalURIPart(BPELElement elem) {
+		String ret="";
+		
+		if (elem instanceof BPELActivity) {
+			ret = "@activity";
+		}
+		
+		return(ret);
+	}
+	
+	private BPELElement m_activity;
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Elseif.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Elseif.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Elseif.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,139 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import java.util.List;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.scribble.model.Activity;
+
+/**
+ * This class represents the 'elseif' construct contained
+ * within the 'if' activity.
+ */
+public class Elseif extends BPELElement {
+
+	private static final long serialVersionUID = 6371029130621912170L;
+
+	public static final String ELSEIF="elseif";
+	
+	/**
+	 * The constructor for the element.
+	 * 
+	 * @param model The BPEL model
+	 * @param activity The XML configuration details for the element
+	 */
+	public Elseif(BPELLanguageModel model,
+					org.w3c.dom.Element activity) {
+		super(model, activity);
+
+		org.w3c.dom.Element cond=
+				findChildElement(Condition.CONDITION);
+	
+		if (cond == null) {
+			m_condition = new Condition(model);
+		} else {
+			m_condition = new Condition(model, cond);
+		}
+		
+		m_activity = findChildActivity();
+	}
+
+	/**
+	 * The constructor for the element.
+	 * 
+	 * @param model The BPEL model
+	 */
+	public Elseif(BPELLanguageModel model) {
+		super(model, ELSEIF);
+	}
+
+	@Override
+	public void convert(List<Activity> activities, ConversionContext context) {
+		
+		if (getActivity() != null) {
+			getActivity().convert(activities, context);
+		}
+	}
+	
+	/**
+	 * This method sets the condition.
+	 * 
+	 * @param cond The condition
+	 */
+	public void setCondition(Condition cond) {
+		m_condition = cond;
+		
+		setChildElement(findChildElement(Condition.CONDITION),
+				cond, getDOMElement().getFirstChild());
+	}
+	
+	/**
+	 * This method returns the condition.
+	 * 
+	 * @return The condition
+	 */
+	public Condition getCondition() {
+		return(m_condition);
+	}
+
+	/**
+	 * This method sets the activity associated with
+	 * the 'else' construct.
+	 * 
+	 * @param act The activity
+	 */
+	public void setActivity(BPELElement act) {
+		m_activity = act;
+		
+		BPELElement existing=findChildActivity();
+		org.w3c.dom.Element existingElem=null;
+		
+		if (existing != null) {
+			existingElem = existing.getDOMElement();
+		}
+
+		org.w3c.dom.Element insertBefore=null;
+		
+		setChildElement(existingElem, act,
+						insertBefore);
+	}
+	
+	/**
+	 * This method returns the activity associated with
+	 * the 'else' construct.
+	 * 
+	 * @return The activity
+	 */
+	public BPELElement getActivity() {
+		return(m_activity);
+	}
+	
+	protected String getLocalURIPart(BPELElement elem) {
+		String ret="";
+		
+		if (elem instanceof BPELActivity) {
+			ret = "@activity";
+		}
+		
+		return(ret);
+	}
+	
+	private Condition m_condition;
+	private BPELElement m_activity;
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/EventHandlers.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/EventHandlers.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/EventHandlers.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,230 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class represents the 'eventHandlers' component within
+ * a 'scope' element.
+ *  
+ * @author gary
+ */
+public class EventHandlers extends BPELElement {
+
+	private static final long serialVersionUID = 118381918664522750L;
+
+	public static final String EVENTHANDLERS = "eventHandlers";
+	
+	/**
+	 * The constructor for the activity.
+	 * 
+	 * @param model The BPEL model
+	 * @param activity The XML configuration details for the activity
+	 */
+	public EventHandlers(BPELLanguageModel model,
+					org.w3c.dom.Element activity) {
+		super(model, activity);
+		
+		java.util.List<BPELElement> onevts=
+					findChildElements(OnEvent.class);
+		
+		for (int i=0; i < onevts.size(); i++) {
+			if (onevts.get(i) instanceof OnEvent) {
+				m_onEvents.add((OnEvent)onevts.get(i));
+			}
+		}
+		
+		java.util.List<BPELElement> onalrms=
+					findChildElements(OnAlarm.class);
+		
+		for (int i=0; i < onalrms.size(); i++) {
+			if (onalrms.get(i) instanceof OnAlarm) {
+				m_onAlarms.add((OnAlarm)onalrms.get(i));
+			}
+		}
+	}
+
+	/**
+	 * The constructor for the activity.
+	 * 
+	 * @param model The BPEL model
+	 */
+	public EventHandlers(BPELLanguageModel model) {
+		super(model, EVENTHANDLERS);
+	}
+
+	/**
+	 * This method adds an 'onEvent' to the grouping construct.
+	 * 
+	 * @param on The 'onEvent' to be added
+	 * @param pos The position to add, or -1 if at the end
+	 */
+	public void addOnEvent(OnEvent on, int pos) {
+		if (pos == -1 || pos >= m_onEvents.size()) {
+			m_onEvents.add(on);
+			
+			org.w3c.dom.Element insertBefore=null;
+			
+			if (m_onAlarms.size() > 0) {
+				insertBefore = m_onAlarms.get(0).getDOMElement();
+			}
+			
+			setChildElement(null, on, insertBefore);
+		} else {
+			
+			OnEvent cur=m_onEvents.get(pos);
+			
+			m_onEvents.add(pos, on);
+			
+			if (cur != null) {
+				setChildElement(null, on,
+							cur.getDOMElement());
+			} else {
+				org.w3c.dom.Element insertBefore=null;
+				
+				if (m_onAlarms.size() > 0) {
+					insertBefore = m_onAlarms.get(0).getDOMElement();
+				}
+				
+				setChildElement(null, on, insertBefore);
+			}
+		}
+	}
+	
+	/**
+	 * This method removes an 'onEvent' from the grouping
+	 * construct.
+	 * 
+	 * @param on The 'onEvent' to be removed
+	 * @return Whether the 'onEvent' was removed
+	 */
+	public boolean removeOnEvent(OnEvent on) {
+		boolean ret=m_onEvents.remove(on);
+		
+		if (ret) {
+			getDOMElement().removeChild(on.getDOMElement());
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the list of 'onEvent' associated
+	 * with the grouping construct.
+	 * 
+	 * @return The list of 'onEvent' elements
+	 */
+	public java.util.List<OnEvent> getOnEvents() {
+		return(m_onEvents);
+	}
+
+	/**
+	 * This method adds an 'onAlarm' to the grouping construct.
+	 * 
+	 * @param on The 'onAlarm' to be added
+	 * @param pos The position to add, or -1 if at the end
+	 */
+	public void addOnAlarm(OnAlarm on, int pos) {
+		if (pos == -1 || pos >= m_onAlarms.size()) {
+			m_onAlarms.add(on);
+			
+			setChildElement(null, on, null);
+		} else {
+			
+			OnAlarm cur=m_onAlarms.get(pos);
+			
+			m_onAlarms.add(pos, on);
+			
+			if (cur != null) {
+				setChildElement(null, on,
+							cur.getDOMElement());
+			} else {
+				setChildElement(null, on, null);
+			}
+		}
+	}
+	
+	/**
+	 * This method removes an 'onAlarm' from the grouping
+	 * construct.
+	 * 
+	 * @param on The 'onAlarm' to be removed
+	 * @return Whether the 'onAlarm' was removed
+	 */
+	public boolean removeOnAlarm(OnAlarm on) {
+		boolean ret=m_onAlarms.remove(on);
+		
+		if (ret) {
+			getDOMElement().removeChild(on.getDOMElement());
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the list of 'onAlarm' associated
+	 * with the grouping construct.
+	 * 
+	 * @return The list of 'onAlarm' elements
+	 */
+	public java.util.List<OnAlarm> getOnAlarms() {
+		return(m_onAlarms);
+	}
+
+	/**
+	 * This method validates the BPEL activity and reports warnings or
+	 * errors to the supplied model listener.
+	 * 
+	 * @param l The model listener
+	 */
+	@Override
+	public void validate(ModelListener l) {
+	}
+	
+	/**
+	 * This method converts the BPEL activity into an equivalent
+	 * behavioural description for conformance checking.
+	 * 
+	 * @param activities The list of activities that will contain
+	 * 				the converted action(s)
+	 * @param context The conversion context
+	 */
+	public void convert(java.util.List<Activity> activities,
+			ConversionContext context) {
+	}
+
+	protected String getLocalURIPart(BPELElement elem) {
+		String ret="";
+		
+		if (elem instanceof OnEvent) {
+			ret += "@onEvent."+getOnEvents().indexOf(elem);
+		} else if (elem instanceof OnAlarm) {
+			ret += "@onAlarm."+getOnAlarms().indexOf(elem);
+		}
+		
+		return(ret);
+	}
+	
+	private java.util.List<OnEvent> m_onEvents=
+					new java.util.Vector<OnEvent>();
+	private java.util.List<OnAlarm> m_onAlarms=
+					new java.util.Vector<OnAlarm>();
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Exit.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Exit.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Exit.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class represents the exit activity.
+ *  
+ * @author gary
+ */
+public class Exit extends BPELActivity {
+
+	private static final long serialVersionUID = -5261386654111234711L;
+
+	public static final String EXIT = "exit";
+	
+	/**
+	 * The constructor for the activity.
+	 * 
+	 * @param model The BPEL model
+	 * @param activity The XML configuration details for the activity
+	 */
+	public Exit(BPELLanguageModel  model,
+					org.w3c.dom.Element activity) {
+		super(model, activity);
+	}
+
+	/**
+	 * The constructor for the activity.
+	 * 
+	 * @param model The BPEL model
+	 */
+	public Exit(BPELLanguageModel model) {
+		super(model, EXIT);
+	}
+
+	/**
+	 * This method validates the BPEL activity and reports warnings or
+	 * errors to the supplied model listener.
+	 * 
+	 * @param l The model listener
+	 */
+	@Override
+	public void validate(ModelListener l) {
+		// Don't validate unsupported actions
+	}
+	
+	/**
+	 * This method does the actual work of converting the specific
+	 * BPEL activity into an equivalent behavioural description for 
+	 * conformance checking. The 'convert' method provides
+	 * a wrapper around this method, to handle the standard elements
+	 * that can be associated with any BPEL activity.
+	 * 
+	 * @param activities The list of activities that will contain
+	 * 				the converted action(s)
+	 * @param context The conversion context
+	 */
+	protected void convertActivity(java.util.List<Activity> activities,
+			ConversionContext context) {
+		getSource().setComponentURI(getURI());
+	}
+
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/FaultHandlers.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/FaultHandlers.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/FaultHandlers.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,148 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import java.util.List;
+
+import org.apache.commons.logging.*;
+import org.savara.bpel.model.BPELLanguageModel;
+import org.scribble.model.Activity;
+
+/**
+ * This class represents the 'faultHandlers' construct contained
+ * within the 'scope' activity.
+ */
+public class FaultHandlers extends BPELElement {
+
+	private static final long serialVersionUID = 4136137332367247503L;
+
+	public static final String FAULTHANDLERS="faultHandlers";
+	
+	/**
+	 * The constructor for the element.
+	 * 
+	 * @param model The BPEL model
+	 * @param activity The XML configuration details for the element
+	 */
+	public FaultHandlers(BPELLanguageModel model,
+					org.w3c.dom.Element activity) {
+		super(model, activity);
+		
+		java.util.List<BPELElement> paths=
+				findChildElements(Catch.class);
+
+		for (int i=0; i < paths.size(); i++) {
+			m_catchPaths.add((Catch)paths.get(i));
+		}
+		
+		paths = findChildElements(CatchAll.class);
+		
+		if (paths.size() > 0) {
+			m_catchAll = (CatchAll)paths.get(0);
+		
+			if (paths.size() > 1) {
+				logger.error("BPEL 'faultHandlers' has multiple 'catchAll' constructs");
+			}
+		}
+	}
+
+	/**
+	 * The constructor for the element.
+	 * 
+	 * @param model The BPEL model
+	 */
+	public FaultHandlers(BPELLanguageModel model) {
+		super(model, FAULTHANDLERS);
+	}
+
+	/**
+	 * This method adds a 'catch' path.
+	 * 
+	 * @param act The 'catch' path
+	 */
+	public void addCatch(Catch act) {
+		m_catchPaths.add(act);
+
+		org.w3c.dom.Element insertBefore=null;
+		
+		if (m_catchAll != null) {
+			insertBefore = m_catchAll.getDOMElement();
+		}
+		
+		setChildElement(null, act,
+						insertBefore);
+	}
+	
+	/**
+	 * This method returns the list of 'catch' paths.
+	 * 
+	 * @return The list of 'catch' paths
+	 */
+	public java.util.List<Catch> getCatchPaths() {
+		return(m_catchPaths);
+	}
+	
+	/**
+	 * This method sets the 'catchAll' path.
+	 * 
+	 * @param act The 'catchAll' path
+	 */
+	public void setCatchAll(CatchAll act) {
+		org.w3c.dom.Element existingElem=null;
+		
+		if (m_catchAll != null) {
+			existingElem = m_catchAll.getDOMElement();
+		}
+
+		m_catchAll = act;
+		
+		setChildElement(existingElem, act,
+						null);
+	}
+	
+	/**
+	 * This method returns the 'catchAll' path.
+	 * 
+	 * @return The 'catchAll' path
+	 */
+	public CatchAll getCatchAll() {
+		return(m_catchAll);
+	}
+
+	@Override
+	public void convert(List<Activity> activities, ConversionContext context) {
+	}
+
+	protected String getLocalURIPart(BPELElement elem) {
+		String ret="";
+		
+		if (elem instanceof Catch) {
+			ret += "@catch."+getCatchPaths().indexOf(elem);
+		} else if (elem instanceof CatchAll) {
+			ret += "@catchAll";
+		}
+		
+		return(ret);
+	}
+	
+	private static Log logger=LogFactory.getLog(FaultHandlers.class);
+	
+	private CatchAll m_catchAll=null;
+	private java.util.List<Catch> m_catchPaths=
+				new java.util.Vector<Catch>();
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Flow.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Flow.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Flow.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,287 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class represents a flow grouping activity.
+ *  
+ */
+public class Flow extends BPELActivity {
+
+	private static final long serialVersionUID = -5165269453306785719L;
+
+	public static final String FLOW = "flow";
+	public static final String LINKS = "links";
+
+	/**
+	 * The constructor for the activity.
+	 * 
+	 * @param model The BPEL model
+	 * @param activity The XML configuration details for the activity
+	 */
+	public Flow(BPELLanguageModel model,
+					org.w3c.dom.Element activity) {
+		super(model, activity);
+		
+		org.w3c.dom.Element links=findChildElement("links");
+		
+		if (links != null) {
+			org.w3c.dom.NodeList nl=links.getChildNodes();
+		
+			for (int i=0; i < nl.getLength(); i++) {
+				if (nl.item(i) instanceof org.w3c.dom.Element &&
+						nl.item(i).getLocalName().equals(Link.LINK)
+						&& nl.item(i) instanceof org.w3c.dom.Element) {
+					m_links.add(new Link(model,
+							(org.w3c.dom.Element)nl.item(i)));
+				}
+			}
+		}
+		
+		java.util.List<BPELElement> acts=
+					findChildElements(BPELActivity.class);
+		
+		for (int i=0; i < acts.size(); i++) {
+			if (acts.get(i).isActivity() &&
+					acts.get(i) instanceof BPELActivity) {
+				m_activities.add((BPELActivity)acts.get(i));
+			}
+		}
+	}
+
+	/**
+	 * The constructor for the activity.
+	 * 
+	 * @param model The BPEL model
+	 */
+	public Flow(BPELLanguageModel model) {
+		super(model, FLOW);
+	}
+
+	/**
+	 * This method adds a link to the grouping construct.
+	 * 
+	 * @param link The link to be added
+	 * @param pos The position to add, or -1 if at the end
+	 */
+	public void addLink(Link link, int pos) {
+		
+		org.w3c.dom.Element links=null;
+		
+		if (m_links.size() == 0) {
+			links = getDOMElement().getOwnerDocument().
+						createElementNS(BPEL_NS, LINKS);
+			
+			if (getDOMElement().getFirstChild() == null) {
+				getDOMElement().appendChild(links);
+			} else {
+				getDOMElement().insertBefore(links,
+						getDOMElement().getFirstChild());
+			}
+		} else {
+			links = findChildElement(LINKS);
+		}
+		
+		org.w3c.dom.Node newNode=link.getDOMElement().cloneNode(true);
+		
+		getDOMElement().getOwnerDocument().adoptNode(newNode);
+		
+		link.setDOMElement((org.w3c.dom.Element)newNode);
+		
+		if (pos == -1 && pos < m_links.size()) {
+			m_links.add(link);
+			
+			links.appendChild(newNode);
+		} else {
+			
+			Link cur=m_links.get(pos);
+			
+			m_links.add(pos, link);
+			
+			if (cur != null) {
+				links.insertBefore(newNode,
+							cur.getDOMElement());
+			} else {
+				links.appendChild(newNode);
+			}
+		}
+	}
+	
+	/**
+	 * This method removes a link from the grouping
+	 * construct.
+	 * 
+	 * @param link The link to be removed
+	 * @return Whether the link was removed
+	 */
+	public boolean removeLink(Link link) {
+		boolean ret=m_links.remove(link);
+		
+		if (ret) {
+			org.w3c.dom.Element links=
+						findChildElement(LINKS);
+			
+			if (links != null) {
+				links.removeChild(link.getDOMElement());
+				
+				if (m_links.size() == 0) {
+					getDOMElement().removeChild(links);
+				}
+			}
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the list of links associated
+	 * with the grouping construct.
+	 * 
+	 * @return The list of links
+	 */
+	public java.util.List<Link> getLinks() {
+		return(m_links);
+	}
+
+	/**
+	 * This method adds an activity to the grouping construct.
+	 * 
+	 * @param act The activity to be added
+	 * @param pos The position to add, or -1 if at the end
+	 */
+	public void addActivity(BPELActivity act, int pos) {
+		if (pos == -1 && pos < m_activities.size()) {
+			m_activities.add(act);
+			
+			setChildElement(null, act, null);
+		} else {
+			
+			BPELActivity cur=m_activities.get(pos);
+			
+			m_activities.add(pos, act);
+			
+			if (cur != null) {
+				setChildElement(null, act,
+							cur.getDOMElement());
+			} else {
+				setChildElement(null, act, null);
+			}
+		}
+	}
+	
+	/**
+	 * This method removes an activity from the grouping
+	 * construct.
+	 * 
+	 * @param act The activity to be removed
+	 * @return Whether the activity was removed
+	 */
+	public boolean removeActivity(BPELActivity act) {
+		boolean ret=m_activities.remove(act);
+		
+		if (ret) {
+			getDOMElement().removeChild(act.getDOMElement());
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the list of activities associated
+	 * with the grouping construct.
+	 * 
+	 * @return The list of activities
+	 */
+	public java.util.List<BPELActivity> getActivities() {
+		return(m_activities);
+	}
+
+	/**
+	 * This method validates the BPEL activity and reports warnings or
+	 * errors to the supplied model listener.
+	 * 
+	 * @param l The model listener
+	 */
+	@Override
+	public void validate(ModelListener l) {
+	}
+	
+	/**
+	 * This method does the actual work of converting the specific
+	 * BPEL activity into an equivalent behavioural description for 
+	 * conformance checking. The 'convert' method provides
+	 * a wrapper around this method, to handle the standard elements
+	 * that can be associated with any BPEL activity.
+	 * 
+	 * @param activities The list of activities that will contain
+	 * 				the converted action(s)
+	 * @param context The conversion context
+	 */
+	protected void convertActivity(java.util.List<Activity> activities,
+			ConversionContext context) {
+		getSource().setComponentURI(getURI());
+		
+		// If links have been defined, represent them as boolean
+		// variables that can be tested using a 'when' clause
+		if (getLinks().size() > 0) {
+			org.scribble.conversation.model.VariableList vl=
+				new org.scribble.conversation.model.VariableList();
+			
+			org.scribble.model.TypeReference tref=
+					new org.scribble.model.TypeReference();
+			tref.setLocalpart("boolean");
+			
+			vl.setType(tref);
+			
+			for (int i=0; i < getLinks().size(); i++) {
+				Link l=getLinks().get(i);
+				
+				org.scribble.conversation.model.Variable var=
+					new org.scribble.conversation.model.Variable();
+				
+				var.setName(l.getName());
+				
+				vl.getVariables().add(var);
+			}
+			
+			activities.add(vl);
+		}
+		
+		org.scribble.conversation.model.Parallel parallel=
+					new org.scribble.conversation.model.Parallel();
+		
+		for (int i=0; i < getActivities().size(); i++) {
+			Block b=new Block();
+			
+			getActivities().get(i).convert(b.getContents(), context);
+			
+			parallel.getBlocks().add(b);
+		}
+		
+		activities.add(parallel);
+	}
+
+	private java.util.List<Link> m_links=
+		new java.util.Vector<Link>();
+	private java.util.List<BPELActivity> m_activities=
+		new java.util.Vector<BPELActivity>();
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/For.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/For.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/For.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.BPELLanguageModel;
+
+/**
+ * This class represents the BPEL 'for' element.
+ */
+public class For extends AbstractCondition {
+
+	private static final long serialVersionUID = -3123540793706121742L;
+
+	public static final String FOR="for";
+	
+	/**
+	 * The constructor for the element.
+	 * 
+	 * @param model The BPEL model
+	 * @param elem The XML configuration details for the element
+	 */
+	public For(BPELLanguageModel model,
+					org.w3c.dom.Element elem) {
+		super(model, elem);
+	}
+
+	/**
+	 * The constructor for the element.
+	 * 
+	 * @param model The BPEL model
+	 */
+	public For(BPELLanguageModel model) {
+		super(model, FOR);
+	}
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/ForEach.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/ForEach.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/ForEach.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,124 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class represents a forEach grouping activity.
+ *  
+ * @author gary
+ */
+public class ForEach extends BPELGroupingConstruct {
+
+	private static final long serialVersionUID = -4302270930464272401L;
+
+	public static final String FOREACH = "forEach";
+
+	/**
+	 * The constructor for the activity.
+	 * 
+	 * @param model The BPEL model
+	 * @param activity The XML configuration details for the activity
+	 */
+	public ForEach(BPELLanguageModel model,
+					org.w3c.dom.Element activity) {
+		super(model, activity);
+	
+		org.w3c.dom.Element scopeElem=
+			findChildElement(Scope.SCOPE);
+
+		if (scopeElem == null) {
+			m_scope = new Scope(model);
+		} else {
+			m_scope = new Scope(model, scopeElem);
+		}
+	}
+
+	/**
+	 * The constructor for the activity.
+	 * 
+	 * @param model The BPEL model
+	 */
+	public ForEach(BPELLanguageModel model) {
+		super(model, FOREACH);
+	}
+
+	/**
+	 * This method sets the scope.
+	 * 
+	 * @param scope The scope
+	 */
+	public void setScope(Scope scope) {
+		m_scope = scope;
+		
+		org.w3c.dom.Element existingElem=this.findChildElement(Scope.SCOPE);
+		
+		setChildElement(existingElem, scope,
+						null);
+	}
+
+	/**
+	 * This method returns the scope.
+	 * 
+	 * @return The scope
+	 */
+	public Scope getScope() {
+		return(m_scope);
+	}
+	
+	/**
+	 * This method validates the BPEL activity and reports warnings or
+	 * errors to the supplied model listener.
+	 * 
+	 * @param l The model listener
+	 */
+	@Override
+	public void validate(ModelListener l) {
+	}
+	
+	/**
+	 * This method does the actual work of converting the specific
+	 * BPEL activity into an equivalent behavioural description for 
+	 * conformance checking. The 'convert' method provides
+	 * a wrapper around this method, to handle the standard elements
+	 * that can be associated with any BPEL activity.
+	 * 
+	 * @param activities The list of activities that will contain
+	 * 				the converted action(s)
+	 * @param context The conversion context
+	 */
+	protected void convertActivity(java.util.List<Activity> activities,
+			ConversionContext context) {
+		getSource().setComponentURI(getURI());
+	}
+
+	protected String getLocalURIPart(BPELElement elem) {
+		String ret="";
+		
+		if (elem instanceof Scope) {
+			ret += "@scope";
+		}
+		
+		return(ret);
+	}
+	
+	private Scope m_scope=null;
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/If.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/If.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/If.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,290 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.*;
+import org.scribble.conversation.model.ConditionalBlock;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.apache.commons.logging.*;
+
+/**
+ * This class represents an 'if' grouping construct.
+ *  
+ * @author gary
+ */
+public class If extends BPELActivity {
+
+	private static final long serialVersionUID = -763221632866464831L;
+	
+	public static final String IF = "if";
+
+	/**
+	 * The constructor for the activity.
+	 * 
+	 * @param model The BPEL model
+	 * @param activity The XML configuration details for the activity
+	 */
+	public If(BPELLanguageModel model,
+					org.w3c.dom.Element activity) {
+		super(model, activity);
+
+		org.w3c.dom.Element cond=
+				findChildElement(Condition.CONDITION);
+
+		if (cond == null) {
+			m_condition = new Condition(model);
+		} else {
+			m_condition = new Condition(model, cond);
+		}
+	
+		m_activity = findChildActivity();
+		
+		java.util.List<BPELElement> paths=
+						findChildElements(Elseif.class);
+		
+		for (int i=0; i < paths.size(); i++) {
+			m_elseIfPaths.add((Elseif)paths.get(i));
+		}
+		
+		paths = findChildElements(Else.class);
+		
+		if (paths.size() > 0) {
+			m_elsePath = (Else)paths.get(0);
+			
+			if (paths.size() > 1) {
+				logger.error("BPEL 'if' has multiple 'else' constructs");
+			}
+		}
+	}
+
+	/**
+	 * The constructor for the activity.
+	 * 
+	 * @param model The BPEL model
+	 */
+	public If(BPELLanguageModel model) {
+		super(model, IF);
+	}
+
+	/**
+	 * This method validates the BPEL activity and reports warnings or
+	 * errors to the supplied model listener.
+	 * 
+	 * @param l The model listener
+	 */
+	@Override
+	public void validate(ModelListener l) {
+	}
+	
+	/**
+	 * This method does the actual work of converting the specific
+	 * BPEL activity into an equivalent behavioural description for 
+	 * conformance checking. The 'convert' method provides
+	 * a wrapper around this method, to handle the standard elements
+	 * that can be associated with any BPEL activity.
+	 * 
+	 * @param activities The list of activities that will contain
+	 * 				the converted action(s)
+	 * @param context The conversion context
+	 */
+	protected void convertActivity(java.util.List<Activity> activities,
+			ConversionContext context) {
+		getSource().setComponentURI(getURI());
+		
+		org.scribble.conversation.model.If elem=
+					new org.scribble.conversation.model.If();
+		
+		ConditionalBlock cb=new ConditionalBlock();
+		
+		// TODO: Convert the conditional expression
+		
+		if (getActivity() != null) {
+			getActivity().convert(cb.getContents(), context);
+		}
+		
+		elem.getConditionalBlocks().add(cb);
+		
+		// Convert 'else if' paths
+		for (int i=0; i < getElseIfPaths().size(); i++) {
+			Elseif elseIfElem=getElseIfPaths().get(i);
+			
+			cb = new ConditionalBlock();
+			
+			elseIfElem.convert(cb.getContents(), context);
+			
+			elem.getConditionalBlocks().add(cb);
+		}
+		
+		// Convert 'else' path
+		if (getElsePath() != null) {
+			cb = new ConditionalBlock();
+			
+			getElsePath().convert(cb.getContents(), context);
+			
+			elem.getConditionalBlocks().add(cb);
+		}
+		
+		activities.add(elem);
+	}
+
+	/**
+	 * This method sets the condition.
+	 * 
+	 * @param cond The condition
+	 */
+	public void setCondition(Condition cond) {
+		m_condition = cond;
+		
+		org.w3c.dom.Element insertBefore=null;
+		
+		if (m_activity != null) {
+			insertBefore = m_activity.getDOMElement();
+		} else if (m_elseIfPaths.size() > 0) {
+			insertBefore = m_elseIfPaths.get(0).getDOMElement();
+		} else if (m_elsePath != null) {
+			insertBefore = m_elsePath.getDOMElement();
+		}
+		
+		setChildElement(findChildElement(Condition.CONDITION),
+				cond, insertBefore);
+	}
+	
+	/**
+	 * This method returns the condition.
+	 * 
+	 * @return The condition
+	 */
+	public Condition getCondition() {
+		return(m_condition);
+	}
+
+	/**
+	 * This method sets the main 'if' activity.
+	 * 
+	 * @param act The activity associated with the 'if'
+	 */
+	public void setActivity(BPELElement act) {
+		m_activity = act;
+		
+		BPELElement existing=findChildActivity();
+		org.w3c.dom.Element existingElem=null;
+		
+		if (existing != null) {
+			existingElem = existing.getDOMElement();
+		}
+
+		org.w3c.dom.Element insertBefore=null;
+		
+		if (m_elseIfPaths.size() > 0) {
+			insertBefore = m_elseIfPaths.get(0).getDOMElement();
+		} else if (m_elsePath != null) {
+			insertBefore = m_elsePath.getDOMElement();
+		}
+		
+		setChildElement(existingElem, act,
+						insertBefore);
+	}
+
+	/**
+	 * This method returns the activity associated with
+	 * the 'if' path.
+	 * 
+	 * @return The 'if' activity
+	 */
+	public BPELElement getActivity() {
+		return(m_activity);
+	}
+	
+	/**
+	 * This method adds an 'else if' path.
+	 * 
+	 * @param act The 'else if' path
+	 */
+	public void addElseIfPath(Elseif act) {
+		m_elseIfPaths.add(act);
+
+		org.w3c.dom.Element insertBefore=null;
+		
+		if (m_elsePath != null) {
+			insertBefore = m_elsePath.getDOMElement();
+		}
+		
+		setChildElement(null, act,
+						insertBefore);
+	}
+	
+	/**
+	 * This method returns the list of 'else if' paths.
+	 * 
+	 * @return The list of 'else if' paths
+	 */
+	public java.util.List<Elseif> getElseIfPaths() {
+		return(m_elseIfPaths);
+	}
+	
+	/**
+	 * This method sets the 'else' path.
+	 * 
+	 * @param act The 'else' path
+	 */
+	public void setElsePath(Else act) {
+		org.w3c.dom.Element existingElem=null;
+		
+		if (m_elsePath != null) {
+			existingElem = m_elsePath.getDOMElement();
+		}
+
+		m_elsePath = act;
+		
+		setChildElement(existingElem, act,
+						null);
+	}
+	
+	/**
+	 * This method returns the 'else' path.
+	 * 
+	 * @return The 'else' path
+	 */
+	public Else getElsePath() {
+		return(m_elsePath);
+	}
+	
+	protected String getLocalURIPart(BPELElement elem) {
+		String ret="";
+		
+		if (elem instanceof Elseif) {
+			int pos=getElseIfPaths().indexOf(elem);
+			ret = "@elseif."+pos;
+		} else if (elem instanceof Else) {
+			ret = "@else";
+		} else {
+			ret = "@activity";
+		}
+		
+		return(ret);
+	}
+	
+	private static Log logger=LogFactory.getLog(If.class);
+	
+	private Condition m_condition=null;
+	private BPELElement m_activity=null;
+	private Else m_elsePath=null;
+	private java.util.List<Elseif> m_elseIfPaths=
+				new java.util.Vector<Elseif>();
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Import.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Import.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Import.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,120 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import java.util.List;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.scribble.model.Activity;
+
+/**
+ * This class represents the 'import' construct.
+ */
+public class Import extends BPELElement {
+
+	private static final long serialVersionUID = -7103589689575940289L;
+
+	private static final String IMPORT_TYPE = "importType";
+	private static final String NAMESPACE = "namespace";
+	private static final String LOCATION = "location";
+
+	public static final String IMPORT="import";
+	
+	/**
+	 * The constructor for the element.
+	 * 
+	 * @param model The BPEL model
+	 * @param activity The XML configuration details for the element
+	 */
+	public Import(BPELLanguageModel model,
+					org.w3c.dom.Element activity) {
+		super(model, activity);
+	}
+
+	/**
+	 * The constructor for the element.
+	 * 
+	 * @param model The BPEL model
+	 */
+	public Import(BPELLanguageModel model) {
+		super(model, IMPORT);
+	}
+
+	/**
+	 * This method sets the import type.
+	 * 
+	 * @param importType The import type
+	 */
+	public void setImportType(String importType) {		
+		getDOMElement().setAttribute(IMPORT_TYPE, importType);
+	}
+	
+	/**
+	 * This method returns the iport type.
+	 * 
+	 * @return The import type
+	 */
+	public String getImportType() {
+		return(getDOMElement().hasAttribute(IMPORT_TYPE)?
+				getDOMElement().getAttribute(IMPORT_TYPE):null);
+	}
+
+	/**
+	 * This method sets the namespace.
+	 * 
+	 * @param ns The namespace
+	 */
+	public void setNamespace(String ns) {		
+		getDOMElement().setAttribute(NAMESPACE, ns);
+	}
+	
+	/**
+	 * This method returns the namespace.
+	 * 
+	 * @return The namespace
+	 */
+	public String getNamespace() {
+		return(getDOMElement().hasAttribute(NAMESPACE)?
+				getDOMElement().getAttribute(NAMESPACE):null);
+	}
+
+	/**
+	 * This method sets the location.
+	 * 
+	 * @param location The location
+	 */
+	public void setLocation(String location) {		
+		getDOMElement().setAttribute(LOCATION, location);
+	}
+	
+	/**
+	 * This method returns the location.
+	 * 
+	 * @return The location
+	 */
+	public String getLocation() {
+		return(getDOMElement().hasAttribute(LOCATION)?
+				getDOMElement().getAttribute(LOCATION):null);
+	}
+
+	@Override
+	public void convert(List<Activity> activities, ConversionContext context) {
+		// TODO Auto-generated method stub
+		
+	}
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Invoke.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Invoke.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Invoke.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,319 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.*;
+import org.savara.bpel.model.util.TypeReferenceUtil;
+import org.savara.util.XMLUtils;
+import org.scribble.conversation.model.ConversationInteraction;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class represents an unsupported (or custom) action within
+ * the conversation based ESB service descriptor.
+ *  
+ * @author gary
+ */
+public class Invoke extends AbstractInteraction {
+
+	private static final String INPUT_VARIABLE = "inputVariable";
+	private static final String OUTPUT_VARIABLE = "outputVariable";
+	public static final String INVOKE = "invoke";
+	
+	private static final long serialVersionUID = 928076947383263387L;
+
+	/**
+	 * The constructor for the activity.
+	 * 
+	 * @param model The BPEL model
+	 * @param activity The XML configuration details for the activity
+	 */
+	public Invoke(BPELLanguageModel model,
+					org.w3c.dom.Element activity) {
+		super(model, activity);
+	}
+
+	/**
+	 * The constructor for the activity.
+	 * 
+	 * @param model The BPEL model
+	 */
+	public Invoke(BPELLanguageModel model) {
+		super(model, INVOKE);
+	}
+	
+	/**
+	 * This method sets the input variable.
+	 * 
+	 * @param var The input variable
+	 */
+	public void setInputVariable(String var) {		
+		getDOMElement().setAttribute(INPUT_VARIABLE, var);
+	}
+	
+	/**
+	 * This method returns the input variable.
+	 * 
+	 * @return The input variable
+	 */
+	public String getInputVariable() {
+		return(getDOMElement().hasAttribute(INPUT_VARIABLE)?
+				getDOMElement().getAttribute(INPUT_VARIABLE):null);
+	}
+
+	/**
+	 * This method sets the output variable.
+	 * 
+	 * @param var The output variable
+	 */
+	public void setOutputVariable(String var) {		
+		getDOMElement().setAttribute(OUTPUT_VARIABLE, var);
+	}
+	
+	/**
+	 * This method returns the output variable.
+	 * 
+	 * @return The output variable
+	 */
+	public String getOutputVariable() {
+		return(getDOMElement().hasAttribute(OUTPUT_VARIABLE)?
+				getDOMElement().getAttribute(OUTPUT_VARIABLE):null);
+	}
+
+	/**
+	 * This method validates the BPEL activity and reports warnings or
+	 * errors to the supplied model listener.
+	 * 
+	 * @param l The model listener
+	 */
+	@Override
+	public void validate(ModelListener l) {
+	}
+	
+	/**
+	 * This method does the actual work of converting the specific
+	 * BPEL activity into an equivalent behavioural description for 
+	 * conformance checking. The 'convert' method provides
+	 * a wrapper around this method, to handle the standard elements
+	 * that can be associated with any BPEL activity.
+	 * 
+	 * @param activities The list of activities that will contain
+	 * 				the converted action(s)
+	 * @param context The conversion context
+	 */
+	protected void convertActivity(java.util.List<Activity> activities,
+			ConversionContext context) {
+		getSource().setComponentURI(getURI());
+		
+		convertRequest(activities, context);
+		
+		// Check if invoke is contained within a scope that defines
+		// fault handlers. If so, then generate choice to throw
+		// fault exceptions.
+		ScopeActivity scope=null;
+		org.w3c.dom.Element cur=getDOMElement();
+		
+		while (cur != null && cur.getParentNode() instanceof org.w3c.dom.Element &&
+							scope == null) {
+			cur = (org.w3c.dom.Element)cur.getParentNode();
+			
+			if (cur != null) {
+				BPELElement elem=BPELElementFactory.createBPELElement(getModel(),
+										cur);
+				
+				if (elem instanceof ScopeActivity) {
+					scope = (ScopeActivity)elem;
+				}
+			}
+		}
+		
+		if (scope != null && scope.getFaultHandlers() != null &&
+						(scope.getFaultHandlers().getCatchPaths().size() > 0 ||
+						scope.getFaultHandlers().getCatchAll() != null)) {
+			org.scribble.conversation.model.If te=
+					new org.scribble.conversation.model.If();
+			te.derivedFrom(this);
+			
+			activities.add(te);
+			
+			org.scribble.conversation.model.ConditionalBlock cb=
+						new org.scribble.conversation.model.ConditionalBlock();
+			te.getConditionalBlocks().add(cb);
+			
+			activities = cb.getContents();
+			
+			for (int i=0; i < scope.getFaultHandlers().getCatchPaths().size(); i++) {
+				Catch catchBlock=scope.getFaultHandlers().getCatchPaths().get(i);
+
+				org.scribble.conversation.model.ConditionalBlock fcb=
+					new org.scribble.conversation.model.ConditionalBlock();
+				
+				String mesgType=catchBlock.getFaultMessageType();
+				
+				if (mesgType == null) {
+					mesgType = catchBlock.getFaultMessageElement();
+				}
+				
+				Variable faultVar=null;
+				
+				if (catchBlock.getFaultVariable() != null) {
+					faultVar = new Variable(getModel());
+					faultVar.setName(catchBlock.getFaultVariable());
+					faultVar.setMessageType(catchBlock.getFaultMessageType());
+					faultVar.setElement(catchBlock.getFaultMessageElement());			
+					context.addVariable(faultVar);
+				}
+				
+				convertFaultResponse(fcb.getContents(), catchBlock.getFaultVariable(),
+									mesgType, context);
+				
+				org.scribble.conversation.model.Raise raise=
+							new org.scribble.conversation.model.Raise();
+				
+				TypeReference tref=new TypeReference();
+				tref.setLocalpart(XMLUtils.getLocalname(catchBlock.getFaultName()));
+				raise.setType(tref);
+				
+				fcb.getContents().add(raise);
+				
+				te.getConditionalBlocks().add(fcb);
+				
+				if (faultVar != null) {
+					context.removeVariable(faultVar);
+				}
+			}
+		}
+		
+		if (getOutputVariable() != null) {
+			
+			convertResponse(activities, context);
+		}
+	}
+	
+	protected void convertRequest(java.util.List<Activity> activities,
+			ConversionContext context) {
+		// Create interaction for request
+		ConversationInteraction interaction=new ConversationInteraction();
+		interaction.derivedFrom(this);
+		
+		Variable var=context.getVariable(getInputVariable());
+		
+		String xmlType=context.getProcess().getXMLType(var.getMessageType(),
+				context.getEnvironmentContext());
+
+		TypeReference tref=TypeReferenceUtil.createTypeReference(xmlType, context);
+				
+		MessageSignature ms=new MessageSignature();
+		ms.setOperation(getOperation());
+		ms.getTypes().add(tref);
+		
+		if (context.getRole() != null) {
+			interaction.setFromRole(new Role(context.getRole()));
+		}
+		
+		String toRole=getClientPartnerRole();
+		
+		if (toRole != null) {
+			interaction.setToRole(new Role(toRole));
+		}
+		
+		interaction.setMessageSignature(ms);
+		
+		activities.add(interaction);
+	}
+
+	protected void convertResponse(java.util.List<Activity> activities,
+			ConversionContext context) {
+		
+		// Create interaction for request
+		ConversationInteraction interaction=new ConversationInteraction();
+		interaction.derivedFrom(this);
+		
+		Variable var=context.getVariable(getOutputVariable());
+		
+		String xmlType=context.getProcess().getXMLType(var.getMessageType(),
+				context.getEnvironmentContext());
+
+		TypeReference tref=TypeReferenceUtil.createTypeReference(xmlType, context);
+		
+		MessageSignature ms=new MessageSignature();
+		ms.setOperation(getOperation());
+		ms.getTypes().add(tref);
+		
+		String fromRole=getClientPartnerRole();
+		
+		if (fromRole != null) {
+			interaction.setFromRole(new Role(fromRole));
+		}
+		
+		if (context.getRole() != null) {
+			interaction.setToRole(new Role(context.getRole()));
+		}
+		
+		interaction.setMessageSignature(ms);
+		
+		activities.add(interaction);
+	}
+	
+	protected void convertFaultResponse(java.util.List<Activity> activities,
+			String faultVar, String faultMesgType, ConversionContext context) {
+		
+		// Create interaction for request
+		ConversationInteraction interaction=new ConversationInteraction();
+		interaction.derivedFrom(this);
+		
+		TypeReference tref=null;
+		
+		// TODO: Not sure if fault variable is supposed to be declared
+		// in catch scope, or reused from outer scope?? If declared,
+		// then without the message type/element, may be difficult to
+		// define the message signature.
+		
+		Variable var=context.getVariable(faultVar);
+		
+		if (var != null) {
+			String xmlType=context.getProcess().getXMLType(var.getMessageType(),
+					context.getEnvironmentContext());
+
+			tref = TypeReferenceUtil.createTypeReference(xmlType, context);
+			//tref.setLocalpart(var.getMessageType());
+		} else if (faultMesgType != null) {
+			tref = TypeReferenceUtil.createTypeReference(faultMesgType, context);
+			//tref.setLocalpart(faultMesgType);
+		}
+		
+		MessageSignature ms=new MessageSignature();
+		ms.setOperation(getOperation());
+		ms.getTypes().add(tref);
+		
+		String fromRole=getClientPartnerRole();
+		
+		if (fromRole != null) {
+			interaction.setFromRole(new Role(fromRole));
+		}
+		
+		if (context.getRole() != null) {
+			interaction.setToRole(new Role(context.getRole()));
+		}
+		
+		interaction.setMessageSignature(ms);
+		
+		activities.add(interaction);
+	}
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Link.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Link.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Link.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import java.util.List;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.scribble.model.Activity;
+
+/**
+ * This class represents the BPEL link element, contained within
+ * the flow activity.
+ */
+public class Link extends BPELElement {
+
+	private static final long serialVersionUID = 6889776538490515074L;
+
+	private static final String NAME = "name";
+
+	public static final String LINK="link";
+	
+	/**
+	 * The constructor for the element.
+	 * 
+	 * @param model The BPEL model
+	 * @param elem The XML configuration details for the element
+	 */
+	public Link(BPELLanguageModel model,
+					org.w3c.dom.Element elem) {
+		super(model, elem);
+	}
+
+	/**
+	 * The constructor for the element.
+	 * 
+	 * @param model The BPEL model
+	 */
+	public Link(BPELLanguageModel model) {
+		super(model, LINK);
+	}
+
+	/**
+	 * This method returns the name associated
+	 * with the link.
+	 * 
+	 * @return The link name
+	 */
+	public String getName() {
+		return(getDOMElement().getAttribute(NAME));
+	}
+	
+	/**
+	 * This method sets the link name.
+	 * 
+	 * @param name The name
+	 */
+	public void setName(String name) {
+		getDOMElement().setAttribute(NAME, name);
+	}
+	
+	@Override
+	public void convert(List<Activity> activities, ConversionContext context) {
+		// TODO Auto-generated method stub
+		
+	}
+
+
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/OnAlarm.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/OnAlarm.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/OnAlarm.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,182 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import java.util.List;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.scribble.model.Activity;
+
+/**
+ * This class represents the 'onAlarm' construct contained
+ * within the 'pick' activity.
+ */
+public class OnAlarm extends BPELElement {
+
+	private static final long serialVersionUID = 271323368015539L;
+
+	public static final String ONALARM="onAlarm";
+	
+	/**
+	 * The constructor for the element.
+	 * 
+	 * @param model The BPEL model
+	 * @param activity The XML configuration details for the element
+	 */
+	public OnAlarm(BPELLanguageModel model,
+					org.w3c.dom.Element activity) {
+		super(model, activity);
+		
+		m_activity = findChildActivity();
+	}
+
+	/**
+	 * The constructor for the element.
+	 * 
+	 * @param model The BPEL model
+	 */
+	public OnAlarm(BPELLanguageModel model) {
+		super(model, ONALARM);
+	}
+
+	@Override
+	public void convert(List<Activity> activities, ConversionContext context) {
+		// TODO Auto-generated method stub
+		
+	}
+	
+	/**
+	 * This method sets the 'until' condition.
+	 * 
+	 * @param cond The 'until' condition
+	 */
+	public void setUntil(Until cond) {
+		org.w3c.dom.Element insertBefore=null;
+		
+		if (m_activity != null) {
+			insertBefore = m_activity.getDOMElement();
+		}
+		
+		setChildElement(findChildElement(Until.UNTIL),
+				cond, insertBefore);
+		
+		org.w3c.dom.Element elem=findChildElement(For.FOR);
+		if (elem != null) {
+			getDOMElement().removeChild(elem);
+		}
+	}
+	
+	/**
+	 * This method returns the 'until' condition.
+	 * 
+	 * @return The 'until' condition
+	 */
+	public Until getUntil() {
+		Until ret=null;
+		
+		org.w3c.dom.Element elem=findChildElement(Until.UNTIL);
+		if (elem != null) {
+			ret = new Until(getModel(), elem);
+		}
+		
+		return(ret);
+	}
+
+	/**
+	 * This method sets the 'for' condition.
+	 * 
+	 * @param cond The 'for' condition
+	 */
+	public void setFor(For cond) {	
+		org.w3c.dom.Element insertBefore=null;
+		
+		if (m_activity != null) {
+			insertBefore = m_activity.getDOMElement();
+		}
+		
+		setChildElement(findChildElement(For.FOR),
+				cond, insertBefore);
+		
+		org.w3c.dom.Element elem=findChildElement(Until.UNTIL);
+		if (elem != null) {
+			getDOMElement().removeChild(elem);
+		}
+	}
+	
+	/**
+	 * This method returns the 'for' condition.
+	 * 
+	 * @return The 'for' condition
+	 */
+	public For getFor() {
+		For ret=null;
+		
+		org.w3c.dom.Element elem=findChildElement(For.FOR);
+		if (elem != null) {
+			ret = new For(getModel(), elem);
+		}
+		
+		return(ret);
+	}
+
+	/**
+	 * This method sets the activity associated with
+	 * the 'else' construct.
+	 * 
+	 * @param act The activity
+	 */
+	public void setActivity(BPELElement act) {
+		m_activity = act;
+		
+		BPELElement existing=findChildActivity();
+		org.w3c.dom.Element existingElem=null;
+		
+		if (existing != null) {
+			existingElem = existing.getDOMElement();
+		}
+
+		org.w3c.dom.Element insertBefore=null;
+		
+		setChildElement(existingElem, act,
+						insertBefore);
+	}
+	
+	/**
+	 * This method returns the activity associated with
+	 * the 'else' construct.
+	 * 
+	 * @return The activity
+	 */
+	public BPELElement getActivity() {
+		return(m_activity);
+	}
+		
+	protected String getLocalURIPart(BPELElement elem) {
+		String ret="";
+		
+		if (elem instanceof Scope) {
+			ret = "@scope";
+		} else {
+			ret = "@activity";
+		}
+		
+		return(ret);
+	}
+	
+	private BPELElement m_activity;
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/OnEvent.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/OnEvent.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/OnEvent.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,191 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import java.util.List;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.scribble.model.Activity;
+
+/**
+ * This class represents the 'onEvent' construct contained
+ * within the 'EventHandler' element.
+ */
+public class OnEvent extends BPELElement {
+
+	private static final long serialVersionUID = -2444989267977027500L;
+
+	private static final String PARTNER_LINK = "partnerLink";
+	private static final String PORT_TYPE = "portType";
+	private static final String OPERATION = "operation";
+	private static final String VARIABLE = "variable";
+
+	public static final String ONEVENT="onEvent";
+	
+	/**
+	 * The constructor for the element.
+	 * 
+	 * @param model The BPEL model
+	 * @param activity The XML configuration details for the element
+	 */
+	public OnEvent(BPELLanguageModel model,
+					org.w3c.dom.Element activity) {
+		super(model, activity);
+		
+		BPELElement elem=findChildActivity();
+		
+		if (elem instanceof Scope) {
+			m_scope = (Scope)elem;
+		}
+	}
+
+	/**
+	 * The constructor for the element.
+	 * 
+	 * @param model The BPEL model
+	 */
+	public OnEvent(BPELLanguageModel model) {
+		super(model, ONEVENT);
+	}
+
+	/**
+	 * This method sets the operation.
+	 * 
+	 * @param op The operation
+	 */
+	public void setOperation(String op) {		
+		getDOMElement().setAttribute(OPERATION, op);
+	}
+	
+	/**
+	 * This method returns the operation.
+	 * 
+	 * @return The operation
+	 */
+	public String getOperation() {
+		return(getDOMElement().hasAttribute(OPERATION)?
+				getDOMElement().getAttribute(OPERATION):null);
+	}
+
+	/**
+	 * This method sets the partner link.
+	 * 
+	 * @param pl The partner link
+	 */
+	public void setPartnerLink(String pl) {		
+		getDOMElement().setAttribute(PARTNER_LINK, pl);
+	}
+	
+	/**
+	 * This method returns the partner link.
+	 * 
+	 * @return The partner link
+	 */
+	public String getPartnerLink() {
+		return(getDOMElement().hasAttribute(PARTNER_LINK)?
+				getDOMElement().getAttribute(PARTNER_LINK):null);
+	}
+
+	/**
+	 * This method sets the port type.
+	 * 
+	 * @param pt The port type
+	 */
+	public void setPortType(String pt) {		
+		getDOMElement().setAttribute(PORT_TYPE, pt);
+	}
+	
+	/**
+	 * This method returns the port type.
+	 * 
+	 * @return The port type
+	 */
+	public String getPortType() {
+		return(getDOMElement().hasAttribute(PORT_TYPE)?
+				getDOMElement().getAttribute(PORT_TYPE):null);
+	}
+
+	/**
+	 * This method sets the variable.
+	 * 
+	 * @param var The variable
+	 */
+	public void setVariable(String var) {		
+		getDOMElement().setAttribute(VARIABLE, var);
+	}
+	
+	/**
+	 * This method returns the variable.
+	 * 
+	 * @return The variable
+	 */
+	public String getVariable() {
+		return(getDOMElement().hasAttribute(VARIABLE)?
+				getDOMElement().getAttribute(VARIABLE):null);
+	}
+
+	/**
+	 * This method sets the scope associated with
+	 * the 'onEvent' construct.
+	 * 
+	 * @param scope The scope
+	 */
+	public void setScope(Scope scope) {
+		m_scope = scope;
+		
+		BPELElement existing=findChildActivity();
+		org.w3c.dom.Element existingElem=null;
+		
+		if (existing != null) {
+			existingElem = existing.getDOMElement();
+		}
+
+		org.w3c.dom.Element insertBefore=null;
+		
+		setChildElement(existingElem, scope,
+						insertBefore);
+	}
+	
+	/**
+	 * This method returns the scope associated with
+	 * the 'onEvent' construct.
+	 * 
+	 * @return The scope
+	 */
+	public Scope getScope() {
+		return(m_scope);
+	}
+	
+	@Override
+	public void convert(List<Activity> activities, ConversionContext context) {
+		// TODO Auto-generated method stub
+		
+	}
+	
+	protected String getLocalURIPart(BPELElement elem) {
+		String ret="";
+		
+		if (elem instanceof Scope) {
+			ret += "@scope";
+		}
+		
+		return(ret);
+	}
+	
+	private Scope m_scope;
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/OnMessage.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/OnMessage.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/OnMessage.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,237 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import java.util.List;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.savara.bpel.model.util.TypeReferenceUtil;
+import org.scribble.conversation.model.ConversationInteraction;
+import org.scribble.model.Activity;
+import org.scribble.model.MessageSignature;
+import org.scribble.model.Role;
+import org.scribble.model.TypeReference;
+
+/**
+ * This class represents the 'onMessage' construct contained
+ * within the 'pick' activity.
+ */
+public class OnMessage extends BPELElement {
+
+	private static final long serialVersionUID = -827946684365823245L;
+
+	private static final String PARTNER_LINK = "partnerLink";
+	private static final String PORT_TYPE = "portType";
+	private static final String OPERATION = "operation";
+	private static final String VARIABLE = "variable";
+
+	public static final String ONMESSAGE="onMessage";
+	
+	/**
+	 * The constructor for the element.
+	 * 
+	 * @param model The BPEL model
+	 * @param activity The XML configuration details for the element
+	 */
+	public OnMessage(BPELLanguageModel model,
+					org.w3c.dom.Element activity) {
+		super(model, activity);
+		
+		m_activity = findChildActivity();
+	}
+
+	/**
+	 * The constructor for the element.
+	 * 
+	 * @param model The BPEL model
+	 */
+	public OnMessage(BPELLanguageModel model) {
+		super(model, ONMESSAGE);
+	}
+
+	/**
+	 * This method sets the operation.
+	 * 
+	 * @param op The operation
+	 */
+	public void setOperation(String op) {		
+		getDOMElement().setAttribute(OPERATION, op);
+	}
+	
+	/**
+	 * This method returns the operation.
+	 * 
+	 * @return The operation
+	 */
+	public String getOperation() {
+		return(getDOMElement().hasAttribute(OPERATION)?
+				getDOMElement().getAttribute(OPERATION):null);
+	}
+
+	/**
+	 * This method sets the partner link.
+	 * 
+	 * @param pl The partner link
+	 */
+	public void setPartnerLink(String pl) {		
+		getDOMElement().setAttribute(PARTNER_LINK, pl);
+	}
+	
+	/**
+	 * This method returns the partner link.
+	 * 
+	 * @return The partner link
+	 */
+	public String getPartnerLink() {
+		return(getDOMElement().hasAttribute(PARTNER_LINK)?
+				getDOMElement().getAttribute(PARTNER_LINK):null);
+	}
+
+	/**
+	 * This method sets the port type.
+	 * 
+	 * @param pt The port type
+	 */
+	public void setPortType(String pt) {		
+		getDOMElement().setAttribute(PORT_TYPE, pt);
+	}
+	
+	/**
+	 * This method returns the port type.
+	 * 
+	 * @return The port type
+	 */
+	public String getPortType() {
+		return(getDOMElement().hasAttribute(PORT_TYPE)?
+				getDOMElement().getAttribute(PORT_TYPE):null);
+	}
+
+	/**
+	 * This method sets the variable.
+	 * 
+	 * @param var The variable
+	 */
+	public void setVariable(String var) {		
+		getDOMElement().setAttribute(VARIABLE, var);
+	}
+	
+	/**
+	 * This method returns the variable.
+	 * 
+	 * @return The variable
+	 */
+	public String getVariable() {
+		return(getDOMElement().hasAttribute(VARIABLE)?
+				getDOMElement().getAttribute(VARIABLE):null);
+	}
+
+	/**
+	 * This method sets the activity associated with
+	 * the 'else' construct.
+	 * 
+	 * @param act The activity
+	 */
+	public void setActivity(BPELElement act) {
+		m_activity = act;
+		
+		BPELElement existing=findChildActivity();
+		org.w3c.dom.Element existingElem=null;
+		
+		if (existing != null) {
+			existingElem = existing.getDOMElement();
+		}
+
+		org.w3c.dom.Element insertBefore=null;
+		
+		setChildElement(existingElem, act,
+						insertBefore);
+	}
+	
+	/**
+	 * This method returns the activity associated with
+	 * the 'else' construct.
+	 * 
+	 * @return The activity
+	 */
+	public BPELElement getActivity() {
+		return(m_activity);
+	}
+	
+	/**
+	 * This method attempts to identify the server's partner role name.
+	 * 
+	 * @return The partner role
+	 */
+	protected String getServerPartnerRole() {
+		String ret=getPartnerLink();
+		int index=-1;
+		
+		if (ret != null && (index=ret.indexOf("To")) != -1) {
+			ret = ret.substring(0, index);
+		}
+		
+		return(ret);
+	}
+
+	@Override
+	public void convert(List<Activity> activities, ConversionContext context) {
+		
+		ConversationInteraction interaction=new ConversationInteraction();
+		
+		Variable var=context.getVariable(getVariable());
+		
+		String xmlType=context.getProcess().getXMLType(var.getMessageType(),
+				context.getEnvironmentContext());
+
+		TypeReference tref=TypeReferenceUtil.createTypeReference(xmlType, context);
+		
+		MessageSignature ms=new MessageSignature();
+		ms.setOperation(getOperation());
+		ms.getTypes().add(tref);
+		
+		String fromRole=getServerPartnerRole();
+		
+		if (fromRole != null) {
+			interaction.setFromRole(new Role(fromRole));
+		}
+		
+		if (context.getRole() != null) {
+			interaction.setToRole(new Role(context.getRole()));
+		}
+		
+		interaction.setMessageSignature(ms);
+		
+		activities.add(interaction);
+
+		if (getActivity() != null) {
+			getActivity().convert(activities, context);
+		}
+	}
+	
+	protected String getLocalURIPart(BPELElement elem) {
+		String ret="";
+		
+		if (elem instanceof BPELActivity) {
+			ret = "@activity";
+		}
+		
+		return(ret);
+	}
+	
+	private BPELElement m_activity;
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/PartnerLink.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/PartnerLink.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/PartnerLink.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,140 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import java.util.List;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.scribble.model.Activity;
+
+/**
+ * This class represents the 'partnerLink' construct.
+ */
+public class PartnerLink extends BPELElement {
+
+	private static final long serialVersionUID = 8342639172267763736L;
+
+	private static final String NAME = "name";
+	private static final String PARTNER_LINK_TYPE = "partnerLinkType";
+	private static final String MY_ROLE = "myRole";
+	private static final String PARTNER_ROLE = "partnerRole";
+
+	public static final String PARTNERLINK="partnerLink";
+	
+	/**
+	 * The constructor for the element.
+	 * 
+	 * @param model The BPEL model
+	 * @param activity The XML configuration details for the element
+	 */
+	public PartnerLink(BPELLanguageModel model,
+					org.w3c.dom.Element activity) {
+		super(model, activity);
+	}
+
+	/**
+	 * The constructor for the element.
+	 * 
+	 * @param model The BPEL model
+	 */
+	public PartnerLink(BPELLanguageModel model) {
+		super(model, PARTNERLINK);
+	}
+
+	/**
+	 * This method sets the name.
+	 * 
+	 * @param name The name
+	 */
+	public void setName(String name) {		
+		getDOMElement().setAttribute(NAME, name);
+	}
+	
+	/**
+	 * This method returns the name.
+	 * 
+	 * @return The name
+	 */
+	public String getName() {
+		return(getDOMElement().hasAttribute(NAME)?
+				getDOMElement().getAttribute(NAME):null);
+	}
+
+	/**
+	 * This method sets the partner link type.
+	 * 
+	 * @param pl The partner link type
+	 */
+	public void setPartnerLinkType(String pl) {		
+		getDOMElement().setAttribute(PARTNER_LINK_TYPE, pl);
+	}
+	
+	/**
+	 * This method returns the partner link type.
+	 * 
+	 * @return The partner link type
+	 */
+	public String getPartnerLinkType() {
+		return(getDOMElement().hasAttribute(PARTNER_LINK_TYPE)?
+				getDOMElement().getAttribute(PARTNER_LINK_TYPE):null);
+	}
+
+	/**
+	 * This method sets my role.
+	 * 
+	 * @param role My role
+	 */
+	public void setMyRole(String role) {		
+		getDOMElement().setAttribute(MY_ROLE, role);
+	}
+	
+	/**
+	 * This method returns my role.
+	 * 
+	 * @return My role
+	 */
+	public String getMyRole() {
+		return(getDOMElement().hasAttribute(MY_ROLE)?
+				getDOMElement().getAttribute(MY_ROLE):null);
+	}
+
+	/**
+	 * This method sets partner role.
+	 * 
+	 * @param role Partner role
+	 */
+	public void setPartnerRole(String role) {		
+		getDOMElement().setAttribute(PARTNER_ROLE, role);
+	}
+	
+	/**
+	 * This method returns partner role.
+	 * 
+	 * @return Partner role
+	 */
+	public String getPartnerRole() {
+		return(getDOMElement().hasAttribute(PARTNER_ROLE)?
+				getDOMElement().getAttribute(PARTNER_ROLE):null);
+	}
+
+	@Override
+	public void convert(List<Activity> activities, ConversionContext context) {
+		// TODO Auto-generated method stub
+		
+	}
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Pick.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Pick.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Pick.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,284 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.*;
+import org.scribble.conversation.model.ConditionalBlock;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class represents a pick grouping activity.
+ *  
+ * @author gary
+ */
+public class Pick extends BPELActivity {
+
+	private static final long serialVersionUID = -2235972351406517577L;
+
+	public static final String PICK = "pick";
+	public static final String CREATE_INSTANCE = "createInstance";
+	
+	/**
+	 * The constructor for the activity.
+	 * 
+	 * @param model The BPEL model
+	 * @param activity The XML configuration details for the activity
+	 */
+	public Pick(BPELLanguageModel model,
+					org.w3c.dom.Element activity) {
+		super(model, activity);
+		
+		java.util.List<BPELElement> onmesgs=
+					findChildElements(OnMessage.class);
+		
+		for (int i=0; i < onmesgs.size(); i++) {
+			if (onmesgs.get(i) instanceof OnMessage) {
+				m_onMessages.add((OnMessage)onmesgs.get(i));
+			}
+		}
+		
+		java.util.List<BPELElement> onalrms=
+					findChildElements(OnAlarm.class);
+		
+		for (int i=0; i < onalrms.size(); i++) {
+			if (onalrms.get(i) instanceof OnAlarm) {
+				m_onAlarms.add((OnAlarm)onalrms.get(i));
+			}
+		}
+	}
+
+	/**
+	 * The constructor for the activity.
+	 * 
+	 * @param model The BPEL model
+	 */
+	public Pick(BPELLanguageModel model) {
+		super(model, PICK);
+	}
+
+	/**
+	 * This method sets the 'create instance'
+	 * attribute.
+	 * 
+	 * @param b Whether to create instance
+	 */
+	public void setCreateInstance(boolean b) {
+		String create=(b?"yes":"no");
+		
+		getDOMElement().setAttribute(CREATE_INSTANCE, create);
+	}
+	
+	/**
+	 * This method returns whether to create instance.
+	 * 
+	 * @return Whether to create instance
+	 */
+	public boolean getCreateInstance() {
+		boolean ret=false;
+		String create=
+			getDOMElement().getAttribute(CREATE_INSTANCE);
+
+		if (create != null &&
+				create.equals("yes")) {
+			ret = true;
+		}
+		
+		return(ret);
+	}
+
+	/**
+	 * This method adds an 'onMessage' to the grouping construct.
+	 * 
+	 * @param on The 'onMessage' to be added
+	 * @param pos The position to add, or -1 if at the end
+	 */
+	public void addOnMessage(OnMessage on, int pos) {
+		if (pos == -1 || pos >= m_onMessages.size()) {
+			m_onMessages.add(on);
+			
+			org.w3c.dom.Element insertBefore=null;
+			
+			if (m_onAlarms.size() > 0) {
+				insertBefore = m_onAlarms.get(0).getDOMElement();
+			}
+			
+			setChildElement(null, on, insertBefore);
+		} else {
+			
+			OnMessage cur=m_onMessages.get(pos);
+			
+			m_onMessages.add(pos, on);
+			
+			if (cur != null) {
+				setChildElement(null, on,
+							cur.getDOMElement());
+			} else {
+				org.w3c.dom.Element insertBefore=null;
+				
+				if (m_onAlarms.size() > 0) {
+					insertBefore = m_onAlarms.get(0).getDOMElement();
+				}
+				
+				setChildElement(null, on, insertBefore);
+			}
+		}
+	}
+	
+	/**
+	 * This method removes an 'onMessage' from the grouping
+	 * construct.
+	 * 
+	 * @param on The 'onMessage' to be removed
+	 * @return Whether the 'onMessage' was removed
+	 */
+	public boolean removeOnMessage(OnMessage on) {
+		boolean ret=m_onMessages.remove(on);
+		
+		if (ret) {
+			getDOMElement().removeChild(on.getDOMElement());
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the list of 'onMessage' associated
+	 * with the grouping construct.
+	 * 
+	 * @return The list of 'onMessage' elements
+	 */
+	public java.util.List<OnMessage> getOnMessages() {
+		return(m_onMessages);
+	}
+
+	/**
+	 * This method adds an 'onAlarm' to the grouping construct.
+	 * 
+	 * @param on The 'onAlarm' to be added
+	 * @param pos The position to add, or -1 if at the end
+	 */
+	public void addOnAlarm(OnAlarm on, int pos) {
+		if (pos == -1 || pos >= m_onAlarms.size()) {
+			m_onAlarms.add(on);
+			
+			setChildElement(null, on, null);
+		} else {
+			
+			OnAlarm cur=m_onAlarms.get(pos);
+			
+			m_onAlarms.add(pos, on);
+			
+			if (cur != null) {
+				setChildElement(null, on,
+							cur.getDOMElement());
+			} else {
+				setChildElement(null, on, null);
+			}
+		}
+	}
+	
+	/**
+	 * This method removes an 'onAlarm' from the grouping
+	 * construct.
+	 * 
+	 * @param on The 'onAlarm' to be removed
+	 * @return Whether the 'onAlarm' was removed
+	 */
+	public boolean removeOnAlarm(OnAlarm on) {
+		boolean ret=m_onAlarms.remove(on);
+		
+		if (ret) {
+			getDOMElement().removeChild(on.getDOMElement());
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the list of 'onAlarm' associated
+	 * with the grouping construct.
+	 * 
+	 * @return The list of 'onAlarm' elements
+	 */
+	public java.util.List<OnAlarm> getOnAlarms() {
+		return(m_onAlarms);
+	}
+
+	/**
+	 * This method validates the BPEL activity and reports warnings or
+	 * errors to the supplied model listener.
+	 * 
+	 * @param l The model listener
+	 */
+	@Override
+	public void validate(ModelListener l) {
+	}
+	
+	/**
+	 * This method does the actual work of converting the specific
+	 * BPEL activity into an equivalent behavioural description for 
+	 * conformance checking. The 'convert' method provides
+	 * a wrapper around this method, to handle the standard elements
+	 * that can be associated with any BPEL activity.
+	 * 
+	 * @param activities The list of activities that will contain
+	 * 				the converted action(s)
+	 * @param context The conversion context
+	 */
+	protected void convertActivity(java.util.List<Activity> activities,
+			ConversionContext context) {
+		getSource().setComponentURI(getURI());
+		
+		org.scribble.conversation.model.If elem=
+					new org.scribble.conversation.model.If();
+		
+		// Convert 'onMessage' paths
+		for (int i=0; i < getOnMessages().size(); i++) {
+			OnMessage onMessageElem=getOnMessages().get(i);
+			
+			ConditionalBlock cb = new ConditionalBlock();
+			
+			onMessageElem.convert(cb.getContents(), context);
+			
+			elem.getConditionalBlocks().add(cb);
+		}
+		
+		// TODO: If alarms defined, then model these using a
+		// try/catch with interrupt?
+		
+		activities.add(elem);
+	}
+
+	protected String getLocalURIPart(BPELElement elem) {
+		String ret="";
+		
+		if (elem instanceof OnMessage) {
+			ret += "@onMessage."+getOnMessages().indexOf(elem);
+		} else if (elem instanceof OnAlarm) {
+			ret += "@onAlarm."+getOnAlarms().indexOf(elem);
+		}
+		
+		return(ret);
+	}
+	
+	private java.util.List<OnMessage> m_onMessages=
+					new java.util.Vector<OnMessage>();
+	private java.util.List<OnAlarm> m_onAlarms=
+					new java.util.Vector<OnAlarm>();
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Process.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Process.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Process.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,977 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+
+import org.savara.bpel.model.*;
+import org.savara.bpel.model.util.InteractionUtil;
+import org.savara.util.XMLUtils;
+import org.scribble.conversation.model.ConditionalBlock;
+import org.scribble.conversation.model.Conversation;
+import org.scribble.conversation.model.ConversationNotation;
+import org.scribble.model.*;
+import org.scribble.model.admin.Context;
+import org.scribble.model.admin.ModelListener;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * This class represents a BPEL process.
+ *  
+ * @author gary
+ */
+public class Process extends BPELElement implements ScopeActivity {
+
+	private static final long serialVersionUID = 3400962966628415184L;
+
+	public static final String PROCESS = "process";
+	public static final String NAME = "name";
+	public static final String TARGET_NAMESPACE = "targetNamespace";
+	public static final String CONVERSATION_TYPE = "conversationType";
+	public static final String BPEL_PREFIX = "bpel";
+	
+	public static final String CONVERSATION_NS="http://www.scribble.org/conversation";
+
+	/**
+	 * The constructor for the activity.
+	 * 
+	 * @param model The BPEL model
+	 * @param activity The XML configuration details for the activity
+	 */
+	public Process(BPELLanguageModel model,
+					org.w3c.dom.Element activity) {
+		super(model, activity);
+		
+		java.util.List<BPELElement> imports=findChildElements(Import.class);
+		for (BPELElement elem : imports) {
+			m_imports.add((Import)elem);
+		}
+		
+		m_partnerLinksElem = findChildElement("partnerLinks");
+		
+		if (m_partnerLinksElem != null) {
+			java.util.List<BPELElement> elems=
+					findChildElements(m_partnerLinksElem,
+							PartnerLink.class);
+
+			for (int i=0; i < elems.size(); i++) {
+				m_partnerLinks.add((PartnerLink)elems.get(i));
+			}
+		}
+		
+		m_variablesElem = findChildElement("variables");
+
+		if (m_variablesElem != null) {
+			java.util.List<BPELElement> elems=
+					findChildElements(m_variablesElem,
+							Variable.class);
+
+			for (int i=0; i < elems.size(); i++) {
+				m_variables.add((Variable)elems.get(i));
+			}
+		}
+		
+		//m_messageExchangesElem = findChildElement("messageExchanges");
+		//m_correlationSetsElem = findChildElement("correlationSets");
+		
+		org.w3c.dom.Element ehs=findChildElement(EventHandlers.EVENTHANDLERS);
+		if (ehs != null) {
+			m_eventHandlers = new EventHandlers(model, ehs);
+		}
+		
+		org.w3c.dom.Element fhs=findChildElement(FaultHandlers.FAULTHANDLERS);
+		if (fhs != null) {
+			m_faultHandlers = new FaultHandlers(model, fhs);
+		}
+		
+		m_activity = findChildActivity();
+	}
+
+	/**
+	 * The constructor for the activity.
+	 * 
+	 * @param model The BPEL model
+	 */
+	public Process(BPELLanguageModel model) {
+		super(model, PROCESS);
+		
+		initNamespace(BPEL_NS, BPEL_PREFIX);
+	}
+
+	/**
+	 * This method adds an import to the scope.
+	 * 
+	 * @param imp The import to be added
+	 * @param pos The position to add, or -1 if at the end
+	 */
+	public void addImport(Import imp, int pos) {
+		
+		if (pos != -1 && pos < m_imports.size()) {
+			m_imports.add(pos, imp);
+		} else {
+			m_imports.add(imp);
+		}
+		
+		java.util.List<BPELElement> children=findChildElements(BPELElement.class);
+		
+		org.w3c.dom.Node newNode=imp.getDOMElement().cloneNode(true);
+		
+		getDOMElement().getOwnerDocument().adoptNode(newNode);
+		
+		if (pos != -1 && pos < children.size()) {
+			getDOMElement().insertBefore(newNode, children.get(pos).getDOMElement());
+		} else {
+			getDOMElement().appendChild(newNode);
+		}
+	}
+	
+	/**
+	 * This method removes a partner link from the grouping
+	 * construct.
+	 * 
+	 * @param pl The partner link to be removed
+	 * @return Whether the partner link was removed
+	 */
+	public boolean removeImport(Import imp) {
+		boolean ret=m_imports.remove(imp);
+		
+		if (ret) {
+			getDOMElement().removeChild(imp.getDOMElement());
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the list of imports.
+	 * 
+	 * @return The imports
+	 */
+	public java.util.List<Import> getImports() {
+		return(m_imports);
+	}
+	
+	/**
+	 * This method searches the defined WSDL definitions to identify
+	 * the underlying XML element/type associated with the supplied
+	 * WSDL message type.
+	 * 
+	 * @param wsdlMessageType The WSDL message type
+	 * @param context The context
+	 * @return The underlying XML element/type, or null if not found
+	 */
+	public String getXMLType(String wsdlMessageType, Context context) {
+		String ret=null;
+		
+		// Resolve the namespace prefix
+		int index=wsdlMessageType.indexOf(':');
+		
+		if (index != -1 && context != null) {
+			String prefix=wsdlMessageType.substring(0, index);
+			
+			String namespace=getNamespace(prefix);
+			
+			wsdlMessageType = wsdlMessageType.substring(index+1);
+		
+			for (Import imp : getImports()) {
+				
+				// Check if import relates to the correct namespace
+				if (imp.getNamespace() != null &&
+						imp.getNamespace().equals(namespace) &&
+						imp.getLocation() != null &&
+						imp.getLocation().endsWith(".wsdl")) {
+					
+					java.net.URI uri=
+							context.getResourceURI(getModel().getModelReference(),
+										imp.getLocation());
+
+					if (uri != null) {
+						ret = getXMLType(imp.getNamespace(), wsdlMessageType, uri);
+						
+						if (ret != null) {
+							break;
+						}
+					}
+				}
+			}
+		}
+		
+		return(ret);
+	}
+
+	protected String getXMLType(String namespace, String wsdlMessageType, java.net.URI uri) {
+		String ret=null;
+		
+		try {
+			WSDLReader reader=javax.wsdl.factory.WSDLFactory.newInstance().newWSDLReader();
+			
+			javax.wsdl.Definition defn=reader.readWSDL(uri.toString());
+			
+			if (defn != null) {
+				javax.wsdl.Message mesg=defn.getMessage(new QName(namespace, wsdlMessageType));
+				
+				if (mesg != null && mesg.getParts().size() == 1) {
+					javax.wsdl.Part part=(javax.wsdl.Part)
+								mesg.getParts().values().iterator().next();
+					
+					if (part.getElementName() != null) {
+						ret = part.getElementName().toString();
+					} else if (part.getTypeName() != null) {
+						ret = part.getTypeName().toString();
+					}
+				}
+			}
+			
+		} catch(Exception e) {
+			logger.error("Failed to read WSDL", e);
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the list of partner links.
+	 * 
+	 * @return The partner links
+	 */
+	public java.util.List<PartnerLink> getPartnerLinks() {
+		return(m_partnerLinks);
+	}
+	
+	/**
+	 * This method returns the partner link associated
+	 * with the supplied name.
+	 * 
+	 * @param name The name
+	 * @return The partner link, or null if not found
+	 */
+	public PartnerLink getPartnerLink(String name) {
+		PartnerLink ret=null;
+		
+		for (int i=0; ret == null && i < m_partnerLinks.size(); i++) {
+			if (m_partnerLinks.get(i).getName().equals(name)) {
+				ret = m_partnerLinks.get(i);
+			}
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method adds a partner link to the scope.
+	 * 
+	 * @param pl The partner link to be added
+	 * @param pos The position to add, or -1 if at the end
+	 */
+	public void addPartnerLink(PartnerLink pl, int pos) {
+		
+		if (m_partnerLinksElem == null) {
+			m_partnerLinksElem = getDOMElement().getOwnerDocument().
+				createElementNS(BPEL_NS, "partnerLinks");
+			
+			// Add to parent
+			org.w3c.dom.Element insertBefore=
+					findChildElement("messageExchanges");
+
+			if (insertBefore == null) {
+				insertBefore = findChildElement("variables");
+			}
+			
+			if (insertBefore == null) {
+				insertBefore = findChildElement("correlationSets");
+			}
+			
+			if (insertBefore == null) {
+				insertBefore = findChildElement("faultHandlers");
+			}
+			
+			if (insertBefore == null) {
+				insertBefore = findChildElement("eventHandlers");
+			}
+			
+			if (insertBefore == null) {
+				BPELElement elem=findChildActivity();
+				
+				if (elem != null) {
+					insertBefore = elem.getDOMElement();
+				}
+			}
+			
+			if (insertBefore != null) {
+				getDOMElement().insertBefore(m_partnerLinksElem, insertBefore);
+			} else {
+				getDOMElement().appendChild(m_partnerLinksElem);
+			}
+		}
+		
+		if (pos == -1 || pos >= m_partnerLinks.size()) {
+			m_partnerLinks.add(pl);
+			
+			setChildElement(m_partnerLinksElem, null, pl, null);
+		} else {
+			
+			PartnerLink cur=m_partnerLinks.get(pos);
+			
+			m_partnerLinks.add(pos, pl);
+			
+			if (cur != null) {
+				setChildElement(m_partnerLinksElem, null, pl,
+							cur.getDOMElement());
+			} else {
+				setChildElement(m_partnerLinksElem, null, pl, null);
+			}
+		}
+	}
+	
+	/**
+	 * This method removes a partner link from the grouping
+	 * construct.
+	 * 
+	 * @param pl The partner link to be removed
+	 * @return Whether the partner link was removed
+	 */
+	public boolean removePartnerLink(PartnerLink pl) {
+		boolean ret=m_partnerLinks.remove(pl);
+		
+		if (ret) {
+			m_partnerLinksElem.removeChild(pl.getDOMElement());
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method sets the name.
+	 * 
+	 * @param name The name
+	 */
+	public void setName(String name) {		
+		getDOMElement().setAttribute(NAME, name);
+	}
+	
+	/**
+	 * This method returns the name.
+	 * 
+	 * @return The name
+	 */
+	public String getName() {
+		return(getDOMElement().hasAttribute(NAME)?
+				getDOMElement().getAttribute(NAME):null);
+	}
+
+	/**
+	 * This method sets the target namespace.
+	 * 
+	 * @param tns The target namespace
+	 */
+	public void setTargetNamespace(String tns) {		
+		getDOMElement().setAttribute(TARGET_NAMESPACE, tns);
+	}
+	
+	/**
+	 * This method returns the target namespace.
+	 * 
+	 * @return The target namespace
+	 */
+	public String getTargetNamespace() {
+		return(getDOMElement().hasAttribute(TARGET_NAMESPACE)?
+				getDOMElement().getAttribute(TARGET_NAMESPACE):null);
+	}
+
+	/**
+	 * This method sets the conversation type.
+	 * 
+	 * @param ctype The conversation type
+	 */
+	public void setConversationType(String ctype) {		
+		getDOMElement().setAttributeNS(CONVERSATION_NS, CONVERSATION_TYPE, ctype);
+	}
+	
+	/**
+	 * This method returns the conversation type.
+	 * 
+	 * @return The conversation type
+	 */
+	public String getConversationType() {
+		return(getDOMElement().hasAttributeNS(CONVERSATION_NS, CONVERSATION_TYPE)?
+				getDOMElement().getAttributeNS(CONVERSATION_NS, CONVERSATION_TYPE):null);
+	}
+
+	/**
+	 * This method returns the prefix associated with the
+	 * supplied namespace.
+	 * 
+	 * @param namespace The namespace
+	 * @return The prefix, or null if not found
+	 */
+	public String getPrefix(String namespace) {
+		String ret=null;
+		
+		org.w3c.dom.NamedNodeMap map=getDOMElement().getAttributes();
+		
+		for (int i=0; ret == null && i < map.getLength(); i++) {
+			org.w3c.dom.Node node=map.item(i);
+			
+			if (node instanceof org.w3c.dom.Attr) {
+				org.w3c.dom.Attr attr=(org.w3c.dom.Attr)node;
+				
+				if (attr.getNodeValue().equals(namespace) &&
+						attr.getNodeName().startsWith("xmlns:")) {
+					ret = attr.getNodeName().substring(6);
+				}
+			}
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the namespace for the supplied prefix.
+	 * 
+	 * @param prefix The prefix
+	 * @return The namespace, or null if not found
+	 */
+	public String getNamespace(String prefix) {
+		String ret=null;
+		
+		org.w3c.dom.NamedNodeMap map=getDOMElement().getAttributes();
+		
+		for (int i=0; ret == null && i < map.getLength(); i++) {
+			org.w3c.dom.Node node=map.item(i);
+			
+			if (node instanceof org.w3c.dom.Attr) {
+				org.w3c.dom.Attr attr=(org.w3c.dom.Attr)node;
+				
+				if (attr.getNodeName().equals("xmlns:"+prefix) ||
+						attr.getNodeName().equals(prefix)) {
+					ret = attr.getNodeValue();
+				}
+			}
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method initialises the prefix associated with the supplied
+	 * namespace.
+	 * 
+	 * @param namespace
+	 * @param prefix
+	 */
+	public void initNamespace(String namespace, String prefix) {
+		getDOMElement().setAttribute("xmlns:"+prefix, namespace);
+	}
+	
+	/**
+	 * This method adds a new namespace and returns the
+	 * prefix allocated to it.
+	 * 
+	 * @param namespace The namespace to be added
+	 * @return The prefix
+	 */
+	public String addNamespace(String namespace) {
+		String ret=getPrefix(namespace);
+		int i=1;
+
+		while (ret == null) {
+			String prefix="ns"+(i++);
+			
+			if (getDOMElement().hasAttribute("xmlns:"+prefix) == false) {
+				ret = prefix;
+				
+				getDOMElement().setAttribute("xmlns:"+prefix, namespace);
+			}
+		}
+		
+		return(ret);
+	}
+		
+	/**
+	 * This method adds a variable to the scope.
+	 * 
+	 * @param var The variable to be added
+	 * @param pos The position to add, or -1 if at the end
+	 */
+	public void addVariable(Variable var, int pos) {
+		
+		if (m_variablesElem == null) {
+			m_variablesElem = getDOMElement().getOwnerDocument().
+				createElementNS(BPEL_NS, "variables");
+			
+			// Add to parent
+			org.w3c.dom.Element insertBefore=
+					findChildElement("correlationSets");
+
+			if (insertBefore == null) {
+				insertBefore = findChildElement("faultHandlers");
+			}
+			
+			if (insertBefore == null) {
+				insertBefore = findChildElement("eventHandlers");
+			}
+			
+			if (insertBefore == null) {
+				BPELElement elem=findChildActivity();
+				
+				if (elem != null) {
+					insertBefore = elem.getDOMElement();
+				}
+			}
+			
+			if (insertBefore != null) {
+				getDOMElement().insertBefore(m_variablesElem, insertBefore);
+			} else {
+				getDOMElement().appendChild(m_variablesElem);
+			}
+		}
+		
+		if (pos == -1 || pos >= m_variables.size()) {
+			m_variables.add(var);
+			
+			setChildElement(m_variablesElem, null, var, null);
+		} else {
+			
+			Variable cur=m_variables.get(pos);
+			
+			m_variables.add(pos, var);
+			
+			if (cur != null) {
+				setChildElement(m_variablesElem, null, var,
+							cur.getDOMElement());
+			} else {
+				setChildElement(m_variablesElem, null, var, null);
+			}
+		}
+	}
+	
+	/**
+	 * This method removes an activity from the grouping
+	 * construct.
+	 * 
+	 * @param act The activity to be removed
+	 * @return Whether the activity was removed
+	 */
+	public boolean removeVariable(Variable var) {
+		boolean ret=m_variables.remove(var);
+		
+		if (ret) {
+			m_variablesElem.removeChild(var.getDOMElement());
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the list of variables.
+	 * 
+	 * @return The 
+	 */
+	public java.util.List<Variable> getVariables() {
+		return(m_variables);
+	}
+	
+	/**
+	 * This method returns the variable associated
+	 * with the supplied name.
+	 * 
+	 * @param name The name
+	 * @return The variable, or null if not found
+	 */
+	public Variable getVariable(String name) {
+		Variable ret=null;
+		
+		for (int i=0; ret == null && i < m_variables.size(); i++) {
+			if (m_variables.get(i).getName().equals(name)) {
+				ret = m_variables.get(i);
+			}
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method sets the activity associated with
+	 * the 'else' construct.
+	 * 
+	 * @param act The activity
+	 */
+	public void setActivity(BPELActivity act) {
+		m_activity = act;
+		
+		BPELElement existing=findChildActivity();
+		org.w3c.dom.Element existingElem=null;
+		
+		if (existing != null) {
+			existingElem = existing.getDOMElement();
+		}
+
+		org.w3c.dom.Element insertBefore=null;
+		
+		setChildElement(existingElem, act,
+						insertBefore);
+	}
+	
+	/**
+	 * This method returns the activity associated with
+	 * the 'else' construct.
+	 * 
+	 * @return The activity
+	 */
+	public BPELActivity getActivity() {
+		return(m_activity);
+	}
+	
+	/**
+	 * This method sets the 'eventHandlers' path.
+	 * 
+	 * @param elem The 'eventHandlers' path
+	 */
+	public void setEventHandlers(EventHandlers elem) {
+		org.w3c.dom.Element existingElem=null;
+		
+		if (m_eventHandlers != null) {
+			existingElem = m_eventHandlers.getDOMElement();
+		}
+
+		m_eventHandlers = elem;
+		
+		org.w3c.dom.Element insertBefore=null;
+		
+		if (insertBefore == null) {
+			BPELElement act=findChildActivity();
+			
+			if (elem != null) {
+				insertBefore = act.getDOMElement();
+			}
+		}
+
+		setChildElement(existingElem, elem,
+						insertBefore);
+	}
+	
+	/**
+	 * This method returns the 'eventHandlers' path.
+	 * 
+	 * @return The 'eventHandlers' path
+	 */
+	public EventHandlers getEventHandlers() {
+		return(m_eventHandlers);
+	}
+	
+	/**
+	 * This method sets the 'faultHandlers' path.
+	 * 
+	 * @param elem The 'faultHandlers' path
+	 */
+	public void setFaultHandlers(FaultHandlers elem) {
+		org.w3c.dom.Element existingElem=null;
+		
+		if (m_faultHandlers != null) {
+			existingElem = m_faultHandlers.getDOMElement();
+		}
+
+		m_faultHandlers = elem;
+		
+		org.w3c.dom.Element insertBefore=null;
+		
+		if (insertBefore == null) {
+			insertBefore = findChildElement("eventHandlers");
+		}
+
+		if (insertBefore == null) {
+			BPELElement act=findChildActivity();
+			
+			if (elem != null) {
+				insertBefore = act.getDOMElement();
+			}
+		}
+
+		setChildElement(existingElem, elem,
+				insertBefore);
+	}
+	
+	/**
+	 * This method returns the 'faultHandlers' path.
+	 * 
+	 * @return The 'faultHandlers' path
+	 */
+	public FaultHandlers getFaultHandlers() {
+		return(m_faultHandlers);
+	}
+	
+	/**
+	 * This method validates the BPEL activity and reports warnings or
+	 * errors to the supplied model listener.
+	 * 
+	 * @param l The model listener
+	 */
+	@Override
+	public void validate(ModelListener l) {
+	}
+	
+	/**
+	 * This method does the actual work of converting the specific
+	 * BPEL activity into an equivalent behavioural description for 
+	 * conformance checking. The 'convert' method provides
+	 * a wrapper around this method, to handle the standard elements
+	 * that can be associated with any BPEL activity.
+	 * 
+	 * @param activities The list of activities that will contain
+	 * 				the converted action(s)
+	 * @param context The conversion context
+	 */
+	public void convert(java.util.List<Activity> activities,
+			ConversionContext context) {
+		
+		// Add variables to the context
+		for (int i=0; i < m_variables.size(); i++) {
+			context.addVariable(m_variables.get(i));
+		}
+		
+		// Count number of invoke activities
+		int invokeCount=InteractionUtil.countInvokes(getActivity().getDOMElement());
+		
+		// Check whether scope has been defined to represent
+		// an interaction with one or more fault responses and
+		// no event handlers
+		Invoke invoke=null;
+		
+		if (invokeCount == 1 &&
+				m_faultHandlers != null && (m_faultHandlers.getCatchPaths().size() > 0 ||
+				m_faultHandlers.getCatchAll() != null) &&
+				(m_eventHandlers == null || (m_eventHandlers.getOnEvents().size() == 0 &&
+						m_eventHandlers.getOnAlarms().size() == 0)) &&
+				(invoke = InteractionUtil.getInvoke(m_activity)) != null) {
+
+			invoke.convertRequest(activities, context);
+			
+			// Create choice with normal response and fault paths
+			org.scribble.conversation.model.If choice=new org.scribble.conversation.model.If();
+			
+			ConditionalBlock cb=new ConditionalBlock();
+			
+			invoke.convertResponse(cb.getContents(), context);
+			
+			// Include remaining activities
+			if (m_activity instanceof Sequence) {
+				for (int i=1; i < ((Sequence)m_activity).getActivities().size(); i++) {
+					((Sequence)m_activity).getActivities().get(i).convert(cb.getContents(), context);
+				}
+			}
+			
+			choice.getConditionalBlocks().add(cb);
+			
+			// Process fault handlers
+			for (int i=0; i < m_faultHandlers.getCatchPaths().size(); i++) {
+				Catch catchBlock=m_faultHandlers.getCatchPaths().get(i);
+				
+				ConditionalBlock fcb=new ConditionalBlock();
+				
+				String mesgType=catchBlock.getFaultMessageType();
+				
+				if (mesgType == null) {
+					mesgType = catchBlock.getFaultMessageElement();
+				}
+				
+				Variable faultVar=null;
+				
+				if (catchBlock.getFaultVariable() != null) {
+					faultVar = new Variable(getModel());
+					faultVar.setName(catchBlock.getFaultVariable());
+					faultVar.setMessageType(catchBlock.getFaultMessageType());
+					faultVar.setElement(catchBlock.getFaultMessageElement());			
+					context.addVariable(faultVar);
+				}
+				
+				invoke.convertFaultResponse(fcb.getContents(), catchBlock.getFaultVariable(),
+									mesgType, context);
+				
+				if (catchBlock.getActivity() != null) {
+					catchBlock.getActivity().convert(fcb.getContents(), context);
+				}
+				
+				choice.getConditionalBlocks().add(fcb);
+				
+				if (faultVar != null) {
+					context.removeVariable(faultVar);
+				}
+			}
+			
+			activities.add(choice);
+		} else {
+			// Store in local var, in case try/catch block needs to be
+			// added
+			java.util.List<Activity> acts=activities;
+			
+			// Check if try/catch block is required
+			if (getFaultHandlers() != null &&
+					(getFaultHandlers().getCatchPaths().size() > 0 ||
+							getFaultHandlers().getCatchAll() != null)) {
+				org.scribble.conversation.model.TryEscape te=
+						new org.scribble.conversation.model.TryEscape();
+				te.derivedFrom(this);
+				te.getBlock().derivedFrom(this);
+				
+				acts.add(te);
+				
+				acts = te.getBlock().getContents();
+		
+				for (int i=0; i < getFaultHandlers().getCatchPaths().size(); i++) {
+					Catch catchPath=getFaultHandlers().getCatchPaths().get(i);
+					
+					org.scribble.conversation.model.CatchBlock cb=
+						new org.scribble.conversation.model.CatchBlock();
+					cb.derivedFrom(catchPath);				
+					
+					TypeReference tref=new TypeReference();
+					tref.setLocalpart(XMLUtils.getLocalname(catchPath.getFaultName()));
+					cb.setType(tref);
+					
+					Variable faultVar=null;
+					
+					if (catchPath.getFaultVariable() != null) {
+						faultVar = new Variable(getModel());
+						faultVar.setName(catchPath.getFaultVariable());
+						faultVar.setMessageType(catchPath.getFaultMessageType());
+						faultVar.setElement(catchPath.getFaultMessageElement());			
+						context.addVariable(faultVar);
+					}
+					
+					if (catchPath.getActivity() != null) {
+						catchPath.getActivity().convert(cb.getContents(), context);
+					}
+					
+					if (faultVar != null) {
+						context.removeVariable(faultVar);
+					}
+
+					te.getEscapeBlocks().add(cb);
+				}
+			}
+			
+			// Convert normal activities in scope
+			if (getActivity() != null) {
+				getActivity().convert(acts, context);
+			}
+		}
+	}
+
+	/**
+	 * This method returns the conversion associated with the
+	 * BPEL process.
+	 * 
+	 * @param envContext The environment context
+	 * @return The conversation
+	 */
+	public Conversation convert(Context envContext) {
+		Conversation ret=new Conversation();
+		
+		ret.derivedFrom(this);
+		ret.getBlock().derivedFrom(this);
+		
+		// Configure model name
+		LocatedName modelName=new LocatedName();
+		modelName.setName(getName());
+		
+		ret.setLocatedName(modelName);
+		
+		// Define implements reference for conversation type
+		String convType=getConversationType();
+		String role=null;
+		
+		if (convType != null) {
+			int index=convType.indexOf('@');
+		
+			if (index != -1) {
+				// TODO: Need to think whether this should be
+				// 'implements' reference. If so, then need to change
+				// Java Lang Model parser and also Lang Model conformance
+				// rule.
+				ImplementsReference iref=
+					new ImplementsReference(ConversationNotation.NOTATION_CODE);
+			
+				role = convType.substring(index+1);
+				
+				iref.setLocatedRole(role);
+				
+				// Need to locate the model name
+				modelName.setRole(new Role(iref.getLocatedRole()));
+				
+				String mainpart=convType.substring(0, index);
+				
+				index = mainpart.lastIndexOf(".");
+				
+				if (index == -1) {
+					iref.setNamespace("");
+					iref.setLocalpart(mainpart);
+				} else {
+					iref.setNamespace(mainpart.substring(0, index));								
+					iref.setLocalpart(mainpart.substring(index+1));
+				}
+
+				ret.getImplements().add(iref);
+
+			} else {
+				logger.warn("Conversation type does not " +
+						"contain '@' located role separator");
+			}
+		}
+
+		// Convert the process contents
+		DefaultConversionContext context=new DefaultConversionContext(role, this, envContext);
+		
+		// Add variables to the context
+		for (int i=0; i < m_variables.size(); i++) {
+			context.addVariable(m_variables.get(i));
+		}
+		
+		convert(ret.getBlock().getContents(), context);
+		
+		return(ret);
+	}
+
+	protected String getParentURI(BPELElement elem) {
+		String ret="//";
+		
+		if (elem instanceof BPELActivity) {
+			ret += "@activity";
+		} else if (elem instanceof FaultHandlers) {
+			ret += "@faultHandlers";
+		} else if (elem instanceof EventHandlers) {
+			ret += "@eventHandlers";
+		}
+		
+		return(ret);
+	}
+	
+	private static Log logger = LogFactory.getLog(Process.class);
+
+	private org.w3c.dom.Element m_partnerLinksElem=null;
+	//private org.w3c.dom.Element m_messageExchangesElem=null;
+	private org.w3c.dom.Element m_variablesElem=null;
+	//private org.w3c.dom.Element m_correlationSetsElem=null;
+	private java.util.List<Import> m_imports=new java.util.Vector<Import>();
+	private java.util.List<PartnerLink> m_partnerLinks=new java.util.Vector<PartnerLink>();
+	private java.util.List<Variable> m_variables=new java.util.Vector<Variable>();
+	private EventHandlers m_eventHandlers=null;
+	private FaultHandlers m_faultHandlers=null;
+	private BPELActivity m_activity;
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Receive.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Receive.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Receive.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,171 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.*;
+import org.savara.bpel.model.util.TypeReferenceUtil;
+import org.scribble.conversation.model.ConversationInteraction;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class represents an unsupported (or custom) action within
+ * the conversation based ESB service descriptor.
+ *  
+ * @author gary
+ */
+public class Receive extends AbstractInteraction {
+
+	private static final String CREATE_INSTANCE = "createInstance";
+	private static final String VARIABLE = "variable";
+
+	public static final String RECEIVE = "receive";
+	
+	private static final long serialVersionUID = -3041725198724191842L;
+
+	/**
+	 * The constructor for the activity.
+	 * 
+	 * @param model The BPEL model
+	 * @param activity The XML configuration details for the activity
+	 */
+	public Receive(BPELLanguageModel  model,
+					org.w3c.dom.Element activity) {
+		super(model, activity);
+	}
+
+	/**
+	 * The constructor for the activity.
+	 * 
+	 * @param model The BPEL model
+	 */
+	public Receive(BPELLanguageModel model) {
+		super(model, RECEIVE);
+	}
+
+	/**
+	 * This method sets the variable.
+	 * 
+	 * @param var The variable
+	 */
+	public void setVariable(String var) {		
+		getDOMElement().setAttribute(VARIABLE, var);
+	}
+	
+	/**
+	 * This method returns the variable.
+	 * 
+	 * @return The variable
+	 */
+	public String getVariable() {
+		return(getDOMElement().hasAttribute(VARIABLE)?
+				getDOMElement().getAttribute(VARIABLE):null);
+	}
+
+	/**
+	 * This method sets the 'create instance'
+	 * attribute.
+	 * 
+	 * @param b Whether to create instance
+	 */
+	public void setCreateInstance(boolean b) {
+		String create=(b?"yes":"no");
+		
+		getDOMElement().setAttribute(CREATE_INSTANCE, create);
+	}
+	
+	/**
+	 * This method returns whether to create instance.
+	 * 
+	 * @return Whether to create instance
+	 */
+	public boolean getCreateInstance() {
+		boolean ret=false;
+		String create=
+			getDOMElement().getAttribute(CREATE_INSTANCE);
+
+		if (create != null &&
+				create.equals("yes")) {
+			ret = true;
+		}
+		
+		return(ret);
+	}
+
+	/**
+	 * This method validates the BPEL activity and reports warnings or
+	 * errors to the supplied model listener.
+	 * 
+	 * @param l The model listener
+	 */
+	@Override
+	public void validate(ModelListener l) {
+		// Don't validate unsupported actions
+	}
+	
+	/**
+	 * This method does the actual work of converting the specific
+	 * BPEL activity into an equivalent behavioural description for 
+	 * conformance checking. The 'convert' method provides
+	 * a wrapper around this method, to handle the standard elements
+	 * that can be associated with any BPEL activity.
+	 * 
+	 * @param activities The list of activities that will contain
+	 * 				the converted action(s)
+	 * @param context The conversion context
+	 */
+	protected void convertActivity(java.util.List<Activity> activities,
+									ConversionContext context) {
+		getSource().setComponentURI(getURI());
+		
+		ConversationInteraction interaction=new ConversationInteraction();
+		interaction.derivedFrom(this);
+		
+		Variable var=context.getVariable(getVariable());
+		
+		String xmlType=context.getProcess().getXMLType(var.getMessageType(),
+								context.getEnvironmentContext());
+		
+		TypeReference tref=TypeReferenceUtil.createTypeReference(xmlType, context);
+		
+		MessageSignature ms=new MessageSignature();
+		ms.derivedFrom(this);
+		
+		ms.setOperation(getOperation());
+		ms.getTypes().add(tref);
+		
+		String fromRole=getServerPartnerRole();
+		
+		if (fromRole != null && fromRole.equals(context.getRole())) {
+			fromRole = getClientPartnerRole();
+		}
+		
+		if (fromRole != null) {
+			interaction.setFromRole(new Role(fromRole));
+		}
+		
+		if (context.getRole() != null) {
+			interaction.setToRole(new Role(context.getRole()));
+		}
+		
+		interaction.setMessageSignature(ms);
+		
+		activities.add(interaction);
+	}
+
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/RepeatUntil.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/RepeatUntil.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/RepeatUntil.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,160 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class represents a RepeatUntil grouping activity.
+ *  
+ * @author gary
+ */
+public class RepeatUntil extends BPELGroupingConstruct {
+	
+	private static final long serialVersionUID = -4479515591509703188L;
+
+	public static final String REPEATUNTIL = "repeatUntil";
+
+	/**
+	 * The constructor for the activity.
+	 * 
+	 * @param model The BPEL model
+	 * @param activity The XML configuration details for the activity
+	 */
+	public RepeatUntil(BPELLanguageModel model,
+					org.w3c.dom.Element activity) {
+		super(model, activity);
+	
+		m_activity = findChildActivity();
+
+		org.w3c.dom.Element cond=
+			findChildElement(Condition.CONDITION);
+
+		if (cond == null) {
+			m_condition = new Condition(model);
+		} else {
+			m_condition = new Condition(model, cond);
+		}	
+	}
+
+	/**
+	 * The constructor for the activity.
+	 * 
+	 * @param model The BPEL model
+	 */
+	public RepeatUntil(BPELLanguageModel model) {
+		super(model, REPEATUNTIL);
+	}
+
+	/**
+	 * This method validates the BPEL activity and reports warnings or
+	 * errors to the supplied model listener.
+	 * 
+	 * @param l The model listener
+	 */
+	@Override
+	public void validate(ModelListener l) {
+	}
+	
+	/**
+	 * This method does the actual work of converting the specific
+	 * BPEL activity into an equivalent behavioural description for 
+	 * conformance checking. The 'convert' method provides
+	 * a wrapper around this method, to handle the standard elements
+	 * that can be associated with any BPEL activity.
+	 * 
+	 * @param activities The list of activities that will contain
+	 * 				the converted action(s)
+	 * @param context The conversion context
+	 */
+	protected void convertActivity(java.util.List<Activity> activities,
+			ConversionContext context) {
+		getSource().setComponentURI(getURI());
+	}
+
+	/**
+	 * This method sets the condition.
+	 * 
+	 * @param cond The condition
+	 */
+	public void setCondition(Condition cond) {
+		m_condition = cond;
+		
+		setChildElement(findChildElement(Condition.CONDITION),
+				cond, null);
+	}
+	
+	/**
+	 * This method returns the condition.
+	 * 
+	 * @return The condition
+	 */
+	public Condition getCondition() {
+		return(m_condition);
+	}
+
+	/**
+	 * This method sets the main 'if' activity.
+	 * 
+	 * @param act The activity associated with the 'if'
+	 */
+	public void setActivity(BPELElement act) {
+		m_activity = act;
+		
+		BPELElement existing=findChildActivity();
+		org.w3c.dom.Element existingElem=null;
+		
+		if (existing != null) {
+			existingElem = existing.getDOMElement();
+		}
+
+		org.w3c.dom.Element insertBefore=null;
+		
+		if (m_condition != null) {
+			insertBefore = m_condition.getDOMElement();
+		}
+		
+		setChildElement(existingElem, act,
+				insertBefore);
+	}
+
+	/**
+	 * This method returns the activity associated with
+	 * the 'if' path.
+	 * 
+	 * @return The 'if' activity
+	 */
+	public BPELElement getActivity() {
+		return(m_activity);
+	}
+	
+	protected String getLocalURIPart(BPELElement elem) {
+		String ret="";
+		
+		if (elem instanceof BPELActivity) {
+			ret = "@activity";
+		}
+		
+		return(ret);
+	}
+	
+	private Condition m_condition=null;
+	private BPELElement m_activity=null;
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Reply.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Reply.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Reply.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,155 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.*;
+import org.savara.bpel.model.util.TypeReferenceUtil;
+import org.scribble.conversation.model.ConversationInteraction;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class represents a BPEL reply activity.
+ *  
+ * @author gary
+ */
+public class Reply extends AbstractInteraction {
+
+	private static final String VARIABLE = "variable";
+	private static final String FAULT_NAME = "faultName";
+
+	public static final String REPLY = "reply";
+	
+	private static final long serialVersionUID = 8582738107125170604L;
+
+	/**
+	 * The constructor for the activity.
+	 * 
+	 * @param model The BPEL model
+	 * @param activity The XML configuration details for the activity
+	 */
+	public Reply(BPELLanguageModel  model,
+					org.w3c.dom.Element activity) {
+		super(model, activity);
+	}
+
+	/**
+	 * The constructor for the activity.
+	 * 
+	 * @param model The BPEL model
+	 */
+	public Reply(BPELLanguageModel model) {
+		super(model, REPLY);
+	}
+
+	/**
+	 * This method sets the variable.
+	 * 
+	 * @param var The variable
+	 */
+	public void setVariable(String var) {		
+		getDOMElement().setAttribute(VARIABLE, var);
+	}
+	
+	/**
+	 * This method returns the variable.
+	 * 
+	 * @return The variable
+	 */
+	public String getVariable() {
+		return(getDOMElement().hasAttribute(VARIABLE)?
+				getDOMElement().getAttribute(VARIABLE):null);
+	}
+
+	/**
+	 * This method sets the fault name.
+	 * 
+	 * @param fname The fault name
+	 */
+	public void setFaultName(String fname) {		
+		getDOMElement().setAttribute(FAULT_NAME, fname);
+	}
+	
+	/**
+	 * This method returns the fault name.
+	 * 
+	 * @return The fault name
+	 */
+	public String getFaultName() {
+		return(getDOMElement().hasAttribute(FAULT_NAME)?
+				getDOMElement().getAttribute(FAULT_NAME):null);
+	}
+
+	/**
+	 * This method validates the BPEL activity and reports warnings or
+	 * errors to the supplied model listener.
+	 * 
+	 * @param l The model listener
+	 */
+	@Override
+	public void validate(ModelListener l) {
+		// Don't validate unsupported actions
+	}
+	
+	/**
+	 * This method does the actual work of converting the specific
+	 * BPEL activity into an equivalent behavioural description for 
+	 * conformance checking. The 'convert' method provides
+	 * a wrapper around this method, to handle the standard elements
+	 * that can be associated with any BPEL activity.
+	 * 
+	 * @param activities The list of activities that will contain
+	 * 				the converted action(s)
+	 * @param context The conversion context
+	 */
+	protected void convertActivity(java.util.List<Activity> activities,
+			ConversionContext context) {
+		getSource().setComponentURI(getURI());
+
+		ConversationInteraction interaction=new ConversationInteraction();
+		interaction.derivedFrom(this);
+		
+		Variable var=context.getVariable(getVariable());
+		
+		String xmlType=context.getProcess().getXMLType(var.getMessageType(),
+				context.getEnvironmentContext());
+
+		TypeReference tref=TypeReferenceUtil.createTypeReference(xmlType, context);
+		
+		MessageSignature ms=new MessageSignature();
+		ms.derivedFrom(this);
+
+		ms.setOperation(getOperation());
+		ms.getTypes().add(tref);
+		
+		if (context.getRole() != null) {
+			interaction.setFromRole(new Role(context.getRole()));
+		}
+		
+		String toRole=getServerPartnerRole();
+		
+		if (toRole != null) {
+			interaction.setToRole(new Role(toRole));
+		}
+		
+		interaction.setMessageSignature(ms);
+		
+		activities.add(interaction);
+	}
+
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Rethrow.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Rethrow.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Rethrow.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class represents the rethrow activity.
+ *  
+ * @author gary
+ */
+public class Rethrow extends BPELActivity {
+
+	private static final long serialVersionUID = 9187657888490480490L;
+
+	public static final String RETHROW = "rethrow";
+	
+	/**
+	 * The constructor for the activity.
+	 * 
+	 * @param model The BPEL model
+	 * @param activity The XML configuration details for the activity
+	 */
+	public Rethrow(BPELLanguageModel  model,
+					org.w3c.dom.Element activity) {
+		super(model, activity);
+	}
+
+	/**
+	 * The constructor for the activity.
+	 * 
+	 * @param model The BPEL model
+	 */
+	public Rethrow(BPELLanguageModel model) {
+		super(model, RETHROW);
+	}
+
+	/**
+	 * This method validates the BPEL activity and reports warnings or
+	 * errors to the supplied model listener.
+	 * 
+	 * @param l The model listener
+	 */
+	@Override
+	public void validate(ModelListener l) {
+		// Don't validate unsupported actions
+	}
+	
+	/**
+	 * This method does the actual work of converting the specific
+	 * BPEL activity into an equivalent behavioural description for 
+	 * conformance checking. The 'convert' method provides
+	 * a wrapper around this method, to handle the standard elements
+	 * that can be associated with any BPEL activity.
+	 * 
+	 * @param activities The list of activities that will contain
+	 * 				the converted action(s)
+	 * @param context The conversion context
+	 */
+	protected void convertActivity(java.util.List<Activity> activities,
+			ConversionContext context) {
+		getSource().setComponentURI(getURI());
+	}
+
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Scope.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Scope.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Scope.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,690 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.*;
+import org.savara.bpel.model.util.InteractionUtil;
+import org.savara.util.XMLUtils;
+import org.scribble.conversation.model.ConditionalBlock;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class represents a scope grouping activity.
+ *  
+ * @author gary
+ */
+public class Scope extends BPELActivity implements ScopeActivity {
+
+	private static final long serialVersionUID = 7132062003047468101L;
+
+	public static final String SCOPE = "scope";
+
+	/**
+	 * The constructor for the activity.
+	 * 
+	 * @param model The BPEL model
+	 * @param activity The XML configuration details for the activity
+	 */
+	public Scope(BPELLanguageModel model,
+					org.w3c.dom.Element activity) {
+		super(model, activity);
+		
+		m_partnerLinksElem = findChildElement("partnerLinks");
+		
+		if (m_partnerLinksElem != null) {
+			java.util.List<BPELElement> elems=
+					findChildElements(m_partnerLinksElem,
+							PartnerLink.class);
+
+			for (int i=0; i < elems.size(); i++) {
+				m_partnerLinks.add((PartnerLink)elems.get(i));
+			}
+		}
+		
+		m_variablesElem = findChildElement("variables");
+
+		if (m_variablesElem != null) {
+			java.util.List<BPELElement> elems=
+					findChildElements(m_variablesElem,
+							Variable.class);
+
+			for (int i=0; i < elems.size(); i++) {
+				m_variables.add((Variable)elems.get(i));
+			}
+		}
+		
+		m_messageExchangesElem = findChildElement("messageExchanges");
+		m_correlationSetsElem = findChildElement("correlationSets");
+		
+		org.w3c.dom.Element ehs=findChildElement(EventHandlers.EVENTHANDLERS);
+		if (ehs != null) {
+			m_eventHandlers = new EventHandlers(model, ehs);
+		}
+		
+		org.w3c.dom.Element fhs=findChildElement(FaultHandlers.FAULTHANDLERS);
+		if (fhs != null) {
+			m_faultHandlers = new FaultHandlers(model, fhs);
+		}
+		
+		org.w3c.dom.Element ch=findChildElement(CompensationHandler.COMPENSATIONHANDLER);
+		if (ch != null) {
+			m_compensationHandler = new CompensationHandler(model, ch);
+		}
+		
+		org.w3c.dom.Element th=findChildElement(TerminationHandler.TERMINATIONHANDLER);
+		if (th != null) {
+			m_terminationHandler = new TerminationHandler(model, th);
+		}
+		
+		m_activity = findChildActivity();
+	}
+
+	/**
+	 * The constructor for the activity.
+	 * 
+	 * @param model The BPEL model
+	 */
+	public Scope(BPELLanguageModel model) {
+		super(model, SCOPE);
+	}
+
+	/**
+	 * This method adds a variable to the scope.
+	 * 
+	 * @param var The variable to be added
+	 * @param pos The position to add, or -1 if at the end
+	 */
+	public void addVariable(Variable var, int pos) {
+		
+		if (m_variablesElem == null) {
+			m_variablesElem = getDOMElement().getOwnerDocument().
+				createElementNS(BPEL_NS, "variables");
+			
+			// Add to parent
+			org.w3c.dom.Element insertBefore=
+					findChildElement("partnerLinks");
+			
+			if (insertBefore == null) {
+				insertBefore = findChildElement("messageExchanges");
+			}
+			
+			if (insertBefore == null) {
+				insertBefore = findChildElement("correlationSets");
+			}
+			
+			if (insertBefore == null) {
+				insertBefore = findChildElement("eventHandlers");
+			}
+			
+			if (insertBefore == null) {
+				insertBefore = findChildElement("faultHandlers");
+			}
+			
+			if (insertBefore == null) {
+				insertBefore = findChildElement("compensationHandler");
+			}
+			
+			if (insertBefore == null) {
+				insertBefore = findChildElement("terminationHandler");
+			}
+			
+			if (insertBefore == null) {
+				BPELElement elem=findChildActivity();
+				
+				if (elem != null) {
+					insertBefore = elem.getDOMElement();
+				}
+			}
+			
+			if (insertBefore != null) {
+				getDOMElement().insertBefore(m_variablesElem, insertBefore);
+			} else {
+				getDOMElement().appendChild(m_variablesElem);
+			}
+		}
+		
+		if (pos == -1 || pos >= m_variables.size()) {
+			m_variables.add(var);
+			
+			setChildElement(m_variablesElem, null, var, null);
+		} else {
+			
+			Variable cur=m_variables.get(pos);
+			
+			m_variables.add(pos, var);
+			
+			if (cur != null) {
+				setChildElement(m_variablesElem, null, var,
+							cur.getDOMElement());
+			} else {
+				setChildElement(m_variablesElem, null, var, null);
+			}
+		}
+	}
+	
+	/**
+	 * This method removes an activity from the grouping
+	 * construct.
+	 * 
+	 * @param act The activity to be removed
+	 * @return Whether the activity was removed
+	 */
+	public boolean removeVariable(Variable var) {
+		boolean ret=m_variables.remove(var);
+		
+		if (ret) {
+			m_variablesElem.removeChild(var.getDOMElement());
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the list of variables.
+	 * 
+	 * @return The 
+	 */
+	public java.util.List<Variable> getVariables() {
+		return(m_variables);
+	}
+	
+	/**
+	 * This method adds a partner link to the scope.
+	 * 
+	 * @param pl The partner link to be added
+	 * @param pos The position to add, or -1 if at the end
+	 */
+	public void addPartnerLink(PartnerLink pl, int pos) {
+		
+		if (m_partnerLinksElem == null) {
+			m_partnerLinksElem = getDOMElement().getOwnerDocument().
+				createElementNS(BPEL_NS, "partnerLinks");
+			
+			// Add to parent
+			org.w3c.dom.Element insertBefore=
+					findChildElement("messageExchanges");
+
+			if (insertBefore == null) {
+				insertBefore = findChildElement("correlationSets");
+			}
+			
+			if (insertBefore == null) {
+				insertBefore = findChildElement("eventHandlers");
+			}
+			
+			if (insertBefore == null) {
+				insertBefore = findChildElement("faultHandlers");
+			}
+			
+			if (insertBefore == null) {
+				insertBefore = findChildElement("compensationHandler");
+			}
+			
+			if (insertBefore == null) {
+				insertBefore = findChildElement("terminationHandler");
+			}
+			
+			if (insertBefore == null) {
+				BPELElement elem=findChildActivity();
+				
+				if (elem != null) {
+					insertBefore = elem.getDOMElement();
+				}
+			}
+			
+			if (insertBefore != null) {
+				getDOMElement().insertBefore(m_partnerLinksElem, insertBefore);
+			} else {
+				getDOMElement().appendChild(m_partnerLinksElem);
+			}
+		}
+		
+		if (pos == -1 || pos >= m_partnerLinks.size()) {
+			m_partnerLinks.add(pl);
+			
+			setChildElement(m_partnerLinksElem, null, pl, null);
+		} else {
+			
+			PartnerLink cur=m_partnerLinks.get(pos);
+			
+			m_partnerLinks.add(pos, pl);
+			
+			if (cur != null) {
+				setChildElement(m_partnerLinksElem, null, pl,
+							cur.getDOMElement());
+			} else {
+				setChildElement(m_partnerLinksElem, null, pl, null);
+			}
+		}
+	}
+	
+	/**
+	 * This method removes a partner link from the grouping
+	 * construct.
+	 * 
+	 * @param pl The partner link to be removed
+	 * @return Whether the partner link was removed
+	 */
+	public boolean removePartnerLink(PartnerLink pl) {
+		boolean ret=m_partnerLinks.remove(pl);
+		
+		if (ret) {
+			m_partnerLinksElem.removeChild(pl.getDOMElement());
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the list of partner links.
+	 * 
+	 * @return The partner links
+	 */
+	public java.util.List<PartnerLink> getPartnerLinks() {
+		return(m_partnerLinks);
+	}
+	
+	/**
+	 * This method sets the activity associated with
+	 * the 'else' construct.
+	 * 
+	 * @param act The activity
+	 */
+	public void setActivity(BPELActivity act) {
+		m_activity = act;
+		
+		BPELElement existing=findChildActivity();
+		org.w3c.dom.Element existingElem=null;
+		
+		if (existing != null) {
+			existingElem = existing.getDOMElement();
+		}
+
+		org.w3c.dom.Element insertBefore=null;
+		
+		setChildElement(existingElem, act,
+						insertBefore);
+	}
+	
+	/**
+	 * This method returns the activity associated with
+	 * the 'else' construct.
+	 * 
+	 * @return The activity
+	 */
+	public BPELActivity getActivity() {
+		return(m_activity);
+	}
+	
+	/**
+	 * This method sets the 'eventHandlers' path.
+	 * 
+	 * @param elem The 'eventHandlers' path
+	 */
+	public void setEventHandlers(EventHandlers elem) {
+		org.w3c.dom.Element existingElem=null;
+		
+		if (m_eventHandlers != null) {
+			existingElem = m_eventHandlers.getDOMElement();
+		}
+
+		m_eventHandlers = elem;
+		
+		org.w3c.dom.Element insertBefore=null;
+		
+		if (insertBefore == null) {
+			insertBefore = findChildElement("faultHandlers");
+		}
+
+		if (insertBefore == null) {
+			insertBefore = findChildElement("compensationHandler");
+		}
+
+		if (insertBefore == null) {
+			insertBefore = findChildElement("terminationHandler");
+		}
+		
+		if (insertBefore == null) {
+			BPELElement act=findChildActivity();
+			
+			if (elem != null) {
+				insertBefore = act.getDOMElement();
+			}
+		}
+
+		setChildElement(existingElem, elem,
+						insertBefore);
+	}
+	
+	/**
+	 * This method returns the 'eventHandlers' path.
+	 * 
+	 * @return The 'eventHandlers' path
+	 */
+	public EventHandlers getEventHandlers() {
+		return(m_eventHandlers);
+	}
+	
+	/**
+	 * This method sets the 'faultHandlers' path.
+	 * 
+	 * @param elem The 'faultHandlers' path
+	 */
+	public void setFaultHandlers(FaultHandlers elem) {
+		org.w3c.dom.Element existingElem=null;
+		
+		if (m_faultHandlers != null) {
+			existingElem = m_faultHandlers.getDOMElement();
+		}
+
+		m_faultHandlers = elem;
+		
+		org.w3c.dom.Element insertBefore=null;
+		
+		if (insertBefore == null) {
+			insertBefore = findChildElement("compensationHandler");
+		}
+
+		if (insertBefore == null) {
+			insertBefore = findChildElement("terminationHandler");
+		}
+		
+		if (insertBefore == null) {
+			BPELElement act=findChildActivity();
+			
+			if (elem != null) {
+				insertBefore = act.getDOMElement();
+			}
+		}
+
+		setChildElement(existingElem, elem,
+				insertBefore);
+	}
+	
+	/**
+	 * This method returns the 'faultHandlers' path.
+	 * 
+	 * @return The 'faultHandlers' path
+	 */
+	public FaultHandlers getFaultHandlers() {
+		return(m_faultHandlers);
+	}
+	
+	/**
+	 * This method sets the 'compensationHandler' path.
+	 * 
+	 * @param elem The 'compensationHandler' path
+	 */
+	public void setCompensationHandler(CompensationHandler elem) {
+		org.w3c.dom.Element existingElem=null;
+		
+		if (m_compensationHandler != null) {
+			existingElem = m_compensationHandler.getDOMElement();
+		}
+
+		m_compensationHandler = elem;
+		
+		org.w3c.dom.Element insertBefore=null;
+		
+		if (insertBefore == null) {
+			insertBefore = findChildElement("terminationHandler");
+		}
+		
+		if (insertBefore == null) {
+			BPELElement act=findChildActivity();
+			
+			if (elem != null) {
+				insertBefore = act.getDOMElement();
+			}
+		}
+
+		setChildElement(existingElem, elem,
+				insertBefore);
+	}
+	
+	/**
+	 * This method returns the 'compensationHandler' path.
+	 * 
+	 * @return The 'compensationHandler' path
+	 */
+	public CompensationHandler getCompensationHandler() {
+		return(m_compensationHandler);
+	}
+	
+	/**
+	 * This method sets the 'terminationHandler' path.
+	 * 
+	 * @param elem The 'terminationHandler' path
+	 */
+	public void setTerminationHandler(TerminationHandler elem) {
+		org.w3c.dom.Element existingElem=null;
+		
+		if (m_terminationHandler != null) {
+			existingElem = m_terminationHandler.getDOMElement();
+		}
+
+		m_terminationHandler = elem;
+		
+		org.w3c.dom.Element insertBefore=null;
+		
+		if (insertBefore == null) {
+			BPELElement act=findChildActivity();
+			
+			if (elem != null) {
+				insertBefore = act.getDOMElement();
+			}
+		}
+
+		setChildElement(existingElem, elem,
+				insertBefore);
+	}
+	
+	/**
+	 * This method returns the 'terminationHandler' path.
+	 * 
+	 * @return The 'terminationHandler' path
+	 */
+	public TerminationHandler getTerminationHandler() {
+		return(m_terminationHandler);
+	}
+	
+	/**
+	 * This method validates the BPEL activity and reports warnings or
+	 * errors to the supplied model listener.
+	 * 
+	 * @param l The model listener
+	 */
+	@Override
+	public void validate(ModelListener l) {
+	}
+	
+	/**
+	 * This method does the actual work of converting the specific
+	 * BPEL activity into an equivalent behavioural description for 
+	 * conformance checking. The 'convert' method provides
+	 * a wrapper around this method, to handle the standard elements
+	 * that can be associated with any BPEL activity.
+	 * 
+	 * @param activities The list of activities that will contain
+	 * 				the converted action(s)
+	 * @param context The conversion context
+	 */
+	protected void convertActivity(java.util.List<Activity> activities,
+			ConversionContext context) {
+		getSource().setComponentURI(getURI());
+		
+		// Add variables to the context
+		for (int i=0; i < m_variables.size(); i++) {
+			context.addVariable(m_variables.get(i));
+		}
+		
+		// Count number of invoke activities
+		int invokeCount=InteractionUtil.countInvokes(getActivity().getDOMElement());
+		
+		// Check whether scope has been defined to represent
+		// an interaction with one or more fault responses and
+		// no event handlers
+		Invoke invoke=null;
+		
+		if (invokeCount == 1 &&
+				m_faultHandlers != null && (m_faultHandlers.getCatchPaths().size() > 0 ||
+				m_faultHandlers.getCatchAll() != null) &&
+				(m_eventHandlers == null || (m_eventHandlers.getOnEvents().size() == 0 &&
+						m_eventHandlers.getOnAlarms().size() == 0)) &&
+				(invoke = InteractionUtil.getInvoke(m_activity)) != null) {
+
+			invoke.convertRequest(activities, context);
+			
+			// Create choice with normal response and fault paths
+			org.scribble.conversation.model.If choice=new org.scribble.conversation.model.If();
+			
+			ConditionalBlock cb=new ConditionalBlock();
+			
+			invoke.convertResponse(cb.getContents(), context);
+			
+			// Include remaining activities
+			if (m_activity instanceof Sequence) {
+				for (int i=1; i < ((Sequence)m_activity).getActivities().size(); i++) {
+					((Sequence)m_activity).getActivities().get(i).convert(cb.getContents(), context);
+				}
+			}
+			
+			choice.getConditionalBlocks().add(cb);
+			
+			// Process fault handlers
+			for (int i=0; i < m_faultHandlers.getCatchPaths().size(); i++) {
+				Catch catchBlock=m_faultHandlers.getCatchPaths().get(i);
+				
+				ConditionalBlock fcb=new ConditionalBlock();
+				
+				String mesgType=catchBlock.getFaultMessageType();
+				
+				if (mesgType == null) {
+					mesgType = catchBlock.getFaultMessageElement();
+				}
+				
+				Variable faultVar=null;
+				
+				if (catchBlock.getFaultVariable() != null) {
+					faultVar = new Variable(getModel());
+					faultVar.setName(catchBlock.getFaultVariable());
+					faultVar.setMessageType(catchBlock.getFaultMessageType());
+					faultVar.setElement(catchBlock.getFaultMessageElement());			
+					context.addVariable(faultVar);
+				}
+				
+				invoke.convertFaultResponse(fcb.getContents(), catchBlock.getFaultVariable(),
+									mesgType, context);
+				
+				if (catchBlock.getActivity() != null) {
+					catchBlock.getActivity().convert(fcb.getContents(), context);
+				}
+				
+				choice.getConditionalBlocks().add(fcb);
+				
+				if (faultVar != null) {
+					context.removeVariable(faultVar);
+				}
+			}
+			
+			activities.add(choice);
+		} else {
+			// Store in local var, in case try/catch block needs to be
+			// added
+			java.util.List<Activity> acts=activities;
+			
+			// Check if try/catch block is required
+			if (getFaultHandlers() != null &&
+					(getFaultHandlers().getCatchPaths().size() > 0 ||
+							getFaultHandlers().getCatchAll() != null)) {
+				org.scribble.conversation.model.TryEscape te=
+						new org.scribble.conversation.model.TryEscape();
+				te.derivedFrom(this);
+				te.getBlock().derivedFrom(this);
+				
+				acts.add(te);
+				
+				acts = te.getBlock().getContents();
+		
+				for (int i=0; i < getFaultHandlers().getCatchPaths().size(); i++) {
+					Catch catchPath=getFaultHandlers().getCatchPaths().get(i);
+					
+					org.scribble.conversation.model.CatchBlock cb=
+						new org.scribble.conversation.model.CatchBlock();
+					cb.derivedFrom(catchPath);
+					
+					TypeReference tref=new TypeReference();
+					tref.setLocalpart(XMLUtils.getLocalname(catchPath.getFaultName()));
+					cb.setType(tref);
+					
+					Variable faultVar=null;
+					
+					if (catchPath.getFaultVariable() != null) {
+						faultVar = new Variable(getModel());
+						faultVar.setName(catchPath.getFaultVariable());
+						faultVar.setMessageType(catchPath.getFaultMessageType());
+						faultVar.setElement(catchPath.getFaultMessageElement());			
+						context.addVariable(faultVar);
+					}
+					
+					if (catchPath.getActivity() != null) {
+						catchPath.getActivity().convert(cb.getContents(), context);
+					}
+					
+					if (faultVar != null) {
+						context.removeVariable(faultVar);
+					}
+
+					te.getEscapeBlocks().add(cb);
+				}
+			}
+			
+			// Convert normal activities in scope
+			if (getActivity() != null) {
+				getActivity().convert(acts, context);
+			}
+		}
+	}
+	
+	protected String getLocalURIPart(BPELElement elem) {
+		String ret="";
+		
+		if (elem instanceof BPELActivity) {
+			ret += "@activity";
+		} else if (elem instanceof FaultHandlers) {
+			ret += "@faultHandlers";
+		} else if (elem instanceof EventHandlers) {
+			ret += "@eventHandlers";
+		}
+		
+		return(ret);
+	}
+	
+	private org.w3c.dom.Element m_partnerLinksElem=null;
+	private org.w3c.dom.Element m_variablesElem=null;
+	private org.w3c.dom.Element m_messageExchangesElem=null;
+	private org.w3c.dom.Element m_correlationSetsElem=null;
+	private java.util.List<PartnerLink> m_partnerLinks=new java.util.Vector<PartnerLink>();
+	private java.util.List<Variable> m_variables=new java.util.Vector<Variable>();
+	private EventHandlers m_eventHandlers=null;
+	private FaultHandlers m_faultHandlers=null;
+	private CompensationHandler m_compensationHandler=null;
+	private TerminationHandler m_terminationHandler=null;
+	private BPELActivity m_activity;
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/ScopeActivity.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/ScopeActivity.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/ScopeActivity.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,129 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This interface represents a scope activity.
+ *  
+ * @author gary
+ */
+public interface ScopeActivity {
+
+	/**
+	 * This method adds a variable to the scope.
+	 * 
+	 * @param var The variable to be added
+	 * @param pos The position to add, or -1 if at the end
+	 */
+	public void addVariable(Variable var, int pos);
+	
+	/**
+	 * This method removes an activity from the grouping
+	 * construct.
+	 * 
+	 * @param act The activity to be removed
+	 * @return Whether the activity was removed
+	 */
+	public boolean removeVariable(Variable var);
+	
+	/**
+	 * This method returns the list of variables.
+	 * 
+	 * @return The 
+	 */
+	public java.util.List<Variable> getVariables();
+	
+	/**
+	 * This method adds a partner link to the scope.
+	 * 
+	 * @param pl The partner link to be added
+	 * @param pos The position to add, or -1 if at the end
+	 */
+	public void addPartnerLink(PartnerLink pl, int pos);
+	
+	/**
+	 * This method removes a partner link from the grouping
+	 * construct.
+	 * 
+	 * @param pl The partner link to be removed
+	 * @return Whether the partner link was removed
+	 */
+	public boolean removePartnerLink(PartnerLink pl);
+	
+	/**
+	 * This method returns the list of partner links.
+	 * 
+	 * @return The partner links
+	 */
+	public java.util.List<PartnerLink> getPartnerLinks() ;
+	
+	/**
+	 * This method sets the activity associated with
+	 * the 'else' construct.
+	 * 
+	 * @param act The activity
+	 */
+	public void setActivity(BPELActivity act) ;
+	
+	/**
+	 * This method returns the activity associated with
+	 * the 'else' construct.
+	 * 
+	 * @return The activity
+	 */
+	public BPELActivity getActivity() ;
+	
+	/**
+	 * This method sets the 'eventHandlers' path.
+	 * 
+	 * @param elem The 'eventHandlers' path
+	 */
+	public void setEventHandlers(EventHandlers elem);
+	
+	/**
+	 * This method returns the 'eventHandlers' path.
+	 * 
+	 * @return The 'eventHandlers' path
+	 */
+	public EventHandlers getEventHandlers();
+	
+	/**
+	 * This method sets the 'faultHandlers' path.
+	 * 
+	 * @param elem The 'faultHandlers' path
+	 */
+	public void setFaultHandlers(FaultHandlers elem);
+	
+	/**
+	 * This method returns the 'faultHandlers' path.
+	 * 
+	 * @return The 'faultHandlers' path
+	 */
+	public FaultHandlers getFaultHandlers();
+	
+	/**
+	 * This method validates the BPEL activity and reports warnings or
+	 * errors to the supplied model listener.
+	 * 
+	 * @param l The model listener
+	 */
+	public void validate(ModelListener l);
+	
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Sequence.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Sequence.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Sequence.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,155 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class represents a sequence grouping activity.
+ *  
+ * @author gary
+ */
+public class Sequence extends BPELActivity {
+
+	public static final String SEQUENCE = "sequence";
+	
+	private static final long serialVersionUID = 6656299352423612770L;
+
+	/**
+	 * The constructor for the activity.
+	 * 
+	 * @param model The BPEL model
+	 * @param activity The XML configuration details for the activity
+	 */
+	public Sequence(BPELLanguageModel model,
+					org.w3c.dom.Element activity) {
+		super(model, activity);
+		
+		java.util.List<BPELElement> acts=
+					findChildElements(BPELActivity.class);
+		
+		for (int i=0; i < acts.size(); i++) {
+			if (acts.get(i).isActivity() &&
+					acts.get(i) instanceof BPELActivity) {
+				m_activities.add((BPELActivity)acts.get(i));
+			}
+		}
+	}
+
+	/**
+	 * The constructor for the activity.
+	 * 
+	 * @param model The BPEL model
+	 */
+	public Sequence(BPELLanguageModel model) {
+		super(model, SEQUENCE);
+	}
+
+	/**
+	 * This method adds an activity to the grouping construct.
+	 * 
+	 * @param act The activity to be added
+	 * @param pos The position to add, or -1 if at the end
+	 */
+	public void addActivity(BPELActivity act, int pos) {
+		if (pos == -1 || pos >= m_activities.size()) {
+			m_activities.add(act);
+			
+			setChildElement(null, act, null);
+		} else {
+			
+			BPELActivity cur=m_activities.get(pos);
+			
+			m_activities.add(pos, act);
+			
+			if (cur != null) {
+				setChildElement(null, act,
+							cur.getDOMElement());
+			} else {
+				setChildElement(null, act, null);
+			}
+		}
+	}
+	
+	/**
+	 * This method removes an activity from the grouping
+	 * construct.
+	 * 
+	 * @param act The activity to be removed
+	 * @return Whether the activity was removed
+	 */
+	public boolean removeActivity(BPELActivity act) {
+		boolean ret=m_activities.remove(act);
+		
+		if (ret) {
+			getDOMElement().removeChild(act.getDOMElement());
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the list of activities associated
+	 * with the grouping construct.
+	 * 
+	 * @return The list of activities
+	 */
+	public java.util.List<BPELActivity> getActivities() {
+		return(m_activities);
+	}
+
+	/**
+	 * This method validates the BPEL activity and reports warnings or
+	 * errors to the supplied model listener.
+	 * 
+	 * @param l The model listener
+	 */
+	@Override
+	public void validate(ModelListener l) {
+	}
+	
+	/**
+	 * This method does the actual work of converting the specific
+	 * BPEL activity into an equivalent behavioural description for 
+	 * conformance checking. The 'convert' method provides
+	 * a wrapper around this method, to handle the standard elements
+	 * that can be associated with any BPEL activity.
+	 * 
+	 * @param activities The list of activities that will contain
+	 * 				the converted action(s)
+	 * @param context The conversion context
+	 */
+	protected void convertActivity(java.util.List<Activity> activities,
+			ConversionContext context) {
+		getSource().setComponentURI(getURI());
+		
+		for (int i=0; i < m_activities.size(); i++) {
+			m_activities.get(i).convert(activities, context);
+		}
+	}
+
+	protected String getLocalURIPart(BPELElement elem) {
+		int pos=getActivities().indexOf(elem);
+		return("@activities."+pos);
+	}
+	
+	private java.util.List<BPELActivity> m_activities=
+					new java.util.Vector<BPELActivity>();
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Source.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Source.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Source.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import java.util.List;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.scribble.model.Activity;
+
+/**
+ * This class represents the BPEL source element, contained within
+ * any BPEL activity.
+ */
+public class Source extends BPELElement {
+
+	private static final long serialVersionUID = 4878669992635772776L;
+
+	private static final String LINK_NAME = "linkName";
+
+	public static final String SOURCE="source";
+	
+	/**
+	 * The constructor for the element.
+	 * 
+	 * @param model The BPEL model
+	 * @param elem The XML configuration details for the element
+	 */
+	public Source(BPELLanguageModel model,
+					org.w3c.dom.Element elem) {
+		super(model, elem);
+	}
+
+	/**
+	 * The constructor for the element.
+	 * 
+	 * @param model The BPEL model
+	 */
+	public Source(BPELLanguageModel model) {
+		super(model, SOURCE);
+	}
+
+	/**
+	 * This method returns the name associated
+	 * with the link.
+	 * 
+	 * @return The link name
+	 */
+	public String getLinkName() {
+		return(getDOMElement().getAttribute(LINK_NAME));
+	}
+	
+	/**
+	 * This method sets the link name.
+	 * 
+	 * @param name The name
+	 */
+	public void setLinkName(String name) {
+		getDOMElement().setAttribute(LINK_NAME, name);
+	}
+	
+	@Override
+	public void convert(List<Activity> activities, ConversionContext context) {
+		// TODO Auto-generated method stub
+		
+	}
+
+
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Target.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Target.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Target.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import java.util.List;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.scribble.model.Activity;
+
+/**
+ * This class represents the BPEL target element, contained within
+ * any BPEL activity.
+ */
+public class Target extends BPELElement {
+
+	private static final long serialVersionUID = -8813636777020840433L;
+
+	private static final String LINK_NAME = "linkName";
+
+	public static final String TARGET="target";
+	
+	/**
+	 * The constructor for the element.
+	 * 
+	 * @param model The BPEL model
+	 * @param elem The XML configuration details for the element
+	 */
+	public Target(BPELLanguageModel model,
+					org.w3c.dom.Element elem) {
+		super(model, elem);
+	}
+
+	/**
+	 * The constructor for the element.
+	 * 
+	 * @param model The BPEL model
+	 */
+	public Target(BPELLanguageModel model) {
+		super(model, TARGET);
+	}
+
+	/**
+	 * This method returns the name associated
+	 * with the link.
+	 * 
+	 * @return The link name
+	 */
+	public String getLinkName() {
+		return(getDOMElement().getAttribute(LINK_NAME));
+	}
+	
+	/**
+	 * This method sets the link name.
+	 * 
+	 * @param name The name
+	 */
+	public void setLinkName(String name) {
+		getDOMElement().setAttribute(LINK_NAME, name);
+	}
+	
+	@Override
+	public void convert(List<Activity> activities, ConversionContext context) {
+		// TODO Auto-generated method stub
+		
+	}
+
+
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/TerminationHandler.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/TerminationHandler.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/TerminationHandler.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import java.util.List;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.scribble.model.Activity;
+
+/**
+ * This class represents the 'terminationHandler' construct contained
+ * within the 'scope' activity.
+ */
+public class TerminationHandler extends BPELElement {
+
+	private static final long serialVersionUID = 7316551859410369824L;
+
+	public static final String TERMINATIONHANDLER="terminationHandler";
+	
+	/**
+	 * The constructor for the element.
+	 * 
+	 * @param model The BPEL model
+	 * @param activity The XML configuration details for the element
+	 */
+	public TerminationHandler(BPELLanguageModel model,
+					org.w3c.dom.Element activity) {
+		super(model, activity);
+		
+		m_activity = findChildActivity();
+	}
+
+	/**
+	 * The constructor for the element.
+	 * 
+	 * @param model The BPEL model
+	 */
+	public TerminationHandler(BPELLanguageModel model) {
+		super(model, TERMINATIONHANDLER);
+	}
+
+	/**
+	 * This method sets the activity associated with
+	 * the 'else' construct.
+	 * 
+	 * @param act The activity
+	 */
+	public void setActivity(BPELElement act) {
+		m_activity = act;
+		
+		BPELElement existing=findChildActivity();
+		org.w3c.dom.Element existingElem=null;
+		
+		if (existing != null) {
+			existingElem = existing.getDOMElement();
+		}
+
+		org.w3c.dom.Element insertBefore=null;
+		
+		setChildElement(existingElem, act,
+						insertBefore);
+	}
+	
+	/**
+	 * This method returns the activity associated with
+	 * the 'else' construct.
+	 * 
+	 * @return The activity
+	 */
+	public BPELElement getActivity() {
+		return(m_activity);
+	}
+	
+	@Override
+	public void convert(List<Activity> activities, ConversionContext context) {
+		// TODO Auto-generated method stub
+		
+	}
+	
+	private BPELElement m_activity;
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Throw.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Throw.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Throw.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,123 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class represents the throw activity.
+ *  
+ * @author gary
+ */
+public class Throw extends BPELActivity {
+
+	private static final long serialVersionUID = 9187657888490480490L;
+
+	public static final String THROW = "throw";
+	
+	private static final String FAULT_NAME = "faultName";
+	private static final String FAULT_VARIABLE = "faultVariable";
+	
+	/**
+	 * The constructor for the activity.
+	 * 
+	 * @param model The BPEL model
+	 * @param activity The XML configuration details for the activity
+	 */
+	public Throw(BPELLanguageModel  model,
+					org.w3c.dom.Element activity) {
+		super(model, activity);
+	}
+
+	/**
+	 * The constructor for the activity.
+	 * 
+	 * @param model The BPEL model
+	 */
+	public Throw(BPELLanguageModel model) {
+		super(model, THROW);
+	}
+
+	/**
+	 * This method sets the fault name.
+	 * 
+	 * @param faultName The fault name
+	 */
+	public void setFaultName(String faultName) {		
+		getDOMElement().setAttribute(FAULT_NAME, faultName);
+	}
+	
+	/**
+	 * This method returns the fault name.
+	 * 
+	 * @return The fault name
+	 */
+	public String getFaultName() {
+		return(getDOMElement().hasAttribute(FAULT_NAME)?
+				getDOMElement().getAttribute(FAULT_NAME):null);
+	}
+
+	/**
+	 * This method sets the fault variable.
+	 * 
+	 * @param faultVariable The fault variable
+	 */
+	public void setFaultVariable(String faultVariable) {		
+		getDOMElement().setAttribute(FAULT_VARIABLE, faultVariable);
+	}
+	
+	/**
+	 * This method returns the fault variable.
+	 * 
+	 * @return The fault variable
+	 */
+	public String getFaultVariable() {
+		return(getDOMElement().hasAttribute(FAULT_VARIABLE)?
+				getDOMElement().getAttribute(FAULT_VARIABLE):null);
+	}
+
+	/**
+	 * This method validates the BPEL activity and reports warnings or
+	 * errors to the supplied model listener.
+	 * 
+	 * @param l The model listener
+	 */
+	@Override
+	public void validate(ModelListener l) {
+		// Don't validate unsupported actions
+	}
+	
+	/**
+	 * This method does the actual work of converting the specific
+	 * BPEL activity into an equivalent behavioural description for 
+	 * conformance checking. The 'convert' method provides
+	 * a wrapper around this method, to handle the standard elements
+	 * that can be associated with any BPEL activity.
+	 * 
+	 * @param activities The list of activities that will contain
+	 * 				the converted action(s)
+	 * @param context The conversion context
+	 */
+	protected void convertActivity(java.util.List<Activity> activities,
+			ConversionContext context) {
+		getSource().setComponentURI(getURI());
+	}
+
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Until.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Until.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Until.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.BPELLanguageModel;
+
+/**
+ * This class represents the BPEL 'until' element.
+ */
+public class Until extends AbstractCondition {
+
+	private static final long serialVersionUID = 5398291987513467996L;
+
+	public static final String UNTIL="until";
+	
+	/**
+	 * The constructor for the element.
+	 * 
+	 * @param model The BPEL model
+	 * @param elem The XML configuration details for the element
+	 */
+	public Until(BPELLanguageModel model,
+					org.w3c.dom.Element elem) {
+		super(model, elem);
+	}
+
+	/**
+	 * The constructor for the element.
+	 * 
+	 * @param model The BPEL model
+	 */
+	public Until(BPELLanguageModel model) {
+		super(model, UNTIL);
+	}
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Variable.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Variable.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Variable.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,159 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class represents the variable.
+ *  
+ * @author gary
+ */
+public class Variable extends BPELElement {
+
+	private static final long serialVersionUID = -3824104482191549444L;
+
+	public static final String VARIABLE = "variable";
+	
+	private static final String NAME = "name";
+	private static final String TYPE = "type";
+	private static final String ELEMENT = "element";
+	private static final String MESSAGE_TYPE = "messageType";
+	
+	/**
+	 * The constructor for the element.
+	 * 
+	 * @param model The BPEL model
+	 * @param element The XML configuration details for the element
+	 */
+	public Variable(BPELLanguageModel  model,
+					org.w3c.dom.Element element) {
+		super(model, element);
+	}
+
+	/**
+	 * The constructor for the element.
+	 * 
+	 * @param model The BPEL model
+	 */
+	public Variable(BPELLanguageModel model) {
+		super(model, VARIABLE);
+	}
+
+	/**
+	 * This method sets the name.
+	 * 
+	 * @param name The name
+	 */
+	public void setName(String name) {		
+		getDOMElement().setAttribute(NAME, name);
+	}
+	
+	/**
+	 * This method returns the name.
+	 * 
+	 * @return The name
+	 */
+	public String getName() {
+		return(getDOMElement().hasAttribute(NAME)?
+				getDOMElement().getAttribute(NAME):null);
+	}
+
+	/**
+	 * This method sets the variable type.
+	 * 
+	 * @param type The type
+	 */
+	public void setType(String type) {		
+		getDOMElement().setAttribute(TYPE, type);
+	}
+	
+	/**
+	 * This method returns the variable type.
+	 * 
+	 * @return The type
+	 */
+	public String getType() {
+		return(getDOMElement().hasAttribute(TYPE)?
+				getDOMElement().getAttribute(TYPE):null);
+	}
+
+	/**
+	 * This method sets the variable element.
+	 * 
+	 * @param element The element
+	 */
+	public void setElement(String element) {		
+		getDOMElement().setAttribute(ELEMENT, element);
+	}
+	
+	/**
+	 * This method returns the variable element.
+	 * 
+	 * @return The element
+	 */
+	public String getElement() {
+		return(getDOMElement().hasAttribute(ELEMENT)?
+				getDOMElement().getAttribute(ELEMENT):null);
+	}
+
+	/**
+	 * This method sets the variable message type.
+	 * 
+	 * @param type The message type
+	 */
+	public void setMessageType(String type) {		
+		getDOMElement().setAttribute(MESSAGE_TYPE, type);
+	}
+	
+	/**
+	 * This method returns the variable message type.
+	 * 
+	 * @return The message type
+	 */
+	public String getMessageType() {
+		return(getDOMElement().hasAttribute(MESSAGE_TYPE)?
+				getDOMElement().getAttribute(MESSAGE_TYPE):null);
+	}
+
+	/**
+	 * This method validates the BPEL activity and reports warnings or
+	 * errors to the supplied model listener.
+	 * 
+	 * @param l The model listener
+	 */
+	@Override
+	public void validate(ModelListener l) {
+		// Don't validate unsupported actions
+	}
+	
+	/**
+	 * This method converts the BPEL activity into an equivalent
+	 * behavioural description for conformance checking.
+	 * 
+	 * @param activities The list of activities that will contain
+	 * 				the converted action(s)
+	 * @param context The conversion context
+	 */
+	public void convert(java.util.List<Activity> activities,
+			ConversionContext context) {
+	}
+
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Wait.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Wait.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/Wait.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,148 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class represents the wait activity.
+ *  
+ * @author gary
+ */
+public class Wait extends BPELActivity {
+
+	private static final String FOR = "for";
+
+	private static final String UNTIL = "until";
+
+	private static final long serialVersionUID = -3934422332929710337L;
+
+	public static final String WAIT = "wait";
+	
+	/**
+	 * The constructor for the activity.
+	 * 
+	 * @param model The BPEL model
+	 * @param activity The XML configuration details for the activity
+	 */
+	public Wait(BPELLanguageModel  model,
+					org.w3c.dom.Element activity) {
+		super(model, activity);
+	}
+
+	/**
+	 * The constructor for the activity.
+	 * 
+	 * @param model The BPEL model
+	 */
+	public Wait(BPELLanguageModel model) {
+		super(model, WAIT);
+	}
+
+	/**
+	 * This method sets the 'until' condition.
+	 * 
+	 * @param cond The 'until' condition
+	 */
+	public void setUntil(Condition cond) {
+		setChildElement(findChildElement(UNTIL),
+				cond, null);
+		
+		org.w3c.dom.Element elem=findChildElement(FOR);
+		if (elem != null) {
+			getDOMElement().removeChild(elem);
+		}
+	}
+	
+	/**
+	 * This method returns the 'until' condition.
+	 * 
+	 * @return The 'until' condition
+	 */
+	public Condition getUntil() {
+		Condition ret=null;
+		
+		org.w3c.dom.Element elem=findChildElement(UNTIL);
+		if (elem != null) {
+			ret = new Condition(getModel(), elem);
+		}
+		
+		return(ret);
+	}
+
+	/**
+	 * This method sets the 'for' condition.
+	 * 
+	 * @param cond The 'for' condition
+	 */
+	public void setFor(Condition cond) {
+		setChildElement(findChildElement(FOR),
+				cond, null);
+		
+		org.w3c.dom.Element elem=findChildElement(UNTIL);
+		if (elem != null) {
+			getDOMElement().removeChild(elem);
+		}
+	}
+	
+	/**
+	 * This method returns the 'for' condition.
+	 * 
+	 * @return The 'for' condition
+	 */
+	public Condition getFor() {
+		Condition ret=null;
+		
+		org.w3c.dom.Element elem=findChildElement(FOR);
+		if (elem != null) {
+			ret = new Condition(getModel(), elem);
+		}
+		
+		return(ret);
+	}
+
+	/**
+	 * This method validates the BPEL activity and reports warnings or
+	 * errors to the supplied model listener.
+	 * 
+	 * @param l The model listener
+	 */
+	@Override
+	public void validate(ModelListener l) {
+		// Don't validate unsupported actions
+	}
+	
+	/**
+	 * This method does the actual work of converting the specific
+	 * BPEL activity into an equivalent behavioural description for 
+	 * conformance checking. The 'convert' method provides
+	 * a wrapper around this method, to handle the standard elements
+	 * that can be associated with any BPEL activity.
+	 * 
+	 * @param activities The list of activities that will contain
+	 * 				the converted action(s)
+	 * @param context The conversion context
+	 */
+	protected void convertActivity(java.util.List<Activity> activities,
+			ConversionContext context) {
+		getSource().setComponentURI(getURI());
+	}
+
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/While.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/While.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/component/While.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,173 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class represents a while grouping activity.
+ *  
+ * @author gary
+ */
+public class While extends BPELGroupingConstruct {
+
+	private static final long serialVersionUID = -4173984531470466407L;
+	
+	public static final String WHILE = "while";
+
+	/**
+	 * The constructor for the activity.
+	 * 
+	 * @param model The BPEL model
+	 * @param activity The XML configuration details for the activity
+	 */
+	public While(BPELLanguageModel model,
+					org.w3c.dom.Element activity) {
+		super(model, activity);
+	
+		org.w3c.dom.Element cond=
+			findChildElement(Condition.CONDITION);
+
+		if (cond == null) {
+			m_condition = new Condition(model);
+		} else {
+			m_condition = new Condition(model, cond);
+		}
+	
+		m_activity = findChildActivity();
+	}
+
+	/**
+	 * The constructor for the activity.
+	 * 
+	 * @param model The BPEL model
+	 */
+	public While(BPELLanguageModel model) {
+		super(model, WHILE);
+	}
+
+	/**
+	 * This method validates the BPEL activity and reports warnings or
+	 * errors to the supplied model listener.
+	 * 
+	 * @param l The model listener
+	 */
+	@Override
+	public void validate(ModelListener l) {
+	}
+	
+	/**
+	 * This method does the actual work of converting the specific
+	 * BPEL activity into an equivalent behavioural description for 
+	 * conformance checking. The 'convert' method provides
+	 * a wrapper around this method, to handle the standard elements
+	 * that can be associated with any BPEL activity.
+	 * 
+	 * @param activities The list of activities that will contain
+	 * 				the converted action(s)
+	 * @param context The conversion context
+	 */
+	protected void convertActivity(java.util.List<Activity> activities,
+			ConversionContext context) {
+		getSource().setComponentURI(getURI());
+		
+		org.scribble.conversation.model.While elem=
+					new org.scribble.conversation.model.While();
+		
+		// TODO: Convert while expression
+		
+		if (getActivity() != null) {
+			getActivity().convert(elem.getBlock().getContents(), context);
+		}
+		
+		activities.add(elem);
+	}
+
+	/**
+	 * This method sets the condition.
+	 * 
+	 * @param cond The condition
+	 */
+	public void setCondition(Condition cond) {
+		m_condition = cond;
+		
+		org.w3c.dom.Element insertBefore=null;
+		
+		if (m_activity != null) {
+			insertBefore = m_activity.getDOMElement();
+		}
+
+		setChildElement(findChildElement(Condition.CONDITION),
+				cond, insertBefore);
+	}
+	
+	/**
+	 * This method returns the condition.
+	 * 
+	 * @return The condition
+	 */
+	public Condition getCondition() {
+		return(m_condition);
+	}
+
+	/**
+	 * This method sets the main 'if' activity.
+	 * 
+	 * @param act The activity associated with the 'if'
+	 */
+	public void setActivity(BPELElement act) {
+		m_activity = act;
+		
+		BPELElement existing=findChildActivity();
+		org.w3c.dom.Element existingElem=null;
+		
+		if (existing != null) {
+			existingElem = existing.getDOMElement();
+		}
+
+		org.w3c.dom.Element insertBefore=null;
+		
+		setChildElement(existingElem, act,
+						insertBefore);
+	}
+
+	/**
+	 * This method returns the activity associated with
+	 * the 'if' path.
+	 * 
+	 * @return The 'if' activity
+	 */
+	public BPELElement getActivity() {
+		return(m_activity);
+	}
+	
+	protected String getLocalURIPart(BPELElement elem) {
+		String ret="";
+		
+		if (elem instanceof BPELActivity) {
+			ret = "@activity";
+		}
+		
+		return(ret);
+	}
+	
+	private Condition m_condition=null;
+	private BPELElement m_activity=null;
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/util/InteractionUtil.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/util/InteractionUtil.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/util/InteractionUtil.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,168 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.util;
+
+import org.savara.bpel.model.component.BPELActivity;
+import org.savara.bpel.model.component.Invoke;
+import org.savara.bpel.model.component.Sequence;
+import org.scribble.model.*;
+
+/**
+ * This class contains utility functions for dealing with Interactions.
+ */
+public class InteractionUtil {
+	
+	/**
+	 * This method returns the name associated with the interaction.
+	 * 
+	 * @param interaction The interaction
+	 * @return The name
+	 */
+	public static String getName(Interaction interaction) {
+		String ret=null;
+		
+		if (isSend(interaction)) {
+			ret = "Send";
+		} else {
+			ret = "Receive";
+		}
+		
+		for (TypeReference ref : interaction.getMessageSignature().getTypes()) {
+			ret += "_"+ref.getLocalpart();
+		}
+
+		return(ret);
+	}
+	
+	/**
+	 * This method determines whether the supplied interaction
+	 * is a send.
+	 * 
+	 * @param interaction The interaction
+	 * @return Whether the interaction is a send
+	 */
+	public static boolean isSend(Interaction interaction) {
+		boolean ret=false;
+		Role role=null;
+		
+		if (interaction.getEnclosingDefinition() != null) {
+			role = interaction.getEnclosingDefinition().
+						getLocatedName().getRole();
+		}
+		
+		if (role != null && ((interaction.getFromRole() != null &&
+				interaction.getFromRole().equals(
+						role)) ||
+			(interaction.getToRole() != null &&
+				interaction.getToRole().equals(
+						role) == false))) {
+			ret = true;
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method determines whether the supplied interaction
+	 * is a request.
+	 * 
+	 * @param interaction The interaction
+	 * @return Whether the interaction is a request
+	 */
+	public static boolean isRequest(Interaction interaction) {
+		boolean ret=false;
+
+		if (interaction.getRequestLabel() != null ||
+				interaction.getReplyToLabel() == null) {
+			ret = true;
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method determines whether the supplied interaction
+	 * is a response.
+	 * 
+	 * @param interaction The interaction
+	 * @return Whether the interaction is a response
+	 */
+	public static boolean isResponse(Interaction interaction) {
+		boolean ret=false;
+
+		if (interaction.getReplyToLabel() != null) {
+			ret = true;
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method determines whether this is the first interaction
+	 * associated with the conversation.
+	 * 
+	 * @param interaction The interaction
+	 * @return Whether the interaction is the first in the conversation
+	 */
+	/**
+	 * This method determines whether the supplied activity
+	 * is either an invoke, or a sequence that has an
+	 * invoke as its first element.
+	 * 
+	 * @param act The activity
+	 * @return The invoke, or null if not found
+	 */
+	public static Invoke getInvoke(BPELActivity act) {
+		Invoke ret=null;
+		
+		if (act instanceof Invoke) {
+			ret = (Invoke)act;
+		} else if (act instanceof Sequence &&
+				((Sequence)act).getActivities().size() > 0 &&
+				((Sequence)act).getActivities().get(0) instanceof Invoke) {
+			ret = (Invoke)((Sequence)act).getActivities().get(0);
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method recursively counts the number of 'invoke' activities
+	 * contained within a DOM element.
+	 * 
+	 * @param elem The current element
+	 * @return The number of invokes contained within the element
+	 */
+	public static int countInvokes(org.w3c.dom.Element elem) {
+		int ret=0;
+		
+		if (elem.getLocalName().equals("invoke")) {
+			ret = 1;
+		} else {
+			org.w3c.dom.NodeList nl=elem.getChildNodes();
+			
+			for (int i=0; i < nl.getLength(); i++) {
+				if (nl.item(i) instanceof org.w3c.dom.Element) {
+					ret += countInvokes((org.w3c.dom.Element)nl.item(i));
+				}
+			}
+		}
+		
+		return(ret);
+	}	
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/util/TypeReferenceUtil.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/util/TypeReferenceUtil.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/util/TypeReferenceUtil.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.util;
+
+import javax.xml.namespace.QName;
+
+import org.savara.bpel.model.component.ConversionContext;
+import org.scribble.model.TypeReference;
+
+public class TypeReferenceUtil {
+
+	public static TypeReference createTypeReference(String type, ConversionContext context) {
+		TypeReference ret=new TypeReference();
+		//ret.derivedFrom(this);
+		
+		if (type != null) {
+			int index=-1;
+			
+			if (type.charAt(0) == '{') {
+				// Assume a qname
+				QName qname=QName.valueOf(type);
+				
+				ret.setLocalpart(qname.getLocalPart());
+				ret.setNamespace(qname.getNamespaceURI());
+				
+			} else if ((index=type.indexOf(':')) == -1) {
+				ret.setLocalpart(type);
+				
+			} else {
+				ret.setLocalpart(type.substring(index+1));
+				
+				String prefix=type.substring(0, index);
+				String ns=context.getNamespace(prefix);
+				
+				if (ns != null) {
+					ret.setNamespace(ns);
+				} else {
+					// TODO: Log error
+				}
+			}
+		}
+		
+		return(ret);	
+	}
+	
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/osgi/Activator.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/osgi/Activator.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/osgi/Activator.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,30 @@
+package org.savara.bpel.osgi;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator {
+
+	private static BundleContext context;
+
+	static BundleContext getContext() {
+		return context;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+	 */
+	public void start(BundleContext bundleContext) throws Exception {
+		Activator.context = bundleContext;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+	 */
+	public void stop(BundleContext bundleContext) throws Exception {
+		Activator.context = null;
+	}
+
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/parser/BPELModelParserRule.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/parser/BPELModelParserRule.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/parser/BPELModelParserRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,111 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.parser;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.savara.bpel.model.BPELNotation;
+import org.savara.bpel.model.DefaultBPELLanguageModel;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.Model;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.parser.ParserContext;
+import org.scribble.parser.ParserRule;
+import org.scribble.parser.Token;
+
+/**
+ * This class provides the model parser for the BPEL notation.
+ * 
+ */
+ at RegistryInfo(extension=ParserRule.class,notation=BPELNotation.NOTATION_CODE)
+public class BPELModelParserRule extends org.scribble.conversation.parser.ConversationModelParserRule {
+
+	/**
+	 * The default constructor.
+	 */
+	public BPELModelParserRule() {
+		//super(ParserRuleType.File);
+	}
+	
+	/**
+	 * This method determines whether the parser rules is
+	 * appropriate to return a model object of the required
+	 * type.
+	 * 
+	 * @param type The required type
+	 * @return Whether the parser rule returns a
+	 * 				model object of the required type
+	 */
+	public boolean isSupported(Class<?> type) {
+		return(type.isAssignableFrom(Model.class));
+	}
+	
+	/**
+	 * This method parses the description to obtain
+	 * a model object of the appropriate type.
+	 * 
+	 * @param context The context
+	 * @param l The listener
+	 * @return The model object
+	 */
+	public Object parse(ParserContext context, ModelListener l) {
+		DefaultBPELLanguageModel ret=null;
+		
+		Token t=context.nextToken();
+		
+		if (t != null && t.getObject() instanceof String) {
+			try {						
+				String str=(String)t.getObject();
+				
+				// Transform the text representation to DOM
+				DocumentBuilderFactory fact=DocumentBuilderFactory.newInstance();
+				fact.setNamespaceAware(true);
+				
+				DocumentBuilder builder=fact.newDocumentBuilder();
+				
+				// Need to load original input stream and then
+				// provide a second input stream, as some input stream
+				// implementations don't support 'reset' operation,
+				// and therefore this was the only way to extract the
+				// content and also provide the stream to the XML
+				// document builder.
+				java.io.ByteArrayInputStream bais=
+							new java.io.ByteArrayInputStream(str.getBytes());
+				
+				org.w3c.dom.Document doc=builder.parse(bais);
+				
+				// Identify the model associated with the
+				// changed resource
+				ret = new DefaultBPELLanguageModel(context.getSource(),
+						doc.getDocumentElement(), str, context.getEnvironmentContext());
+				
+			} catch(Exception e) {
+				logger.log(Level.SEVERE,
+						"Failed to load model", e);
+			}
+		}
+
+		return(ret);
+	}
+
+	private static Logger logger = Logger.getLogger("org.savara.tools.bpel.parser");
+}

Added: trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/parser/BPELTokenizer.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/parser/BPELTokenizer.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/main/java/org/savara/bpel/parser/BPELTokenizer.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.parser;
+
+import org.savara.bpel.model.BPELNotation;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.ModelReference;
+import org.scribble.parser.*;
+
+/**
+ * This is the BPEL based implementation of the tokenizer
+ * interface.
+ */
+ at RegistryInfo(extension=Tokenizer.class,notation=BPELNotation.NOTATION_CODE)
+public class BPELTokenizer extends DefaultTokenizer {
+
+	/**
+	 * The default constructor.
+	 */
+	public BPELTokenizer() {
+	}
+	
+	/**
+	 * This method obtains a list of tokens based on the
+	 * contents of the input stream.
+	 * 
+	 * @param ref The model reference for the input source
+	 * @param is The input stream
+	 * @return The list of tokens
+	 * @throws java.io.IOException Failed to derive 
+	 */
+	public java.util.List<Token> getTokens(ModelReference ref,
+			java.io.InputStream is)	throws java.io.IOException {
+		java.util.List<Token> ret=new java.util.Vector<Token>();
+		
+		byte[] b=new byte[is.available()];
+		is.read(b);
+			
+		Token t=new Token(new String(b));
+		ret.add(t);
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/change/ModelChangeUtilsTest.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/change/ModelChangeUtilsTest.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/change/ModelChangeUtilsTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,272 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.change;
+
+import org.savara.bpel.model.change.ModelChangeUtils;
+import org.savara.contract.model.*;
+import org.scribble.conversation.model.Conversation;
+import org.scribble.conversation.model.Run;
+import org.scribble.model.*;
+import org.scribble.model.change.DefaultModelChangeContext;
+import org.scribble.model.change.ModelChangeContext;
+
+import junit.framework.TestCase;
+
+public class ModelChangeUtilsTest extends TestCase {
+
+	private static final String MY_ROLE = "MyRole";
+	private static final String MY_LOCATED_ROLE = "MyLocatedRole";
+	private static final String MY_OTHER_ROLE = "MyOtherRole";
+	private static final String MY_OTHER_LOCATED_ROLE = "MyOtherLocatedRole";
+
+	public void testInitialiseContracts() {
+		ModelChangeContext context=new DefaultModelChangeContext(null, null);
+		
+		Conversation conv=new Conversation();
+		LocatedName ln=new LocatedName();
+		Role r=new Role();
+		r.setName(MY_ROLE);
+		
+		Contract c=new Contract();
+		r.getAnnotations().put(Contract.class.getName(), c);
+		
+		ln.setRole(r);
+		conv.setLocatedName(ln);
+		
+		ModelChangeUtils.addContracts(context, conv, true);
+		
+		Contract c2=ModelChangeUtils.getContract(context, MY_ROLE);
+		
+		if (c2 == null) {
+			fail("Contract not found");
+		}
+		
+		if (c2 != c) {
+			fail("Contract not the same as the one stored");
+		}
+	}
+
+	public void testInitialiseContractsTwice() {
+		ModelChangeContext context=new DefaultModelChangeContext(null, null);
+		
+		Conversation conv=new Conversation();
+		LocatedName ln=new LocatedName();
+		Role r=new Role();
+		r.setName(MY_ROLE);
+		
+		Contract c=new Contract();
+		r.getAnnotations().put(Contract.class.getName(), c);
+		
+		ln.setRole(r);
+		conv.setLocatedName(ln);
+		
+		ModelChangeUtils.addContracts(context, conv, true);
+		
+		Conversation conv2=new Conversation();
+		LocatedName ln2=new LocatedName();
+		Role r2=new Role();
+		r2.setName(MY_OTHER_ROLE);
+
+		Contract c2=new Contract();
+		r2.getAnnotations().put(Contract.class.getName(), c2);
+		
+		ln2.setRole(r2);
+		conv2.setLocatedName(ln2);
+		
+		ModelChangeUtils.addContracts(context, conv2, true);
+		
+		Contract c3=ModelChangeUtils.getContract(context, MY_ROLE);
+		
+		if (c3 == null) {
+			fail("Contract not found");
+		}
+		
+		if (c3 != c) {
+			fail("Contract not the same as the one stored");
+		}
+		
+		Contract c4=ModelChangeUtils.getContract(context, MY_OTHER_ROLE);
+		
+		if (c4 == null) {
+			fail("Contract not found");
+		}
+		
+		if (c4 != c2) {
+			fail("Contract2 not the same as the one stored");
+		}
+	}
+	
+	public void testPushRoleContractMapping() {
+		ModelChangeContext context=new DefaultModelChangeContext(null, null);
+		
+		Conversation conv=new Conversation();
+		LocatedName ln=new LocatedName();
+		Role r1=new Role();
+		r1.setName(MY_LOCATED_ROLE);
+		ln.setRole(r1);
+		conv.setLocatedName(ln);
+		
+		Contract c1=new Contract();
+		r1.getAnnotations().put(Contract.class.getName(), c1);
+		
+		Role r2=new Role();
+		r2.setName(MY_ROLE);
+		
+		Contract c2=new Contract();
+		r2.getAnnotations().put(Contract.class.getName(), c2);
+				
+		RoleList rl=new RoleList();
+		rl.getRoles().add(r2);
+		conv.getBlock().getContents().add(rl);
+		
+		ModelChangeUtils.addContracts(context, conv, true);
+
+		Conversation subconv=new Conversation();
+		LocatedName subln=new LocatedName();
+		Role subr1=new Role();
+		subr1.setName(MY_OTHER_LOCATED_ROLE);
+		subln.setRole(subr1);
+		subconv.setLocatedName(subln);
+		
+		Run run=new Run();
+		conv.getBlock().getContents().add(run);
+		run.setInlineDefinition(subconv);
+		
+		DeclarationBinding db=new DeclarationBinding();
+		db.setDeclaration(r2);
+		db.setBoundName(MY_OTHER_ROLE);
+		run.getBindings().add(db);
+		
+		ModelChangeUtils.pushRoleContractMapping(context, run);
+		
+		Contract c3=ModelChangeUtils.getContract(context, MY_ROLE);
+		Contract c4=ModelChangeUtils.getContract(context, MY_OTHER_ROLE);
+		
+		if (c3 != null) {
+			fail("Contract for "+MY_ROLE+" should be null");
+		}
+		
+		if (c4 == null) {
+			fail("Contract for "+MY_OTHER_ROLE+" should NOT be null");
+		}
+		
+		Contract c5=ModelChangeUtils.getContract(context, MY_LOCATED_ROLE);
+		Contract c6=ModelChangeUtils.getContract(context, MY_OTHER_LOCATED_ROLE);
+		
+		if (c5 != null) {
+			fail("Contract for "+MY_LOCATED_ROLE+" should be null");
+		}
+		
+		if (c6 == null) {
+			fail("Contract for "+MY_OTHER_LOCATED_ROLE+" should NOT be null");
+		}
+		
+		if (c6 != c1) {
+			fail("Located role's Contract not the same as the one stored");
+		}
+		
+		if (c4 != c2) {
+			fail("Contract not the same as the one stored");
+		}
+	}
+	
+	public void testPopRoleContractMapping() {
+		ModelChangeContext context=new DefaultModelChangeContext(null, null);
+		
+		Conversation conv=new Conversation();
+		LocatedName ln=new LocatedName();
+		Role r1=new Role();
+		r1.setName(MY_LOCATED_ROLE);
+		
+		ln.setRole(r1);
+		conv.setLocatedName(ln);
+		
+		Role r2=new Role();
+		r2.setName(MY_ROLE);
+		
+		RoleList rl=new RoleList();
+		rl.getRoles().add(r2);
+		conv.getBlock().getContents().add(rl);
+		
+		Conversation subconv=new Conversation();
+		LocatedName subln=new LocatedName();
+		Role subr1=new Role();
+		subr1.setName(MY_OTHER_LOCATED_ROLE);
+		subln.setRole(subr1);
+		subconv.setLocatedName(subln);
+		
+		Contract c1=new Contract();
+		subr1.getAnnotations().put(Contract.class.getName(), c1);
+		
+		Role r3=new Role();
+		r3.setName(MY_OTHER_ROLE);
+		
+		Contract c2=new Contract();
+		r3.getAnnotations().put(Contract.class.getName(), c2);
+
+		RoleList rl2=new RoleList();
+		rl2.getRoles().add(r3);
+		subconv.getBlock().getContents().add(rl2);
+		
+		// Add contracts for subconv as if root, as normally
+		// this would be done by pushing the contracts, so this
+		// is just being used to setup the appropriate context
+		ModelChangeUtils.addContracts(context, subconv, true);
+
+		Run run=new Run();
+		conv.getBlock().getContents().add(run);
+		run.setInlineDefinition(subconv);
+		
+		DeclarationBinding db=new DeclarationBinding();
+		db.setDeclaration(r2);
+		db.setBoundName(MY_OTHER_ROLE);
+		run.getBindings().add(db);
+		
+		ModelChangeUtils.popRoleContractMapping(context, run);
+		
+		Contract c3=ModelChangeUtils.getContract(context, MY_ROLE);
+		Contract c4=ModelChangeUtils.getContract(context, MY_OTHER_ROLE);
+		
+		if (c3 == null) {
+			fail("Contract for "+MY_ROLE+" should NOT be null");
+		}
+		
+		if (c4 != null) {
+			fail("Contract for "+MY_OTHER_ROLE+" should be null");
+		}
+		
+		Contract c5=ModelChangeUtils.getContract(context, MY_LOCATED_ROLE);
+		Contract c6=ModelChangeUtils.getContract(context, MY_OTHER_LOCATED_ROLE);
+		
+		if (c5 == null) {
+			fail("Contract for "+MY_LOCATED_ROLE+" should NOT be null");
+		}
+		
+		if (c6 != null) {
+			fail("Contract for "+MY_OTHER_LOCATED_ROLE+" should be null");
+		}
+		
+		if (c3 != c2) {
+			fail("Contract not the same as the one stored");
+		}
+		
+		if (c5 != c1) {
+			fail("Contract not the same as the one stored");
+		}
+	}
+}

Added: trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/AbstractInteractionTest.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/AbstractInteractionTest.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/AbstractInteractionTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,144 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.savara.bpel.model.DefaultBPELLanguageModel;
+
+import junit.framework.TestCase;
+
+public class AbstractInteractionTest extends TestCase {
+
+	public void testIsActivity() {
+		TestAbstractInteraction act=
+			new TestAbstractInteraction(new DefaultBPELLanguageModel(null));
+		
+		if (act.isActivity() == false) {
+			fail("Should be an activity");
+		}
+	}
+	
+	public void testBuildFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String op="testOp";
+		String portType="testPortType";
+		String partnerLink="testPartnerLink";
+		
+		String xml="<interaction xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\" "+
+		       "operation=\""+op+"\" "+
+		       "partnerLink=\""+partnerLink+"\" "+
+		       "portType=\""+portType+"\" "+
+		       "/>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		TestAbstractInteraction component=new TestAbstractInteraction(model, elem);		
+		
+		if (component.getOperation().equals(op) == false) {
+			fail("Operation not correct, expecting '"+op+"': "+
+							component.getOperation());
+		}
+		
+		if (component.getPartnerLink().equals(partnerLink) == false) {
+			fail("PartnerLink not correct, expecting '"+partnerLink+"': "+
+							component.getPartnerLink());
+		}
+		
+		if (component.getPortType().equals(portType) == false) {
+			fail("Port type not correct, expecting '"+portType+"': "+
+							component.getPortType());
+		}
+	}
+	
+	public void testGetOperation() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String op="testOp";
+		
+		TestAbstractInteraction component=new TestAbstractInteraction(model);		
+		
+		if (component.getOperation() != null) {
+			fail("Should be null");
+		}
+		
+		component.setOperation(op);
+		
+		if (component.getOperation().equals(op) == false) {
+			fail("Operation not correct, expecting '"+op+"': "+
+							component.getOperation());
+		}
+	}
+	
+	public void testGetPortType() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String pt="testPortType";
+		
+		TestAbstractInteraction component=new TestAbstractInteraction(model);		
+		
+		if (component.getPortType() != null) {
+			fail("Should be null");
+		}
+		
+		component.setPortType(pt);
+		
+		if (component.getPortType().equals(pt) == false) {
+			fail("Port type not correct, expecting '"+pt+"': "+
+							component.getPortType());
+		}
+	}
+	
+	public void testGetPartnerLink() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String pl="testPartnerLink";
+		
+		TestAbstractInteraction component=new TestAbstractInteraction(model);		
+		
+		if (component.getPartnerLink() != null) {
+			fail("Should be null");
+		}
+		
+		component.setPartnerLink(pl);
+		
+		if (component.getPartnerLink().equals(pl) == false) {
+			fail("Partner link not correct, expecting '"+pl+"': "+
+							component.getPartnerLink());
+		}
+	}
+}

Added: trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/BPELActivityTest.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/BPELActivityTest.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/BPELActivityTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,191 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.savara.bpel.model.DefaultBPELLanguageModel;
+
+import junit.framework.TestCase;
+
+public class BPELActivityTest extends TestCase {
+
+	public void testIsActivity() {
+		TestBPELActivity act=
+			new TestBPELActivity(new DefaultBPELLanguageModel(null));
+		
+		if (act.isActivity() == false) {
+			fail("Should be an activity");
+		}
+	}
+	
+	public void testGetNameFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String name="testName";
+		
+		String xml="<activity xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\" "+
+		       "name=\""+name+"\" />";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		TestBPELActivity component=new TestBPELActivity(model, elem);		
+		
+		if (component.getName().equals(name) == false) {
+			fail("Name not correct, expecting '"+name+"': "+
+							component.getName());
+		}
+	}
+	
+	public void testGetName() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String name="testName";
+		
+		TestBPELActivity component=new TestBPELActivity(model);		
+		
+		if (component.getName() != null) {
+			fail("Should be null");
+		}
+		
+		component.setName(name);
+		
+		if (component.getName().equals(name) == false) {
+			fail("Name not correct, expecting '"+name+"': "+
+							component.getName());
+		}
+	}
+
+	public void testSuppressJoinFailureFromDOMTrue() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String value="yes";
+		
+		String xml="<activity xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\" "+
+		       "suppressJoinFailure=\""+value+"\" />";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		TestBPELActivity component=new TestBPELActivity(model, elem);		
+		
+		if (component.getSuppressJoinFailure() == false) {
+			fail("'Suppress Join Failure' not correct, expecting 'true': "+
+							component.getSuppressJoinFailure());
+		}
+	}
+	
+	public void testSuppressJoinFailureFromDOMFalse() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String value="no";
+		
+		String xml="<activity xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\" "+
+		       "suppressJoinFailure=\""+value+"\" />";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		TestBPELActivity component=new TestBPELActivity(model, elem);		
+		
+		if (component.getSuppressJoinFailure() == true) {
+			fail("'Suppress Join Failure' not correct, expecting 'false': "+
+							component.getSuppressJoinFailure());
+		}
+	}
+	
+	public void testGetSuppressJoinFailureTrue() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		TestBPELActivity component=new TestBPELActivity(model);		
+		
+		component.setSuppressJoinFailure(true);
+		
+		if (component.getSuppressJoinFailure() == false) {
+			fail("'Suppress Join Failure' not correct, expecting 'true': "+
+							component.getSuppressJoinFailure());
+		}
+	}
+	
+	public void testGetSuppressJoinFailureFalse() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		TestBPELActivity component=new TestBPELActivity(model);		
+		
+		component.setSuppressJoinFailure(false);
+		
+		if (component.getSuppressJoinFailure() == true) {
+			fail("'Suppress Join Failure' not correct, expecting 'false': "+
+							component.getSuppressJoinFailure());
+		}
+	}
+}

Added: trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/BPELElementTest.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/BPELElementTest.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/BPELElementTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,401 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.savara.bpel.model.DefaultBPELLanguageModel;
+import org.savara.bpel.model.component.BPELElement;
+import org.savara.bpel.model.component.Condition;
+import org.savara.bpel.model.component.Else;
+import org.savara.bpel.model.component.If;
+import org.savara.bpel.model.component.Sequence;
+
+import junit.framework.TestCase;
+
+public class BPELElementTest extends TestCase {
+
+	public void testFindChildElements() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<elem xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+				"<first/>"+
+				"<else/>"+
+				"<sequence/>"+
+				"<second/>"+
+				"<if/>"+
+				"</elem>";
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		TestBPELElement top=new TestBPELElement(model, elem);		
+
+		java.util.List<BPELElement> elems=
+				top.findChildElements(BPELElement.class);
+		
+		if (elems == null) {
+			fail("Null list");
+		}
+		
+		if (elems.size() != 3) {
+			fail("Expecting three child elements: "+elems.size());
+		}
+		
+		if ((elems.get(0) instanceof Else) == false) {
+			fail("Element 0 not else: "+elems.get(0));
+		}
+		
+		if ((elems.get(1) instanceof Sequence) == false) {
+			fail("Element 1 not sequence: "+elems.get(1));
+		}
+		
+		if ((elems.get(2) instanceof If) == false) {
+			fail("Element 2 not 'if': "+elems.get(2));
+		}
+
+		elems = top.findChildElements(Sequence.class);
+	
+		if (elems == null) {
+			fail("Null sequence list");
+		}
+		
+		if (elems.size() != 1) {
+			fail("Expecting one child element: "+elems.size());
+		}
+	
+		if ((elems.get(0) instanceof Sequence) == false) {
+			fail("Element 0 not sequence: "+elems.get(0));
+		}
+	}
+		
+	public void testFindChildActivity() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<elem xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+				"<first/>"+
+				"<else/>"+
+				"<sequence/>"+
+				"<second/>"+
+				"<if/>"+
+				"</elem>";
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		TestBPELElement top=new TestBPELElement(model, elem);		
+
+		BPELElement act=top.findChildActivity();
+		
+		if (act == null) {
+			fail("Null activity");
+		}
+		
+		if ((act instanceof Sequence) == false) {
+			fail("Activity not sequence");
+		}
+	}
+	
+	public void testSetChildElement() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		TestBPELElement top=new TestBPELElement(model);
+		
+		org.w3c.dom.Element newElem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+
+			newElem = builder.newDocument().createElement("newelem");
+			
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		if (top.getDOMElement().getFirstChild() != null) {
+			fail("Child element not expected");
+		}
+		
+		TestBPELElement telem=new TestBPELElement(model, newElem);
+		
+		top.setChildElement(null, telem, null);
+		
+		if (top.getDOMElement().getChildNodes().getLength() != 1) {
+			fail("Should only be 1 child node: "+top.getDOMElement().getChildNodes().getLength());
+		}
+		
+		if (top.getDOMElement().getChildNodes().item(0).getNodeName().
+						equals(newElem.getNodeName()) == false) {
+			fail("Node name of new child element not correct");
+		}
+	}
+	
+	public void testSetChildElementAtBeginning() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<elem>"+
+				"<first/>"+
+				"<second/>"+
+				"<third/>"+
+				"</elem>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		TestBPELElement top=new TestBPELElement(model, elem);
+
+		org.w3c.dom.Element newElem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+
+			newElem = builder.newDocument().createElement("newelem");
+			
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		if (top.getDOMElement().getChildNodes().getLength() != 3) {
+			fail("Should only be 3 child node: "+top.getDOMElement().getChildNodes().getLength());
+		}
+		
+		TestBPELElement telem=new TestBPELElement(model, newElem);
+		
+		top.setChildElement(null, telem, top.getDOMElement().getFirstChild());
+		
+		if (top.getDOMElement().getChildNodes().getLength() != 4) {
+			fail("Should only be 4 child node: "+top.getDOMElement().getChildNodes().getLength());
+		}
+		
+		if (top.getDOMElement().getChildNodes().item(0).getNodeName().
+						equals(newElem.getNodeName()) == false) {
+			fail("Node name of new child element not correct");
+		}
+	}
+	
+	public void testSetChildElementAtEnd() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<elem>"+
+				"<first/>"+
+				"<second/>"+
+				"<third/>"+
+				"</elem>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		TestBPELElement top=new TestBPELElement(model, elem);
+
+		org.w3c.dom.Element newElem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+
+			newElem = builder.newDocument().createElement("newelem");
+			
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		if (top.getDOMElement().getChildNodes().getLength() != 3) {
+			fail("Should only be 3 child node: "+top.getDOMElement().getChildNodes().getLength());
+		}
+		
+		TestBPELElement telem=new TestBPELElement(model, newElem);
+		
+		top.setChildElement(null, telem, null);
+		
+		if (top.getDOMElement().getChildNodes().getLength() != 4) {
+			fail("Should only be 4 child node: "+top.getDOMElement().getChildNodes().getLength());
+		}
+		
+		if (top.getDOMElement().getChildNodes().item(3).getNodeName().
+						equals(newElem.getNodeName()) == false) {
+			fail("Node name of new child element not correct");
+		}
+	}
+	
+	public void testSetChildElementReplace() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String first="first";
+		String second="second";
+		
+		String xml="<elem>"+
+				"<newelem name=\""+first+"\" />"+
+				"</elem>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		TestBPELElement top=new TestBPELElement(model, elem);
+		
+		org.w3c.dom.Element newElem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+
+			newElem = builder.newDocument().createElement("newelem");
+			newElem.setAttribute("name", second);
+			
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		if (top.getDOMElement().getFirstChild() == null) {
+			fail("First child element expected");
+		}
+		
+		if ((top.getDOMElement().getFirstChild() instanceof 
+						org.w3c.dom.Element) == false) {
+			fail("First child is not an element");
+		}
+		
+		TestBPELElement telem=new TestBPELElement(model, newElem);
+		
+		top.setChildElement((org.w3c.dom.Element)
+				top.getDOMElement().getFirstChild(),
+							telem, null);
+		
+		if (top.getDOMElement().getChildNodes().getLength() != 1) {
+			fail("Should only be 1 child node: "+top.getDOMElement().getChildNodes().getLength());
+		}
+		
+		if (top.getDOMElement().getChildNodes().item(0).getNodeName().
+						equals(newElem.getNodeName()) == false) {
+			fail("Node name of new child element not correct");
+		}
+		
+		if (((org.w3c.dom.Element)top.getDOMElement().getChildNodes().
+				item(0)).getAttribute("name").equals(second) == false) {
+			fail("Attribute is not as expected");
+		}
+	}	
+}

Added: trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/CatchAllTest.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/CatchAllTest.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/CatchAllTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.savara.bpel.model.DefaultBPELLanguageModel;
+import org.savara.bpel.model.component.CatchAll;
+import org.savara.bpel.model.component.Else;
+import org.savara.bpel.model.component.Sequence;
+
+import junit.framework.TestCase;
+
+public class CatchAllTest extends TestCase {
+
+	public void testIsActivity() {
+		CatchAll act=new CatchAll(new DefaultBPELLanguageModel(null));
+		
+		if (act.isActivity() == true) {
+			fail("Should NOT be an activity");
+		}
+	}
+	
+	public void testBuildCatchAll() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<catchAll xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">" +
+				"<sequence/></catchAll>";
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+			
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		CatchAll construct=new CatchAll(model, elem);		
+		
+		if (construct.getActivity() == null) {
+			fail("No activity");
+		}
+		
+		if ((construct.getActivity() instanceof Sequence) == false) {
+			fail("Activity is not a sequence");
+		}
+	}
+}

Added: trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/CatchTest.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/CatchTest.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/CatchTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,117 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.savara.bpel.model.DefaultBPELLanguageModel;
+import org.savara.bpel.model.component.Catch;
+import org.savara.bpel.model.component.Sequence;
+
+import junit.framework.TestCase;
+
+public class CatchTest extends TestCase {
+
+	public void testIsActivity() {
+		Catch act=new Catch(new DefaultBPELLanguageModel(null));
+		
+		if (act.isActivity() == true) {
+			fail("Should NOT be an activity");
+		}
+	}
+	
+	public void testBuildCatchAll() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String var="testVar";
+		String fault="testFault";
+
+		String xml="<catch xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\" " +
+			       "faultVariable=\""+var+"\" "+
+			       "faultName=\""+fault+"\" >"+
+				"<sequence/></catch>";
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+			
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Catch construct=new Catch(model, elem);		
+		
+		if (construct.getActivity() == null) {
+			fail("No activity");
+		}
+		
+		if ((construct.getActivity() instanceof Sequence) == false) {
+			fail("Activity is not a sequence");
+		}
+	}
+
+	public void testGetFaultVariable() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String var="testVariable";
+		
+		Catch component=new Catch(model);		
+		
+		if (component.getFaultVariable() != null) {
+			fail("Should be null");
+		}
+		
+		component.setFaultVariable(var);
+		
+		if (component.getFaultVariable().equals(var) == false) {
+			fail("Fault Variable not correct, expecting '"+var+"': "+
+							component.getFaultVariable());
+		}
+	}
+
+	public void testGetFaultName() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String fault="testFault";
+		
+		Catch component=new Catch(model);		
+		
+		if (component.getFaultName() != null) {
+			fail("Should be null");
+		}
+		
+		component.setFaultName(fault);
+		
+		if (component.getFaultName().equals(fault) == false) {
+			fail("Fault name not correct, expecting '"+fault+"': "+
+							component.getFaultName());
+		}
+	}
+}

Added: trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/CompensationHandlerTest.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/CompensationHandlerTest.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/CompensationHandlerTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.savara.bpel.model.DefaultBPELLanguageModel;
+import org.savara.bpel.model.component.CompensationHandler;
+import org.savara.bpel.model.component.Sequence;
+
+import junit.framework.TestCase;
+
+public class CompensationHandlerTest extends TestCase {
+
+	public void testIsActivity() {
+		CompensationHandler act=
+				new CompensationHandler(new DefaultBPELLanguageModel(null));
+		
+		if (act.isActivity() == true) {
+			fail("Should NOT be an activity");
+		}
+	}
+	
+	public void testBuildCompensationHandler() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<compensationHandler xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">" +
+				"<sequence/></compensationHandler>";
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+			
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		CompensationHandler construct=new CompensationHandler(model, elem);		
+		
+		if (construct.getActivity() == null) {
+			fail("No activity");
+		}
+		
+		if ((construct.getActivity() instanceof Sequence) == false) {
+			fail("Activity is not a sequence");
+		}
+	}
+}

Added: trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/ConditionTest.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/ConditionTest.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/ConditionTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,167 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.savara.bpel.model.DefaultBPELLanguageModel;
+import org.savara.bpel.model.component.Condition;
+
+import junit.framework.TestCase;
+
+public class ConditionTest extends TestCase {
+
+	public void testIsActivity() {
+		Condition act=new Condition(new DefaultBPELLanguageModel(null));
+		
+		if (act.isActivity() == true) {
+			fail("Should NOT be an activity");
+		}
+	}
+	
+	public void testGetExpression() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+		Condition condition=new Condition(model);
+		
+		String expr="Test Expression";
+		
+		if (condition.getExpression() != null) {
+			fail("Should be null");
+		}
+		
+		condition.setExpression(expr);
+		
+		String result=condition.getExpression();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(expr) == false) {
+			fail("Expression is not valid: expecting '"+
+					expr+"' but got '"+result+"'");
+		}
+	}
+	
+	public void testGetExpressionFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String expr="Test Expression";
+		
+		String xml="<condition xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+expr+"</condition>";
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Condition condition=new Condition(model, elem);		
+		
+		String result=condition.getExpression();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(expr) == false) {
+			fail("Expression is not valid: expecting '"+
+					expr+"' but got '"+result+"'");
+		}		
+	}
+
+	public void testGetExpressionLanguage() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+		Condition condition=new Condition(model);
+		
+		String lang="Test Language";
+		
+		if (condition.getExpressionLanguage() != null) {
+			fail("Should be null");
+		}
+		
+		condition.setExpressionLanguage(lang);
+		
+		String result=condition.getExpressionLanguage();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(lang) == false) {
+			fail("Expression language is not valid: expecting '"+
+					lang+"' but got '"+result+"'");
+		}
+	}
+	
+	public void testGetExpressionLanguageFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String lang="TestLanguage";
+		
+		String xml="<condition xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\"" +
+				" expressionLanguage=\""+lang+"\"></condition>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Condition condition=new Condition(model, elem);		
+		
+		String result=condition.getExpressionLanguage();
+		
+		if (result == null) {
+			fail("Expression language is null");
+		}
+		
+		if (result.equals(lang) == false) {
+			fail("Expression language is not valid: expecting '"+
+					lang+"' but got '"+result+"'");
+		}		
+	}
+}

Added: trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/ElseIfTest.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/ElseIfTest.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/ElseIfTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,91 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.savara.bpel.model.DefaultBPELLanguageModel;
+import org.savara.bpel.model.component.Elseif;
+import org.savara.bpel.model.component.Sequence;
+
+import junit.framework.TestCase;
+
+public class ElseIfTest extends TestCase {
+
+	public void testIsActivity() {
+		Elseif act=new Elseif(new DefaultBPELLanguageModel(null));
+		
+		if (act.isActivity() == true) {
+			fail("Should NOT be an activity");
+		}
+	}
+	
+	public void testBuildElseIf() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String expr="Test Expression";
+		
+		String xml="<elseif xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">" +
+				"<condition>"+expr+"</condition><sequence/></elseif>";
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+			
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Elseif elseif=new Elseif(model, elem);		
+		
+		if (elseif.getCondition() == null) {
+			fail("No condition");
+		}
+		
+		if (elseif.getActivity() == null) {
+			fail("No activity");
+		}
+		
+		String result=elseif.getCondition().getExpression();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(expr) == false) {
+			fail("Expression is not valid: expecting '"+
+					expr+"' but got '"+result+"'");
+		}				
+		
+		if ((elseif.getActivity() instanceof Sequence) == false) {
+			fail("Activity is not a sequence");
+		}
+	}
+}

Added: trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/ElseTest.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/ElseTest.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/ElseTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.savara.bpel.model.DefaultBPELLanguageModel;
+import org.savara.bpel.model.component.Else;
+import org.savara.bpel.model.component.Sequence;
+
+import junit.framework.TestCase;
+
+public class ElseTest extends TestCase {
+
+	public void testIsActivity() {
+		Else act=new Else(new DefaultBPELLanguageModel(null));
+		
+		if (act.isActivity() == true) {
+			fail("Should NOT be an activity");
+		}
+	}
+	
+	public void testBuildElse() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<else xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">" +
+				"<sequence/></else>";
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+			
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Else construct=new Else(model, elem);		
+		
+		if (construct.getActivity() == null) {
+			fail("No activity");
+		}
+		
+		if ((construct.getActivity() instanceof Sequence) == false) {
+			fail("Activity is not a sequence");
+		}
+	}
+}

Added: trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/EventHandlersTest.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/EventHandlersTest.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/EventHandlersTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,417 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.savara.bpel.model.DefaultBPELLanguageModel;
+import org.savara.bpel.model.component.BPELActivity;
+import org.savara.bpel.model.component.EventHandlers;
+import org.savara.bpel.model.component.OnAlarm;
+import org.savara.bpel.model.component.OnEvent;
+import org.savara.bpel.model.component.Receive;
+import org.savara.bpel.model.component.Scope;
+import org.savara.bpel.model.component.Sequence;
+
+import junit.framework.TestCase;
+
+public class EventHandlersTest extends TestCase {
+
+	public void testIsActivity() {
+		EventHandlers act=new EventHandlers(new DefaultBPELLanguageModel(null));
+		
+		if (act.isActivity() == true) {
+			fail("Should NOT be an activity");
+		}
+	}
+	
+	public void testEventHandlersFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<eventHandlers xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+		       "<onEvent/>"+
+		       "<onEvent/>"+
+		       "<onAlarm/>"+
+		       "</eventHandlers>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		EventHandlers component=new EventHandlers(model, elem);		
+		
+		if (component.getOnEvents().size() != 2) {
+			fail("Expecting 2 onEvent: "+
+							component.getOnEvents().size());
+		}
+		
+		if (component.getOnAlarms().size() != 1) {
+			fail("Expecting 1 onAlarm: "+
+							component.getOnAlarms().size());
+		}
+	}
+
+	public void testAddOnMessageToEventHandlersInitFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<eventHandlers xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+	       		"<targets/>"+
+	       		"<onAlarm/>"+
+	       		"<onAlarm/>"+
+	       		"</eventHandlers>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		EventHandlers component=new EventHandlers(model, elem);		
+		
+		if (component.getOnAlarms().size() != 2) {
+			fail("Expecting 2 onAlarms: "+
+							component.getOnAlarms().size());
+		}
+		
+		if (component.getOnEvents().size() != 0) {
+			fail("Expecting 0 onEvents: "+
+							component.getOnEvents().size());
+		}
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 3) {
+			fail("Three child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+
+		OnEvent sub=new OnEvent(model);
+		
+		component.addOnEvent(sub, 0);
+		
+		if (component.getOnEvents().size() != 1) {
+			fail("Expecting 1 onEvent: "+
+							component.getOnEvents().size());
+		}
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 4) {
+			fail("Four child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+
+		if (component.getDOMElement().getChildNodes().item(1).
+				getLocalName().equals(OnEvent.ONEVENT) == false) {
+			fail("Second element was not a 'onEvent': "+
+					component.getDOMElement().getChildNodes().item(1).
+									getLocalName());
+		}
+	}
+
+
+	public void testAddOnAlarmToEventHandlersInitFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<eventHandlers xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+	       		"<targets/>"+
+	       		"<onEvent/>"+
+	       		"<onEvent/>"+
+	       		"</eventHandlers>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		EventHandlers component=new EventHandlers(model, elem);		
+		
+		if (component.getOnEvents().size() != 2) {
+			fail("Expecting 2 onEvents: "+
+							component.getOnEvents().size());
+		}
+		
+		if (component.getOnAlarms().size() != 0) {
+			fail("Expecting 0 onAlarms: "+
+							component.getOnAlarms().size());
+		}
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 3) {
+			fail("Three child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+
+		OnAlarm sub=new OnAlarm(model);
+		
+		component.addOnAlarm(sub, 0);
+		
+		if (component.getOnAlarms().size() != 1) {
+			fail("Expecting 1 onAlarm: "+
+							component.getOnAlarms().size());
+		}
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 4) {
+			fail("Four child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+
+		if (component.getDOMElement().getChildNodes().item(3).
+				getLocalName().equals(OnAlarm.ONALARM) == false) {
+			fail("Second element was not a 'onAlarm': "+
+					component.getDOMElement().getChildNodes().item(3).
+									getLocalName());
+		}
+	}
+	
+	public void testGetURIOnEvent() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<process xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+				"<scope>"+
+		       		"<eventHandlers>"+
+						"<onEvent>"+
+							"<scope>"+
+				       		"<sequence>"+
+				       			"<receive/>"+
+			       			"</sequence>"+
+			       			"</scope>"+
+						"</onEvent>"+
+			       "</eventHandlers>"+
+			       "<sequence/>"+
+	       		"</scope>"+
+	       		"</process>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			e.printStackTrace();
+			fail("Failed to convert to doc");
+		}
+		
+		org.savara.bpel.model.component.Process component=
+				new org.savara.bpel.model.component.Process(model, elem);		
+		
+		BPELActivity topact=component.getActivity();
+		
+		if ((topact instanceof Scope) == false) {
+			fail("Top level activity is not scope");
+		}
+		
+		Scope scope=(Scope)topact;
+		
+		if (scope.getEventHandlers() == null) {
+			fail("Event handlers not set");
+		}
+		
+		if (scope.getEventHandlers().getOnEvents().size() != 1) {
+			fail("Event handlers should have 1 onEvent: "+scope.getEventHandlers().getOnEvents().size());
+		}
+		
+		OnEvent one=scope.getEventHandlers().getOnEvents().get(0);
+		
+		Scope innerScope=one.getScope();
+		
+		if (innerScope == null) {
+			fail("Inner scope not set");
+		}
+		
+		if ((innerScope.getActivity() instanceof Sequence) == false) {
+			fail("Inner scope activity is not a sequence");
+		}
+		
+		Sequence seq=(Sequence)innerScope.getActivity();
+		
+		if (seq.getActivities().size() != 1) {
+			fail("Expecting 1 child activities: "+
+							seq.getActivities().size());
+		}
+		
+		if ((seq.getActivities().get(0) instanceof Receive) == false) {
+			fail("First activity should be receive");
+		}
+		
+		Receive recv=(Receive)seq.getActivities().get(0);
+		
+		String uri=recv.getURI();
+		
+		if (uri == null) {
+			fail("URI is null");
+		}
+		
+		if (uri.equals("//@activity/@eventHandlers/@onEvent.0/@scope/@activity/@activities.0") == false) {
+			fail("URI is invalid: "+uri);
+		}
+	}	
+	
+	public void testGetURIOnAlarm() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<process xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+				"<scope>"+
+		       		"<eventHandlers>"+
+						"<onAlarm>"+
+							"<scope>"+
+				       		"<sequence>"+
+				       			"<receive/>"+
+			       			"</sequence>"+
+			       			"</scope>"+
+						"</onAlarm>"+
+			       "</eventHandlers>"+
+			       "<sequence/>"+
+	       		"</scope>"+
+	       		"</process>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			e.printStackTrace();
+			fail("Failed to convert to doc");
+		}
+		
+		org.savara.bpel.model.component.Process component=
+			new org.savara.bpel.model.component.Process(model, elem);		
+		
+		BPELActivity topact=component.getActivity();
+		
+		if ((topact instanceof Scope) == false) {
+			fail("Top level activity is not scope");
+		}
+		
+		Scope scope=(Scope)topact;
+		
+		if (scope.getEventHandlers() == null) {
+			fail("Event handlers not set");
+		}
+		
+		if (scope.getEventHandlers().getOnAlarms().size() != 1) {
+			fail("Event handlers should have 1 onAlarm: "+scope.getEventHandlers().getOnAlarms().size());
+		}
+		
+		OnAlarm one=scope.getEventHandlers().getOnAlarms().get(0);
+		
+		if ((one.getActivity() instanceof Scope) == false) {
+			fail("Activity is not Scope");
+		}
+		
+		Scope innerScope=(Scope)one.getActivity();
+		
+		if (innerScope == null) {
+			fail("Inner scope not set");
+		}
+		
+		if ((innerScope.getActivity() instanceof Sequence) == false) {
+			fail("Inner scope activity is not a sequence");
+		}
+		
+		Sequence seq=(Sequence)innerScope.getActivity();
+		
+		if (seq.getActivities().size() != 1) {
+			fail("Expecting 1 child activities: "+
+							seq.getActivities().size());
+		}
+		
+		if ((seq.getActivities().get(0) instanceof Receive) == false) {
+			fail("First activity should be receive");
+		}
+		
+		Receive recv=(Receive)seq.getActivities().get(0);
+		
+		String uri=recv.getURI();
+		
+		if (uri == null) {
+			fail("URI is null");
+		}
+		
+		if (uri.equals("//@activity/@eventHandlers/@onAlarm.0/@scope/@activity/@activities.0") == false) {
+			fail("URI is invalid: "+uri);
+		}
+	}	
+}

Added: trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/ExitTest.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/ExitTest.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/ExitTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.DefaultBPELLanguageModel;
+import org.savara.bpel.model.component.Exit;
+
+import junit.framework.TestCase;
+
+public class ExitTest extends TestCase {
+
+	public void testIsActivity() {
+		Exit act=
+			new Exit(new DefaultBPELLanguageModel(null));
+		
+		if (act.isActivity() == false) {
+			fail("Should be an activity");
+		}
+	}
+}

Added: trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/FaultHandlersTest.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/FaultHandlersTest.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/FaultHandlersTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,396 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.savara.bpel.model.DefaultBPELLanguageModel;
+import org.savara.bpel.model.component.BPELActivity;
+import org.savara.bpel.model.component.Catch;
+import org.savara.bpel.model.component.CatchAll;
+import org.savara.bpel.model.component.FaultHandlers;
+import org.savara.bpel.model.component.Receive;
+import org.savara.bpel.model.component.Sequence;
+
+import junit.framework.TestCase;
+
+public class FaultHandlersTest extends TestCase {
+
+	public void testIsActivity() {
+		FaultHandlers act=new FaultHandlers(new DefaultBPELLanguageModel(null));
+		
+		if (act.isActivity() == true) {
+			fail("Should NOT be an activity");
+		}
+	}
+	
+	public void testFaultHandlersCatchFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<faultHandlers xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+				"<catch/>"+
+				"<catch/>"+
+		       "</faultHandlers>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		FaultHandlers component=new FaultHandlers(model, elem);		
+		
+		if (component.getCatchAll() != null) {
+			fail("CatchAll path should be null");
+		}
+		
+		if (component.getCatchPaths().size() != 2) {
+			fail("Should have 2 catch paths: "+component.getCatchPaths().size());
+		}
+	}
+
+	public void testFaultHandlersCatchAllFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<faultHandlers xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+				"<catchAll/>"+
+		       "</faultHandlers>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		FaultHandlers component=new FaultHandlers(model, elem);		
+		
+		if (component.getCatchAll() == null) {
+			fail("CatchAll path should NOT be null");
+		}
+		
+		if (component.getCatchPaths().size() != 0) {
+			fail("Should have 0 catch paths: "+component.getCatchPaths().size());
+		}
+	}
+	
+	public void testAddCatch() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<faultHandlers xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+		       "</faultHandlers>";
+		
+		org.w3c.dom.Element ifelem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			ifelem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		FaultHandlers component=new FaultHandlers(model, ifelem);
+
+		if (component.getCatchPaths().size() != 0) {
+			fail("Should be no catch paths");
+		}
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 0) {
+			fail("Zero child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+		
+		Sequence seq=new Sequence(model);
+		Catch elem=new Catch(model);
+		elem.setActivity(seq);
+		
+		component.addCatch(elem);
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 1) {
+			fail("One child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+		
+		if (component.getDOMElement().getChildNodes().item(0).
+				getLocalName().equals(Catch.CATCH) == false) {
+			fail("First element was not a catch: "+
+					component.getDOMElement().getChildNodes().item(0).
+									getLocalName());
+		}
+	}	
+	
+	public void testAddCatchInsertBeforeCatchAll() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<faultHandlers xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+		       "<catchAll>"+
+		       "<sequence/>"+
+		       "</catchAll>"+
+		       "</faultHandlers>";
+		
+		org.w3c.dom.Element ifelem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			ifelem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		FaultHandlers component=new FaultHandlers(model, ifelem);
+
+		if (component.getCatchPaths().size() != 0) {
+			fail("Should be no catch paths");
+		}
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 1) {
+			fail("One child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+		
+		Sequence seq=new Sequence(model);
+		Catch catchElem=new Catch(model);
+		catchElem.setActivity(seq);
+		
+		component.addCatch(catchElem);
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 2) {
+			fail("Two child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+		
+		if (component.getDOMElement().getChildNodes().item(0).
+				getLocalName().equals(Catch.CATCH) == false) {
+			fail("First element was not a catch: "+
+					component.getDOMElement().getChildNodes().item(0).
+									getLocalName());
+		}
+	}	
+	
+	public void testGetURICatch() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<process xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+	       		"<faultHandlers>"+
+					"<catch>"+
+			       		"<sequence>"+
+			       			"<receive/>"+
+		       			"</sequence>"+
+					"</catch>"+
+		       "</faultHandlers>"+
+	       		"</process>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			e.printStackTrace();
+			fail("Failed to convert to doc");
+		}
+		
+		org.savara.bpel.model.component.Process component=
+			new org.savara.bpel.model.component.Process(model, elem);		
+		
+		FaultHandlers fhs=component.getFaultHandlers();
+		
+		if (fhs == null) {
+			fail("No fault handlers");
+		}
+		
+		if (fhs.getCatchPaths().size() != 1) {
+			fail("Expecting one catch: "+fhs.getCatchPaths().size());
+		}
+		
+		Catch c=fhs.getCatchPaths().get(0);
+		
+		BPELActivity act=c.getActivity();
+		
+		if ((act instanceof Sequence) == false) {
+			fail("Activity is not a sequence");
+		}
+		
+		Sequence seq=(Sequence)act;
+		
+		if (seq.getActivities().size() != 1) {
+			fail("Expecting 1 child activities: "+
+							seq.getActivities().size());
+		}
+		
+		if ((seq.getActivities().get(0) instanceof Receive) == false) {
+			fail("First activity should be receive");
+		}
+		
+		Receive recv=(Receive)seq.getActivities().get(0);
+		
+		String uri=recv.getURI();
+		
+		if (uri == null) {
+			fail("URI is null");
+		}
+		
+		if (uri.equals("//@faultHandlers/@catch.0/@activity/@activities.0") == false) {
+			fail("URI is invalid: "+uri);
+		}
+	}	
+
+	public void testGetURICatchAll() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<process xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+	       		"<faultHandlers>"+
+					"<catchAll>"+
+			       		"<sequence>"+
+			       			"<receive/>"+
+		       			"</sequence>"+
+					"</catchAll>"+
+		       "</faultHandlers>"+
+	       		"</process>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			e.printStackTrace();
+			fail("Failed to convert to doc");
+		}
+		
+		org.savara.bpel.model.component.Process component=
+			new org.savara.bpel.model.component.Process(model, elem);		
+		
+		FaultHandlers fhs=component.getFaultHandlers();
+		
+		if (fhs == null) {
+			fail("No fault handlers");
+		}
+		
+		if (fhs.getCatchAll() == null) {
+			fail("CatchAll not set");
+		}
+		
+		CatchAll c=fhs.getCatchAll();
+		
+		BPELActivity act=c.getActivity();
+		
+		if ((act instanceof Sequence) == false) {
+			fail("Activity is not a sequence");
+		}
+		
+		Sequence seq=(Sequence)act;
+		
+		if (seq.getActivities().size() != 1) {
+			fail("Expecting 1 child activities: "+
+							seq.getActivities().size());
+		}
+		
+		if ((seq.getActivities().get(0) instanceof Receive) == false) {
+			fail("First activity should be receive");
+		}
+		
+		Receive recv=(Receive)seq.getActivities().get(0);
+		
+		String uri=recv.getURI();
+		
+		if (uri == null) {
+			fail("URI is null");
+		}
+		
+		if (uri.equals("//@faultHandlers/@catchAll/@activity/@activities.0") == false) {
+			fail("URI is invalid: "+uri);
+		}
+	}	
+}

Added: trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/FlowTest.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/FlowTest.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/FlowTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,398 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.savara.bpel.model.DefaultBPELLanguageModel;
+import org.savara.bpel.model.component.Flow;
+import org.savara.bpel.model.component.Link;
+import org.savara.bpel.model.component.While;
+
+import junit.framework.TestCase;
+
+public class FlowTest extends TestCase {
+
+	public void testIsActivity() {
+		Flow act=new Flow(new DefaultBPELLanguageModel(null));
+		
+		if (act.isActivity() == false) {
+			fail("Should be an activity");
+		}
+	}
+	
+	public void testFlowFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String link1="link1Name";
+		String link2="link2Name";
+		
+		String xml="<flow xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+				"<links>"+
+				"<link name=\""+link1+"\" />"+
+				"<link name=\""+link2+"\" />"+
+				"</links>"+
+		       "<if/>"+
+		       "<if/>"+
+		       "</flow>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Flow component=new Flow(model, elem);		
+		
+		if (component.getLinks().size() != 2) {
+			fail("Expecting 2 child links: "+
+							component.getLinks().size());
+		}
+		
+		if (component.getLinks().get(0).getName().equals(link1) == false) {
+			fail("First link name incorrect");
+		}
+		
+		if (component.getLinks().get(1).getName().equals(link2) == false) {
+			fail("Second link name incorrect");
+		}
+		
+		if (component.getActivities().size() != 2) {
+			fail("Expecting 2 child activities: "+
+							component.getActivities().size());
+		}
+	}
+
+	public void testAddLinkToFlowFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String link1="link1Name";
+		
+		String xml="<flow xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+		       "<if/>"+
+		       "</flow>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Flow component=new Flow(model, elem);
+		
+		if (component.getLinks().size() != 0) {
+			fail("Should be no links");
+		}
+		
+		org.w3c.dom.Element links=
+				component.findChildElement(Flow.LINKS);
+		
+		if (links != null) {
+			fail("Links element should not be found");
+		}
+
+		Link l1=new Link(model);
+		l1.setName(link1);
+		
+		component.addLink(l1, -1);
+		
+		links = component.findChildElement(Flow.LINKS);
+
+		if (links == null) {
+			fail("Links element not found");
+		}
+	}
+
+	public void testRemoveLinkFromFlowFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String link1="link1Name";
+		
+		String xml="<flow xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+				"<links>"+
+				"<link name=\""+link1+"\" />"+
+				"</links>"+
+		       "<if/>"+
+		       "</flow>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Flow component=new Flow(model, elem);
+		
+		if (component.getLinks().size() != 1) {
+			fail("Should be one link: "+component.getLinks().size());
+		}
+		
+		org.w3c.dom.Element links=
+				component.findChildElement(Flow.LINKS);
+		
+		if (links == null) {
+			fail("Links element is null");
+		}
+
+		Link l1=component.getLinks().get(0);
+		
+		component.removeLink(l1);
+		
+		links = component.findChildElement(Flow.LINKS);
+		
+		if (links != null) {
+			fail("Links element should now be null");
+		}
+	}
+
+	public void testAddFirstActToFlowInitFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<flow xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+	       		"<targets/>"+
+	       		"<if/>"+
+	       		"<if/>"+
+	       		"</flow>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Flow component=new Flow(model, elem);		
+		
+		if (component.getActivities().size() != 2) {
+			fail("Expecting 2 child activities: "+
+							component.getActivities().size());
+		}
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 3) {
+			fail("Three child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+
+		While sub=new While(model);
+		
+		component.addActivity(sub, 0);
+		
+		if (component.getActivities().size() != 3) {
+			fail("Expecting 3 child activities: "+
+							component.getActivities().size());
+		}
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 4) {
+			fail("Four child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+
+		if (component.getDOMElement().getChildNodes().item(1).
+				getLocalName().equals(While.WHILE) == false) {
+			fail("Second element was not a 'while': "+
+					component.getDOMElement().getChildNodes().item(1).
+									getLocalName());
+		}
+	}
+
+	public void testAddSecondActToFlowInitFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<flow xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+	       		"<targets/>"+
+	       		"<if/>"+
+	       		"<if/>"+
+	       		"</flow>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Flow component=new Flow(model, elem);		
+		
+		if (component.getActivities().size() != 2) {
+			fail("Expecting 2 child activities: "+
+							component.getActivities().size());
+		}
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 3) {
+			fail("Three child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+
+		While sub=new While(model);
+		
+		component.addActivity(sub, 1);
+		
+		if (component.getActivities().size() != 3) {
+			fail("Expecting 3 child activities: "+
+							component.getActivities().size());
+		}
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 4) {
+			fail("Four child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+
+		if (component.getDOMElement().getChildNodes().item(2).
+				getLocalName().equals(While.WHILE) == false) {
+			fail("Second element was not a 'while': "+
+					component.getDOMElement().getChildNodes().item(2).
+									getLocalName());
+		}
+	}
+
+	public void testAddLastActToFlowInitFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<flow xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+	       		"<targets/>"+
+	       		"<if/>"+
+	       		"<if/>"+
+	       		"</flow>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Flow component=new Flow(model, elem);		
+		
+		if (component.getActivities().size() != 2) {
+			fail("Expecting 2 child activities: "+
+							component.getActivities().size());
+		}
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 3) {
+			fail("Three child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+
+		While sub=new While(model);
+		
+		component.addActivity(sub, -1);
+		
+		if (component.getActivities().size() != 3) {
+			fail("Expecting 3 child activities: "+
+							component.getActivities().size());
+		}
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 4) {
+			fail("Four child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+
+		if (component.getDOMElement().getChildNodes().item(3).
+				getLocalName().equals(While.WHILE) == false) {
+			fail("Second element was not a 'while': "+
+					component.getDOMElement().getChildNodes().item(3).
+									getLocalName());
+		}
+	}
+}

Added: trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/ForEachTest.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/ForEachTest.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/ForEachTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,217 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.savara.bpel.model.DefaultBPELLanguageModel;
+import org.savara.bpel.model.component.BPELActivity;
+import org.savara.bpel.model.component.ForEach;
+import org.savara.bpel.model.component.Process;
+import org.savara.bpel.model.component.Receive;
+import org.savara.bpel.model.component.Scope;
+import org.savara.bpel.model.component.Sequence;
+
+import junit.framework.TestCase;
+
+public class ForEachTest extends TestCase {
+
+	public void testIsActivity() {
+		ForEach act=new ForEach(new DefaultBPELLanguageModel(null));
+		
+		if (act.isActivity() == false) {
+			fail("Should be an activity");
+		}
+	}
+	
+	public void testForEachFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<forEach xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+			"<startCounterValue/>"+
+			"<finalCounterValue/>"+
+			"<completionCondition/>"+
+			"<scope/>"+
+			"</forEach>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		ForEach component=new ForEach(model, elem);		
+		
+		if (component.getScope() == null) {
+			fail("Scope not set");
+		}
+	}
+
+	public void testSetScopeInInitFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<forEach xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+			"<startCounterValue/>"+
+			"<finalCounterValue/>"+
+			"<completionCondition/>"+
+			"</forEach>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		ForEach component=new ForEach(model, elem);		
+		
+		if (component.getScope() == null) {
+			fail("Scope should not be null");
+		}
+		
+		Scope scope=new Scope(model);
+		component.setScope(scope);
+		
+		if (component.getScope() == null) {
+			fail("Scope should still not be null");
+		}
+
+		if (component.getDOMElement().getChildNodes().getLength() != 4) {
+			fail("Four child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+
+		if (component.getDOMElement().getChildNodes().item(3).
+				getLocalName().equals(Scope.SCOPE) == false) {
+			fail("Second element was not a 'scope': "+
+					component.getDOMElement().getChildNodes().item(3).
+									getLocalName());
+		}
+	}
+	
+	public void testGetURI() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<process xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+		       		"<forEach xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+						"<startCounterValue/>"+
+						"<finalCounterValue/>"+
+						"<completionCondition/>"+
+						"<scope>"+
+				       		"<sequence>"+
+				       			"<receive/>"+
+			       			"</sequence>"+
+		       			"</scope>"+
+					"</forEach>"+
+			       "<sequence/>"+
+	       		"</process>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			e.printStackTrace();
+			fail("Failed to convert to doc");
+		}
+		
+		Process component=new Process(model, elem);		
+		
+		BPELActivity topact=component.getActivity();
+		
+		if ((topact instanceof ForEach) == false) {
+			fail("Top level activity is not ForEach");
+		}
+		
+		ForEach fe=(ForEach)topact;
+		
+		Scope innerScope=fe.getScope();
+		
+		if (innerScope == null) {
+			fail("Inner scope not set");
+		}
+		
+		if ((innerScope.getActivity() instanceof Sequence) == false) {
+			fail("Inner scope activity is not a sequence");
+		}
+		
+		Sequence seq=(Sequence)innerScope.getActivity();
+		
+		if (seq.getActivities().size() != 1) {
+			fail("Expecting 1 child activities: "+
+							seq.getActivities().size());
+		}
+		
+		if ((seq.getActivities().get(0) instanceof Receive) == false) {
+			fail("First activity should be receive");
+		}
+		
+		Receive recv=(Receive)seq.getActivities().get(0);
+		
+		String uri=recv.getURI();
+		
+		if (uri == null) {
+			fail("URI is null");
+		}
+		
+		if (uri.equals("//@activity/@scope/@activity/@activities.0") == false) {
+			fail("URI is invalid: "+uri);
+		}
+	}	
+}

Added: trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/IfTest.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/IfTest.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/IfTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,1192 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.savara.bpel.model.DefaultBPELLanguageModel;
+import org.savara.bpel.model.component.BPELActivity;
+import org.savara.bpel.model.component.Condition;
+import org.savara.bpel.model.component.Else;
+import org.savara.bpel.model.component.Elseif;
+import org.savara.bpel.model.component.If;
+import org.savara.bpel.model.component.Process;
+import org.savara.bpel.model.component.Receive;
+import org.savara.bpel.model.component.Reply;
+import org.savara.bpel.model.component.Sequence;
+import org.savara.bpel.model.component.Throw;
+
+import junit.framework.TestCase;
+
+public class IfTest extends TestCase {
+
+	public void testIsActivity() {
+		If act=new If(new DefaultBPELLanguageModel(null));
+		
+		if (act.isActivity() == false) {
+			fail("Should be an activity");
+		}
+	}
+	
+	public void testIfFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String expr1="Test Expression 1";
+		
+		String xml="<if xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+		       "<condition>"+expr1+"</condition>"+
+		       "<sequence/>"+
+		       "</if>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		If component=new If(model, elem);		
+		
+		if (component.getCondition() == null) {
+			fail("Condition not set");
+		}
+		
+		String result=component.getCondition().getExpression();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(expr1) == false) {
+			fail("Expression is not valid: expecting '"+
+					expr1+"' but got '"+result+"'");
+		}
+		
+		if (component.getActivity() == null) {
+			fail("Activity not set");
+		}
+		
+		if ((component.getActivity() instanceof Sequence) == false) {
+			fail("Activity not a sequence");
+		}
+		
+		if (component.getElsePath() != null) {
+			fail("Else path should be null");
+		}
+		
+		if (component.getElseIfPaths().size() > 0) {
+			fail("No elseif paths should be set");
+		}
+	}
+
+	public void testIfElseFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String expr1="Test Expression 1";
+		
+		String xml="<if xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+		       "<condition>"+expr1+"</condition>"+
+		       "<sequence/>"+
+		       "<else>"+
+		       "<sequence/>"+
+		       "</else>"+
+		       "</if>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		If component=new If(model, elem);		
+		
+		if (component.getCondition() == null) {
+			fail("Condition not set");
+		}
+		
+		String result=component.getCondition().getExpression();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(expr1) == false) {
+			fail("Expression is not valid: expecting '"+
+					expr1+"' but got '"+result+"'");
+		}
+		
+		if (component.getActivity() == null) {
+			fail("Activity not set");
+		}
+		
+		if ((component.getActivity() instanceof Sequence) == false) {
+			fail("Activity not a sequence");
+		}
+		
+		if (component.getElsePath() == null) {
+			fail("Else path is not set");
+		}
+		
+		if ((component.getElsePath().getActivity() instanceof Sequence) == false) {
+			fail("Else path Activity not a sequence");
+		}
+		
+	}
+
+	public void testIfElseIfsElseFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String expr1="Test Expression 1";
+		String expr2="Test Expression 2";
+		String expr3="Test Expression 3";
+		
+		String xml="<if xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+		       "<condition>"+expr1+"</condition>"+
+		       "<sequence/>"+
+		       "<elseif>"+
+		       "<condition>"+expr2+"</condition>"+
+		       "<sequence/>"+
+		       "</elseif>"+
+		       "<elseif>"+
+		       "<condition>"+expr3+"</condition>"+
+		       "<sequence/>"+
+		       "</elseif>"+
+		       "<else>"+
+		       "<sequence/>"+
+		       "</else>"+
+		       "</if>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		If component=new If(model, elem);		
+		
+		if (component.getCondition() == null) {
+			fail("Condition not set");
+		}
+		
+		String result=component.getCondition().getExpression();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(expr1) == false) {
+			fail("Expression is not valid: expecting '"+
+					expr1+"' but got '"+result+"'");
+		}
+		
+		if (component.getActivity() == null) {
+			fail("Activity not set");
+		}
+		
+		if ((component.getActivity() instanceof Sequence) == false) {
+			fail("Activity not a sequence");
+		}
+		
+		if (component.getElsePath() == null) {
+			fail("Else path is not set");
+		}
+		
+		if ((component.getElsePath().getActivity() instanceof Sequence) == false) {
+			fail("Else path Activity not a sequence");
+		}
+		
+		if (component.getElseIfPaths().size() != 2) {
+			fail("Two elseif paths expected: "+component.getElseIfPaths().size());
+		}
+		
+		if (component.getElseIfPaths().get(0).getCondition() == null) {
+			fail("Elseif 0 no condition");
+		}
+		
+		result=component.getElseIfPaths().get(0).getCondition().getExpression();
+		
+		if (result == null) {
+			fail("Elseif 0 Expression is null");
+		}
+		
+		if (result.equals(expr2) == false) {
+			fail("Elseif 0 Expression is not valid: expecting '"+
+					expr2+"' but got '"+result+"'");
+		}
+
+		if (component.getElseIfPaths().get(0).getActivity() == null) {
+			fail("Elseif 0 no activity");
+		}
+		
+		if ((component.getElseIfPaths().get(0).getActivity() instanceof Sequence) == false) {
+			fail("Elseif 0 Activity not a sequence");
+		}
+
+		if (component.getElseIfPaths().get(1).getCondition() == null) {
+			fail("Elseif 1 no condition");
+		}
+
+		result=component.getElseIfPaths().get(1).getCondition().getExpression();
+		
+		if (result == null) {
+			fail("Elseif 1 Expression is null");
+		}
+		
+		if (result.equals(expr3) == false) {
+			fail("Elseif 1 Expression is not valid: expecting '"+
+					expr3+"' but got '"+result+"'");
+		}
+
+		if (component.getElseIfPaths().get(1).getActivity() == null) {
+			fail("Elseif 1 no activity");
+		}
+		
+		if ((component.getElseIfPaths().get(1).getActivity() instanceof Sequence) == false) {
+			fail("Elseif 1 Activity not a sequence");
+		}
+	}
+	
+	public void testSetConditionNew() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String expr1="Test Expression 1";
+		
+		String xml="<condition xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+		       expr1+
+		       "</condition>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Condition condition=new Condition(model, elem);
+		
+		If component=new If(model);
+		
+		component.setCondition(condition);
+		
+		if (component.getCondition() == null) {
+			fail("Condition not set");
+		}
+		
+		String result=component.getCondition().getExpression();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(expr1) == false) {
+			fail("Expression is not valid: expecting '"+
+					expr1+"' but got '"+result+"'");
+		}
+	}	
+	
+	public void testSetConditionReplace() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String expr1="Test Expression 1";
+		String expr2="Test Expression 2";
+		
+		String xml1="<condition xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+	       		expr1+
+	       		"</condition>";
+	
+		String xml2="<condition xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+	       		expr2+
+	       		"</condition>";
+	
+		org.w3c.dom.Element elem1=null;
+		org.w3c.dom.Element elem2=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml1.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem1 = doc.getDocumentElement();
+			
+			is.close();
+			
+			is=new java.io.ByteArrayInputStream(xml2.getBytes());
+			
+			doc=builder.parse(is);
+			elem2 = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Condition condition1=new Condition(model, elem1);
+		
+		If component=new If(model);
+		
+		component.setCondition(condition1);
+		
+		if (component.getCondition() == null) {
+			fail("Condition not set");
+		}
+		
+		String result=component.getCondition().getExpression();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(expr1) == false) {
+			fail("Expression1 is not valid: expecting '"+
+					expr1+"' but got '"+result+"'");
+		}
+
+		Condition condition2=new Condition(model, elem2);
+		
+		component.setCondition(condition2);
+		
+		if (component.getCondition() == null) {
+			fail("Condition not set");
+		}
+		
+		result=component.getCondition().getExpression();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(expr2) == false) {
+			fail("Expression2 is not valid: expecting '"+
+					expr2+"' but got '"+result+"'");
+		}
+	}	
+	
+	public void testSetActivityInsertBeforeElse() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<if xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+		       "<condition/>"+
+		       "<else>"+
+		       "<sequence/>"+
+		       "</else>"+
+		       "</if>";
+		
+		org.w3c.dom.Element ifelem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			ifelem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		If component=new If(model, ifelem);
+
+		if (component.getActivity() != null) {
+			fail("Activity should be null");
+		}
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 2) {
+			fail("Two child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+		
+		Sequence seq=new Sequence(model);
+		
+		component.setActivity(seq);
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 3) {
+			fail("Three child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+		
+		if (component.getDOMElement().getChildNodes().item(1).
+				getLocalName().equals(Sequence.SEQUENCE) == false) {
+			fail("Second element was not a sequence: "+
+					component.getDOMElement().getChildNodes().item(1).
+									getLocalName());
+		}
+	}	
+	
+	public void testSetConditionInsertBeforeElse() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<if xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+		       "<sources/>"+
+		       "<else>"+
+		       "<sequence/>"+
+		       "</else>"+
+		       "</if>";
+		
+		org.w3c.dom.Element ifelem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			ifelem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		If component=new If(model, ifelem);
+
+		String expr1="Test Expression 1";
+
+		Condition cond=new Condition(model);
+		cond.setExpression(expr1);
+		
+		component.setCondition(cond);
+		
+		String result=component.getCondition().getExpression();
+		
+		if (result == null) {
+			fail("Expression not set");
+		}
+		
+		if (result.equals(expr1) == false) {
+			fail("Expression not same");
+		}
+		
+		// Check position of condition
+		org.w3c.dom.NodeList nl=component.getDOMElement().getChildNodes();
+		
+		if (nl.item(1).getLocalName().equals(Condition.CONDITION) == false) {
+			fail("Second child not is not condition: "+nl.item(1).getLocalName());
+		}
+	}	
+
+	public void testSetActivityInsertBeforeElseIf() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<if xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+		       "<condition/>"+
+		       "<elseif>"+
+		       "<condition/>"+
+		       "<sequence/>"+
+		       "</elseif>"+
+		       "<else>"+
+		       "<sequence/>"+
+		       "</else>"+
+		       "</if>";
+		
+		org.w3c.dom.Element ifelem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			ifelem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		If component=new If(model, ifelem);
+
+		if (component.getActivity() != null) {
+			fail("Activity should be null");
+		}
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 3) {
+			fail("Three child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+		
+		Sequence seq=new Sequence(model);
+		
+		component.setActivity(seq);
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 4) {
+			fail("Four child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+		
+		if (component.getDOMElement().getChildNodes().item(1).
+				getLocalName().equals(Sequence.SEQUENCE) == false) {
+			fail("Second element was not a sequence: "+
+					component.getDOMElement().getChildNodes().item(1).
+									getLocalName());
+		}
+	}	
+	
+	public void testAddElseIf() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<if xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+		       "<condition/>"+
+		       "<sequence/>"+
+		       "</if>";
+		
+		org.w3c.dom.Element ifelem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			ifelem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		If component=new If(model, ifelem);
+
+		if (component.getElseIfPaths().size() != 0) {
+			fail("Should be no elseif paths");
+		}
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 2) {
+			fail("Two child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+		
+		Sequence seq=new Sequence(model);
+		Elseif elseif=new Elseif(model);
+		elseif.setActivity(seq);
+		
+		component.addElseIfPath(elseif);
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 3) {
+			fail("Three child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+		
+		if (component.getDOMElement().getChildNodes().item(2).
+				getLocalName().equals(Elseif.ELSEIF) == false) {
+			fail("Third element was not an elseif: "+
+					component.getDOMElement().getChildNodes().item(2).
+									getLocalName());
+		}
+	}	
+	
+	public void testAddElseIfInsertBeforeElse() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<if xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+		       "<condition/>"+
+		       "<sequence/>"+
+		       "<else>"+
+		       "<sequence/>"+
+		       "</else>"+
+		       "</if>";
+		
+		org.w3c.dom.Element ifelem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			ifelem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		If component=new If(model, ifelem);
+
+		if (component.getElseIfPaths().size() != 0) {
+			fail("Should be no elseif paths");
+		}
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 3) {
+			fail("Three child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+		
+		Sequence seq=new Sequence(model);
+		Elseif elseif=new Elseif(model);
+		elseif.setActivity(seq);
+		
+		component.addElseIfPath(elseif);
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 4) {
+			fail("Four child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+		
+		if (component.getDOMElement().getChildNodes().item(2).
+				getLocalName().equals(Elseif.ELSEIF) == false) {
+			fail("Third element was not an elseif: "+
+					component.getDOMElement().getChildNodes().item(2).
+									getLocalName());
+		}
+	}	
+
+	public void testSetElseNew() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<if xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+		       "<condition/>"+
+		       "<sequence/>"+
+		       "</if>";
+		
+		org.w3c.dom.Element ifelem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			ifelem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		If component=new If(model, ifelem);
+
+		if (component.getElsePath() != null) {
+			fail("Should be no else path");
+		}
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 2) {
+			fail("Two child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+		
+		Sequence seq=new Sequence(model);
+		Else elseElem=new Else(model);
+		elseElem.setActivity(seq);
+		
+		component.setElsePath(elseElem);
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 3) {
+			fail("Three child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+		
+		if (component.getDOMElement().getChildNodes().item(2).
+				getLocalName().equals(Else.ELSE) == false) {
+			fail("Third element was not an else: "+
+					component.getDOMElement().getChildNodes().item(2).
+									getLocalName());
+		}
+	}	
+	
+
+	public void testSetElseReplace() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<if xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+		       "<condition/>"+
+		       "<sequence/>"+
+		       "<else>"+
+		       "<sequence/>"+
+		       "</else>"+
+		       "</if>";
+		
+		org.w3c.dom.Element ifelem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			ifelem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		If component=new If(model, ifelem);
+
+		if (component.getElsePath() == null) {
+			fail("Should have else path");
+		}
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 3) {
+			fail("Three child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+		
+		If sub=new If(model);
+		Else elseElem=new Else(model);
+		elseElem.setActivity(sub);
+		
+		component.setElsePath(elseElem);
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 3) {
+			fail("Three child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+		
+		if (component.getDOMElement().getChildNodes().item(2).
+				getLocalName().equals(Else.ELSE) == false) {
+			fail("Third element was not an else: "+
+					component.getDOMElement().getChildNodes().item(2).
+									getLocalName());
+		}
+
+		if (component.getDOMElement().getChildNodes().item(2).getFirstChild() == null) {
+			fail("Third element has no child");
+		}
+
+		if (component.getDOMElement().getChildNodes().item(2).getFirstChild().
+				getLocalName().equals(If.IF) == false) {
+			fail("Third element child was not an if: "+
+					component.getDOMElement().getChildNodes().item(2).
+							getFirstChild().getLocalName());
+		}
+	}	
+	
+	public void testGetURIIf() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<process xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+					"<sequence>"+
+		       		"<if xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+				       "<condition/>"+
+				       		"<sequence>"+
+				       			"<receive/>"+
+			       			"</sequence>"+
+				       "<elseif>"+
+				       "<condition/>"+
+			       			"<sequence>"+
+			       				"<invoke/>"+
+			       			"</sequence>"+
+				       "</elseif>"+
+				       "<elseif>"+
+				       "<condition/>"+
+		       				"<sequence>"+
+		       					"<reply/>"+
+		       				"</sequence>"+
+				       "</elseif>"+
+				       "<else>"+
+		       				"<sequence>"+
+		       					"<throw/>"+
+		       				"</sequence>"+
+				       "</else>"+
+				     "</if>"+
+			       "</sequence>"+
+	       		"</process>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			e.printStackTrace();
+			fail("Failed to convert to doc");
+		}
+		
+		org.savara.bpel.model.component.Process component=
+			new org.savara.bpel.model.component.Process(model, elem);		
+		
+		BPELActivity topact=component.getActivity();
+		
+		if ((topact instanceof Sequence) == false) {
+			fail("Top level activity is not Sequence");
+		}
+		
+		Sequence seq=(Sequence)topact;
+		
+		if (seq.getActivities().size() != 1) {
+			fail("Should have 1 activity: "+seq.getActivities().size());
+		}
+		
+		if ((seq.getActivities().get(0) instanceof If) == false) {
+			fail("Activty should be If");
+		}
+		
+		If ifelem=(If)seq.getActivities().get(0);
+		
+		if ((ifelem.getActivity() instanceof Sequence) == false) {
+			fail("Inner scope activity is not a sequence");
+		}
+		
+		Sequence innerseq=(Sequence)ifelem.getActivity();
+		
+		if (innerseq.getActivities().size() != 1) {
+			fail("Expecting 1 child activities: "+
+					innerseq.getActivities().size());
+		}
+		
+		if ((innerseq.getActivities().get(0) instanceof Receive) == false) {
+			fail("First activity should be receive");
+		}
+		
+		Receive recv=(Receive)innerseq.getActivities().get(0);
+		
+		String uri=recv.getURI();
+		
+		if (uri == null) {
+			fail("URI is null");
+		}
+		
+		if (uri.equals("//@activity/@activities.0/@activity/@activities.0") == false) {
+			fail("URI is invalid: "+uri);
+		}
+	}	
+
+	public void testGetURIIfElseIf() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<process xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+					"<sequence>"+
+		       		"<if xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+				       "<condition/>"+
+				       		"<sequence>"+
+				       			"<receive/>"+
+			       			"</sequence>"+
+				       "<elseif>"+
+				       "<condition/>"+
+			       			"<sequence>"+
+			       				"<invoke/>"+
+			       			"</sequence>"+
+				       "</elseif>"+
+				       "<elseif>"+
+				       "<condition/>"+
+		       				"<sequence>"+
+		       					"<reply/>"+
+		       				"</sequence>"+
+				       "</elseif>"+
+				       "<else>"+
+		       				"<sequence>"+
+		       					"<throw/>"+
+		       				"</sequence>"+
+				       "</else>"+
+				     "</if>"+
+			       "</sequence>"+
+	       		"</process>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			e.printStackTrace();
+			fail("Failed to convert to doc");
+		}
+		
+		Process component=new Process(model, elem);		
+		
+		BPELActivity topact=component.getActivity();
+		
+		if ((topact instanceof Sequence) == false) {
+			fail("Top level activity is not Sequence");
+		}
+		
+		Sequence seq=(Sequence)topact;
+		
+		if (seq.getActivities().size() != 1) {
+			fail("Should have 1 activity: "+seq.getActivities().size());
+		}
+		
+		if ((seq.getActivities().get(0) instanceof If) == false) {
+			fail("Activty should be If");
+		}
+		
+		If ifelem=(If)seq.getActivities().get(0);
+
+		if (ifelem.getElseIfPaths().size() != 2) {
+			fail("Expecting 2 elseIf paths: "+ifelem.getElseIfPaths().size());
+		}
+		
+		Elseif eif=ifelem.getElseIfPaths().get(1);
+		
+		if ((eif.getActivity() instanceof Sequence) == false) {
+			fail("ElseIf activity not a sequence");
+		}
+		
+		Sequence innerseq=(Sequence)eif.getActivity();
+		
+		if (innerseq.getActivities().size() != 1) {
+			fail("Expecting 1 child activities: "+
+					innerseq.getActivities().size());
+		}
+		
+		if ((innerseq.getActivities().get(0) instanceof Reply) == false) {
+			fail("First activity should be Reply");
+		}
+		
+		Reply reply=(Reply)innerseq.getActivities().get(0);
+		
+		String uri=reply.getURI();
+		
+		if (uri == null) {
+			fail("URI is null");
+		}
+		
+		if (uri.equals("//@activity/@activities.0/@elseif.1/@activity/@activities.0") == false) {
+			fail("URI is invalid: "+uri);
+		}
+	}	
+
+	public void testGetURIIfElse() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<process xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+					"<sequence>"+
+		       		"<if xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+				       "<condition/>"+
+				       		"<sequence>"+
+				       			"<receive/>"+
+			       			"</sequence>"+
+				       "<elseif>"+
+				       "<condition/>"+
+			       			"<sequence>"+
+			       				"<invoke/>"+
+			       			"</sequence>"+
+				       "</elseif>"+
+				       "<elseif>"+
+				       "<condition/>"+
+		       				"<sequence>"+
+		       					"<reply/>"+
+		       				"</sequence>"+
+				       "</elseif>"+
+				       "<else>"+
+		       				"<sequence>"+
+		       					"<throw/>"+
+		       				"</sequence>"+
+				       "</else>"+
+				     "</if>"+
+			       "</sequence>"+
+	       		"</process>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			e.printStackTrace();
+			fail("Failed to convert to doc");
+		}
+		
+		Process component=new Process(model, elem);		
+		
+		BPELActivity topact=component.getActivity();
+		
+		if ((topact instanceof Sequence) == false) {
+			fail("Top level activity is not Sequence");
+		}
+		
+		Sequence seq=(Sequence)topact;
+		
+		if (seq.getActivities().size() != 1) {
+			fail("Should have 1 activity: "+seq.getActivities().size());
+		}
+		
+		if ((seq.getActivities().get(0) instanceof If) == false) {
+			fail("Activty should be If");
+		}
+		
+		If ifelem=(If)seq.getActivities().get(0);
+
+		if (ifelem.getElsePath() == null) {
+			fail("Else not set");
+		}
+		
+		Else els=ifelem.getElsePath();
+		
+		if ((els.getActivity() instanceof Sequence) == false) {
+			fail("Else activity not a sequence");
+		}
+		
+		Sequence innerseq=(Sequence)els.getActivity();
+		
+		if (innerseq.getActivities().size() != 1) {
+			fail("Expecting 1 child activities: "+
+					innerseq.getActivities().size());
+		}
+		
+		if ((innerseq.getActivities().get(0) instanceof Throw) == false) {
+			fail("First activity should be Throw");
+		}
+		
+		Throw thr=(Throw)innerseq.getActivities().get(0);
+		
+		String uri=thr.getURI();
+		
+		if (uri == null) {
+			fail("URI is null");
+		}
+		
+		if (uri.equals("//@activity/@activities.0/@else/@activity/@activities.0") == false) {
+			fail("URI is invalid: "+uri);
+		}
+	}	
+}

Added: trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/InvokeTest.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/InvokeTest.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/InvokeTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,119 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.savara.bpel.model.DefaultBPELLanguageModel;
+import org.savara.bpel.model.component.Invoke;
+
+import junit.framework.TestCase;
+
+public class InvokeTest extends TestCase {
+
+	public void testIsActivity() {
+		Invoke act=
+			new Invoke(new DefaultBPELLanguageModel(null));
+		
+		if (act.isActivity() == false) {
+			fail("Should be an activity");
+		}
+	}
+	
+	public void testBuildFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String iv="testIV";
+		String ov="testOV";
+		
+		String xml="<invoke xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\" "+
+		       "inputVariable=\""+iv+"\" "+
+		       "outputVariable=\""+ov+"\" "+
+		       "/>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Invoke component=new Invoke(model, elem);		
+		
+		if (component.getInputVariable().equals(iv) == false) {
+			fail("Input variable not correct, expecting '"+iv+"': "+
+							component.getInputVariable());
+		}
+		
+		if (component.getOutputVariable().equals(ov) == false) {
+			fail("Output variable not correct, expecting '"+ov+"': "+
+							component.getOutputVariable());
+		}
+	}
+	
+	public void testGetInputVariable() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String var="testVariable";
+		
+		Invoke component=new Invoke(model);		
+		
+		if (component.getInputVariable() != null) {
+			fail("Should be null");
+		}
+		
+		component.setInputVariable(var);
+		
+		if (component.getInputVariable().equals(var) == false) {
+			fail("Variable not correct, expecting '"+var+"': "+
+							component.getInputVariable());
+		}
+	}
+	
+	public void testGetOutputVariable() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String var="testVariable";
+		
+		Invoke component=new Invoke(model);		
+		
+		if (component.getOutputVariable() != null) {
+			fail("Should be null");
+		}
+		
+		component.setOutputVariable(var);
+		
+		if (component.getOutputVariable().equals(var) == false) {
+			fail("Variable not correct, expecting '"+var+"': "+
+							component.getOutputVariable());
+		}
+	}
+}

Added: trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/OnAlarmTest.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/OnAlarmTest.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/OnAlarmTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,914 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.savara.bpel.model.DefaultBPELLanguageModel;
+import org.savara.bpel.model.component.For;
+import org.savara.bpel.model.component.OnAlarm;
+import org.savara.bpel.model.component.Scope;
+import org.savara.bpel.model.component.Sequence;
+import org.savara.bpel.model.component.Until;
+
+import junit.framework.TestCase;
+
+public class OnAlarmTest extends TestCase {
+
+	public void testIsActivity() {
+		OnAlarm act=new OnAlarm(new DefaultBPELLanguageModel(null));
+		
+		if (act.isActivity() == true) {
+			fail("Should NOT be an activity");
+		}
+	}
+	
+	public void testBuildOnAlarmUntil() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String expr1="Test Expression 1";
+		
+		String xml="<onAlarm xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">" +
+	       		"<until>"+expr1+"</until>"+
+				"<scope/></onAlarm>";
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+			
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		OnAlarm component=new OnAlarm(model, elem);		
+		
+		if (component.getUntil() == null) {
+			fail("Condition not set");
+		}
+		
+		if (component.getFor() != null) {
+			fail("For condition should is set");
+		}
+		
+		String result=component.getUntil().getExpression();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(expr1) == false) {
+			fail("Expression is not valid: expecting '"+
+					expr1+"' but got '"+result+"'");
+		}
+
+		if (component.getActivity() == null) {
+			fail("No activity");
+		}
+	}
+	
+	public void testBuildOnAlarmFor() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String expr1="Test Expression 1";
+		
+		String xml="<onAlarm xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+		       "<for>"+expr1+"</for>"+
+		       "<scope/>"+
+		       "</onAlarm>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		OnAlarm component=new OnAlarm(model, elem);		
+		
+		if (component.getFor() == null) {
+			fail("Condition not set");
+		}
+		
+		if (component.getUntil() != null) {
+			fail("For condition should is set");
+		}
+		
+		String result=component.getFor().getExpression();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(expr1) == false) {
+			fail("Expression is not valid: expecting '"+
+					expr1+"' but got '"+result+"'");
+		}
+
+		if (component.getActivity() == null) {
+			fail("No activity");
+		}
+	}
+
+	public void testSetUntilNew() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String expr1="Test Expression 1";
+		
+		String xml="<until xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+		       expr1+
+		       "</until>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Until condition=new Until(model, elem);
+		
+		OnAlarm component=new OnAlarm(model);
+		
+		component.setUntil(condition);
+		
+		if (component.getUntil() == null) {
+			fail("Condition not set");
+		}
+		
+		if (component.getFor() != null) {
+			fail("For condition should not be set");
+		}
+		
+		String result=component.getUntil().getExpression();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(expr1) == false) {
+			fail("Expression is not valid: expecting '"+
+					expr1+"' but got '"+result+"'");
+		}
+	}	
+	
+	public void testSetUntilReplace() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String expr1="Test Expression 1";
+		String expr2="Test Expression 2";
+		
+		String xml1="<until xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+	       		expr1+
+	       		"</until>";
+	
+		String xml2="<until xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+	       		expr2+
+	       		"</until>";
+	
+		org.w3c.dom.Element elem1=null;
+		org.w3c.dom.Element elem2=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml1.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem1 = doc.getDocumentElement();
+			
+			is.close();
+			
+			is=new java.io.ByteArrayInputStream(xml2.getBytes());
+			
+			doc=builder.parse(is);
+			elem2 = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Until condition1=new Until(model, elem1);
+		
+		OnAlarm component=new OnAlarm(model);
+		
+		component.setUntil(condition1);
+		
+		if (component.getUntil() == null) {
+			fail("Condition not set");
+		}
+		
+		if (component.getFor() != null) {
+			fail("For condition should not be set");
+		}
+		
+		String result=component.getUntil().getExpression();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(expr1) == false) {
+			fail("Expression1 is not valid: expecting '"+
+					expr1+"' but got '"+result+"'");
+		}
+
+		Until condition2=new Until(model, elem2);
+		
+		component.setUntil(condition2);
+		
+		if (component.getUntil() == null) {
+			fail("Condition not set");
+		}
+
+		if (component.getFor() != null) {
+			fail("For condition should still not be set");
+		}
+		
+		result=component.getUntil().getExpression();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(expr2) == false) {
+			fail("Expression2 is not valid: expecting '"+
+					expr2+"' but got '"+result+"'");
+		}
+	}		
+
+	public void testSetForNew() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String expr1="Test Expression 1";
+		
+		String xml="<for xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+		       expr1+
+		       "</for>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		For condition=new For(model, elem);
+		
+		OnAlarm component=new OnAlarm(model);
+		
+		component.setFor(condition);
+		
+		if (component.getFor() == null) {
+			fail("Condition not set");
+		}
+		
+		if (component.getUntil() != null) {
+			fail("Until condition should not be set");
+		}
+		
+		String result=component.getFor().getExpression();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(expr1) == false) {
+			fail("Expression is not valid: expecting '"+
+					expr1+"' but got '"+result+"'");
+		}
+	}	
+	
+	public void testSetForReplace() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String expr1="Test Expression 1";
+		String expr2="Test Expression 2";
+		
+		String xml1="<for xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+	       		expr1+
+	       		"</for>";
+	
+		String xml2="<for xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+	       		expr2+
+	       		"</for>";
+	
+		org.w3c.dom.Element elem1=null;
+		org.w3c.dom.Element elem2=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml1.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem1 = doc.getDocumentElement();
+			
+			is.close();
+			
+			is=new java.io.ByteArrayInputStream(xml2.getBytes());
+			
+			doc=builder.parse(is);
+			elem2 = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		For condition1=new For(model, elem1);
+		
+		OnAlarm component=new OnAlarm(model);
+		
+		component.setFor(condition1);
+		
+		if (component.getFor() == null) {
+			fail("Condition not set");
+		}
+		
+		if (component.getUntil() != null) {
+			fail("Until condition should not be set");
+		}
+		
+		String result=component.getFor().getExpression();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(expr1) == false) {
+			fail("Expression1 is not valid: expecting '"+
+					expr1+"' but got '"+result+"'");
+		}
+
+		For condition2=new For(model, elem2);
+		
+		component.setFor(condition2);
+		
+		if (component.getFor() == null) {
+			fail("Condition not set");
+		}
+
+		if (component.getUntil() != null) {
+			fail("Until condition should still not be set");
+		}
+		
+		result=component.getFor().getExpression();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(expr2) == false) {
+			fail("Expression2 is not valid: expecting '"+
+					expr2+"' but got '"+result+"'");
+		}
+	}		
+
+	public void testSetForThenUntil() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String expr1="Test Expression 1";
+		String expr2="Test Expression 2";
+		
+		String xml1="<for xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+	       		expr1+
+	       		"</for>";
+	
+		String xml2="<until xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+	       		expr2+
+	       		"</until>";
+	
+		org.w3c.dom.Element elem1=null;
+		org.w3c.dom.Element elem2=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml1.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem1 = doc.getDocumentElement();
+			
+			is.close();
+			
+			is=new java.io.ByteArrayInputStream(xml2.getBytes());
+			
+			doc=builder.parse(is);
+			elem2 = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		For condition1=new For(model, elem1);
+		
+		OnAlarm component=new OnAlarm(model);
+		
+		component.setFor(condition1);
+		
+		if (component.getFor() == null) {
+			fail("Condition not set");
+		}
+		
+		if (component.getUntil() != null) {
+			fail("Until condition should not be set");
+		}
+		
+		String result=component.getFor().getExpression();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(expr1) == false) {
+			fail("Expression1 is not valid: expecting '"+
+					expr1+"' but got '"+result+"'");
+		}
+
+		Until condition2=new Until(model, elem2);
+		
+		component.setUntil(condition2);
+		
+		if (component.getUntil() == null) {
+			fail("Condition not set");
+		}
+
+		if (component.getFor() != null) {
+			fail("For condition should still not be set");
+		}
+		
+		result=component.getUntil().getExpression();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(expr2) == false) {
+			fail("Expression2 is not valid: expecting '"+
+					expr2+"' but got '"+result+"'");
+		}
+	}		
+
+	public void testSetUntilThenFor() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String expr1="Test Expression 1";
+		String expr2="Test Expression 2";
+		
+		String xml1="<until xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+	       		expr1+
+	       		"</until>";
+	
+		String xml2="<for xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+	       		expr2+
+	       		"</for>";
+	
+		org.w3c.dom.Element elem1=null;
+		org.w3c.dom.Element elem2=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml1.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem1 = doc.getDocumentElement();
+			
+			is.close();
+			
+			is=new java.io.ByteArrayInputStream(xml2.getBytes());
+			
+			doc=builder.parse(is);
+			elem2 = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Until condition1=new Until(model, elem1);
+		
+		OnAlarm component=new OnAlarm(model);
+		
+		component.setUntil(condition1);
+		
+		if (component.getUntil() == null) {
+			fail("Condition not set");
+		}
+		
+		if (component.getFor() != null) {
+			fail("For condition should not be set");
+		}
+		
+		String result=component.getUntil().getExpression();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(expr1) == false) {
+			fail("Expression1 is not valid: expecting '"+
+					expr1+"' but got '"+result+"'");
+		}
+
+		For condition2=new For(model, elem2);
+		
+		component.setFor(condition2);
+		
+		if (component.getFor() == null) {
+			fail("Condition not set");
+		}
+
+		if (component.getUntil() != null) {
+			fail("Until condition should still not be set");
+		}
+		
+		result=component.getFor().getExpression();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(expr2) == false) {
+			fail("Expression2 is not valid: expecting '"+
+					expr2+"' but got '"+result+"'");
+		}
+	}		
+
+	public void testAddActivityOnAlarmUntil() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String expr1="Test Expression 1";
+		
+		String xml="<onAlarm xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">" +
+	       		"<until>"+expr1+"</until>"+
+				"</onAlarm>";
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+			
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		OnAlarm component=new OnAlarm(model, elem);		
+		
+		if (component.getUntil() == null) {
+			fail("Condition not set");
+		}
+		
+		if (component.getFor() != null) {
+			fail("For condition should is set");
+		}
+		
+		String result=component.getUntil().getExpression();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(expr1) == false) {
+			fail("Expression is not valid: expecting '"+
+					expr1+"' but got '"+result+"'");
+		}
+		
+		Scope sub=new Scope(model);
+		component.setActivity(sub);
+
+		if (component.getActivity() == null) {
+			fail("No activity");
+		}
+		
+		if (component.getDOMElement().getChildNodes().item(1).
+				getLocalName().equals(Scope.SCOPE) == false) {
+			fail("Second element was not a scope: "+
+					component.getDOMElement().getChildNodes().item(1).
+									getLocalName());
+		}
+	}
+
+	public void testAddActivityOnAlarmFor() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String expr1="Test Expression 1";
+		
+		String xml="<onAlarm xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">" +
+	       		"<for>"+expr1+"</for>"+
+				"</onAlarm>";
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+			
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		OnAlarm component=new OnAlarm(model, elem);		
+		
+		if (component.getFor() == null) {
+			fail("Condition not set");
+		}
+		
+		if (component.getUntil() != null) {
+			fail("Until condition should is set");
+		}
+		
+		String result=component.getFor().getExpression();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(expr1) == false) {
+			fail("Expression is not valid: expecting '"+
+					expr1+"' but got '"+result+"'");
+		}
+		
+		Scope sub=new Scope(model);
+		component.setActivity(sub);
+
+		if (component.getActivity() == null) {
+			fail("No activity");
+		}
+		
+		if (component.getDOMElement().getChildNodes().item(1).
+				getLocalName().equals(Scope.SCOPE) == false) {
+			fail("Second element was not a Scope: "+
+					component.getDOMElement().getChildNodes().item(1).
+									getLocalName());
+		}
+	}
+
+	public void testAddForOnAlarm() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String expr1="Test Expression 1";
+		
+		String xml="<onAlarm xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">" +
+				"<scope/>"+
+				"</onAlarm>";
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+			
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		OnAlarm component=new OnAlarm(model, elem);		
+		
+		if (component.getFor() != null) {
+			fail("For condition should not be set");
+		}
+		
+		if (component.getUntil() != null) {
+			fail("Until condition should not be set");
+		}
+		
+		if (component.getActivity() == null) {
+			fail("No activity");
+		}
+		
+		For cond=new For(model);
+		cond.setExpression(expr1);
+		
+		component.setFor(cond);
+		
+		String result=component.getFor().getExpression();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(expr1) == false) {
+			fail("Expression is not valid: expecting '"+
+					expr1+"' but got '"+result+"'");
+		}
+		
+		if (component.getDOMElement().getChildNodes().item(0).
+				getLocalName().equals(For.FOR) == false) {
+			fail("First element was not a 'for': "+
+					component.getDOMElement().getChildNodes().item(0).
+									getLocalName());
+		}
+		
+		if (component.getDOMElement().getChildNodes().item(1).
+				getLocalName().equals(Scope.SCOPE) == false) {
+			fail("Second element was not a Scope: "+
+					component.getDOMElement().getChildNodes().item(1).
+									getLocalName());
+		}
+	}
+
+	public void testAddUntilOnAlarm() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String expr1="Test Expression 1";
+		
+		String xml="<onAlarm xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">" +
+				"<scope/>"+
+				"</onAlarm>";
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+			
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		OnAlarm component=new OnAlarm(model, elem);		
+		
+		if (component.getFor() != null) {
+			fail("For condition should not be set");
+		}
+		
+		if (component.getUntil() != null) {
+			fail("Until condition should not be set");
+		}
+		
+		if (component.getActivity() == null) {
+			fail("No activity");
+		}
+		
+		Until cond=new Until(model);
+		cond.setExpression(expr1);
+		
+		component.setUntil(cond);
+		
+		String result=component.getUntil().getExpression();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(expr1) == false) {
+			fail("Expression is not valid: expecting '"+
+					expr1+"' but got '"+result+"'");
+		}
+		
+		if (component.getDOMElement().getChildNodes().item(0).
+				getLocalName().equals(Until.UNTIL) == false) {
+			fail("First element was not a 'until': "+
+					component.getDOMElement().getChildNodes().item(0).
+									getLocalName());
+		}
+		
+		if (component.getDOMElement().getChildNodes().item(1).
+				getLocalName().equals(Scope.SCOPE) == false) {
+			fail("Second element was not a Scope: "+
+					component.getDOMElement().getChildNodes().item(1).
+									getLocalName());
+		}
+	}
+}

Added: trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/OnEventTest.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/OnEventTest.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/OnEventTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,175 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.savara.bpel.model.DefaultBPELLanguageModel;
+import org.savara.bpel.model.component.OnEvent;
+
+import junit.framework.TestCase;
+
+public class OnEventTest extends TestCase {
+
+	public void testIsActivity() {
+		OnEvent act=new OnEvent(new DefaultBPELLanguageModel(null));
+		
+		if (act.isActivity() == true) {
+			fail("Should NOT be an activity");
+		}
+	}
+	
+	public void testBuildEHOnEvent() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String var="testVar";
+		String op="testOp";
+		String portType="testPortType";
+		String partnerLink="testPartnerLink";
+
+		String xml="<onEvent xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\" " +
+			       "operation=\""+op+"\" "+
+			       "partnerLink=\""+partnerLink+"\" "+
+			       "portType=\""+portType+"\" "+
+	       			"variable=\""+var+"\" "+
+	       			" >"+
+				"<scope/></onEvent>";
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+			
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		OnEvent component=new OnEvent(model, elem);		
+		
+		if (component.getScope() == null) {
+			fail("No scope");
+		}
+		
+		if (component.getVariable().equals(var) == false) {
+			fail("Variable not correct, expecting '"+var+"': "+
+							component.getVariable());
+		}
+
+		if (component.getOperation().equals(op) == false) {
+			fail("Operation not correct, expecting '"+op+"': "+
+							component.getOperation());
+		}
+		
+		if (component.getPartnerLink().equals(partnerLink) == false) {
+			fail("PartnerLink not correct, expecting '"+partnerLink+"': "+
+							component.getPartnerLink());
+		}
+		
+		if (component.getPortType().equals(portType) == false) {
+			fail("Port type not correct, expecting '"+portType+"': "+
+							component.getPortType());
+		}
+	}
+
+	public void testGetVariable() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String var="testVariable";
+		
+		OnEvent component=new OnEvent(model);		
+		
+		if (component.getVariable() != null) {
+			fail("Should be null");
+		}
+		
+		component.setVariable(var);
+		
+		if (component.getVariable().equals(var) == false) {
+			fail("Variable not correct, expecting '"+var+"': "+
+							component.getVariable());
+		}
+	}
+
+	public void testGetOperation() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String op="testOp";
+		
+		OnEvent component=new OnEvent(model);		
+		
+		if (component.getOperation() != null) {
+			fail("Should be null");
+		}
+		
+		component.setOperation(op);
+		
+		if (component.getOperation().equals(op) == false) {
+			fail("Operation not correct, expecting '"+op+"': "+
+							component.getOperation());
+		}
+	}
+	
+	public void testGetPortType() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String pt="testPortType";
+		
+		OnEvent component=new OnEvent(model);		
+		
+		if (component.getPortType() != null) {
+			fail("Should be null");
+		}
+		
+		component.setPortType(pt);
+		
+		if (component.getPortType().equals(pt) == false) {
+			fail("Port type not correct, expecting '"+pt+"': "+
+							component.getPortType());
+		}
+	}
+	
+	public void testGetPartnerLink() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String pl="testPartnerLink";
+		
+		OnEvent component=new OnEvent(model);		
+		
+		if (component.getPartnerLink() != null) {
+			fail("Should be null");
+		}
+		
+		component.setPartnerLink(pl);
+		
+		if (component.getPartnerLink().equals(pl) == false) {
+			fail("Partner link not correct, expecting '"+pl+"': "+
+							component.getPartnerLink());
+		}
+	}
+}

Added: trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/OnMessageTest.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/OnMessageTest.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/OnMessageTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,180 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.savara.bpel.model.DefaultBPELLanguageModel;
+import org.savara.bpel.model.component.OnMessage;
+import org.savara.bpel.model.component.Sequence;
+
+import junit.framework.TestCase;
+
+public class OnMessageTest extends TestCase {
+
+	public void testIsActivity() {
+		OnMessage act=new OnMessage(new DefaultBPELLanguageModel(null));
+		
+		if (act.isActivity() == true) {
+			fail("Should NOT be an activity");
+		}
+	}
+	
+	public void testBuildOnMessage() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String var="testVar";
+		String op="testOp";
+		String portType="testPortType";
+		String partnerLink="testPartnerLink";
+
+		String xml="<onMessage xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\" " +
+			       "operation=\""+op+"\" "+
+			       "partnerLink=\""+partnerLink+"\" "+
+			       "portType=\""+portType+"\" "+
+	       			"variable=\""+var+"\" "+
+	       			" >"+
+				"<sequence/></onMessage>";
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+			
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		OnMessage component=new OnMessage(model, elem);		
+		
+		if (component.getActivity() == null) {
+			fail("No activity");
+		}
+		
+		if ((component.getActivity() instanceof Sequence) == false) {
+			fail("Activity is not a sequence");
+		}
+
+		if (component.getVariable().equals(var) == false) {
+			fail("Variable not correct, expecting '"+var+"': "+
+							component.getVariable());
+		}
+
+		if (component.getOperation().equals(op) == false) {
+			fail("Operation not correct, expecting '"+op+"': "+
+							component.getOperation());
+		}
+		
+		if (component.getPartnerLink().equals(partnerLink) == false) {
+			fail("PartnerLink not correct, expecting '"+partnerLink+"': "+
+							component.getPartnerLink());
+		}
+		
+		if (component.getPortType().equals(portType) == false) {
+			fail("Port type not correct, expecting '"+portType+"': "+
+							component.getPortType());
+		}
+	}
+
+	public void testGetVariable() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String var="testVariable";
+		
+		OnMessage component=new OnMessage(model);		
+		
+		if (component.getVariable() != null) {
+			fail("Should be null");
+		}
+		
+		component.setVariable(var);
+		
+		if (component.getVariable().equals(var) == false) {
+			fail("Variable not correct, expecting '"+var+"': "+
+							component.getVariable());
+		}
+	}
+
+	public void testGetOperation() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String op="testOp";
+		
+		OnMessage component=new OnMessage(model);		
+		
+		if (component.getOperation() != null) {
+			fail("Should be null");
+		}
+		
+		component.setOperation(op);
+		
+		if (component.getOperation().equals(op) == false) {
+			fail("Operation not correct, expecting '"+op+"': "+
+							component.getOperation());
+		}
+	}
+	
+	public void testGetPortType() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String pt="testPortType";
+		
+		OnMessage component=new OnMessage(model);		
+		
+		if (component.getPortType() != null) {
+			fail("Should be null");
+		}
+		
+		component.setPortType(pt);
+		
+		if (component.getPortType().equals(pt) == false) {
+			fail("Port type not correct, expecting '"+pt+"': "+
+							component.getPortType());
+		}
+	}
+	
+	public void testGetPartnerLink() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String pl="testPartnerLink";
+		
+		OnMessage component=new OnMessage(model);		
+		
+		if (component.getPartnerLink() != null) {
+			fail("Should be null");
+		}
+		
+		component.setPartnerLink(pl);
+		
+		if (component.getPartnerLink().equals(pl) == false) {
+			fail("Partner link not correct, expecting '"+pl+"': "+
+							component.getPartnerLink());
+		}
+	}
+}

Added: trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/PartnerLinkTest.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/PartnerLinkTest.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/PartnerLinkTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,170 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.savara.bpel.model.DefaultBPELLanguageModel;
+import org.savara.bpel.model.component.PartnerLink;
+
+import junit.framework.TestCase;
+
+public class PartnerLinkTest extends TestCase {
+
+	public void testIsActivity() {
+		PartnerLink act=new PartnerLink(new DefaultBPELLanguageModel(null));
+		
+		if (act.isActivity() == true) {
+			fail("Should NOT be an activity");
+		}
+	}
+	
+	public void testBuildPartnerLink() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String partnerRole="testPartnerRole";
+		String name="testName";
+		String myRole="testMyRole";
+		String partnerLinkType="testPartnerLinkType";
+
+		String xml="<partnerLink xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\" " +
+			       "name=\""+name+"\" "+
+			       "partnerLinkType=\""+partnerLinkType+"\" "+
+			       "myRole=\""+myRole+"\" "+
+	       			"partnerRole=\""+partnerRole+"\" "+
+	       			" />";
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+			
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		PartnerLink component=new PartnerLink(model, elem);		
+		
+		if (component.getPartnerRole().equals(partnerRole) == false) {
+			fail("PartnerRole not correct, expecting '"+partnerRole+"': "+
+							component.getPartnerRole());
+		}
+
+		if (component.getName().equals(name) == false) {
+			fail("Name not correct, expecting '"+name+"': "+
+							component.getName());
+		}
+		
+		if (component.getPartnerLinkType().equals(partnerLinkType) == false) {
+			fail("PartnerLinkType not correct, expecting '"+partnerLinkType+"': "+
+							component.getPartnerLinkType());
+		}
+		
+		if (component.getMyRole().equals(myRole) == false) {
+			fail("MyRole not correct, expecting '"+myRole+"': "+
+							component.getMyRole());
+		}
+	}
+
+	public void testGetName() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String name="testName";
+		
+		PartnerLink component=new PartnerLink(model);		
+		
+		if (component.getName() != null) {
+			fail("Name should be null");
+		}
+		
+		component.setName(name);
+		
+		if (component.getName().equals(name) == false) {
+			fail("Name not correct, expecting '"+name+"': "+
+							component.getName());
+		}
+	}
+
+	public void testGetPartnerLinkType() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String plt="testPartnerLinkType";
+		
+		PartnerLink component=new PartnerLink(model);	
+		
+		if (component.getPartnerLinkType() != null) {
+			fail("Partner link type should be null");
+		}
+		
+		component.setPartnerLinkType(plt);
+		
+		if (component.getPartnerLinkType().equals(plt) == false) {
+			fail("PartnerLinkType not correct, expecting '"+plt+"': "+
+							component.getPartnerLinkType());
+		}
+	}
+	
+	public void testGetMyRole() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String mr="testMyRole";
+		
+		PartnerLink component=new PartnerLink(model);
+		
+		if (component.getMyRole() != null) {
+			fail("My role is not null");
+		}
+		
+		component.setMyRole(mr);
+		
+		if (component.getMyRole().equals(mr) == false) {
+			fail("MyRole not correct, expecting '"+mr+"': "+
+							component.getMyRole());
+		}
+	}
+	
+	public void testGetPartnerRole() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String pr="testPartnerRole";
+		
+		PartnerLink component=new PartnerLink(model);	
+		
+		if (component.getPartnerRole() != null) {
+			fail("Partner role should be null");
+		}
+		
+		component.setPartnerRole(pr);
+		
+		if (component.getPartnerRole().equals(pr) == false) {
+			fail("PartnerRole not correct, expecting '"+pr+"': "+
+							component.getPartnerRole());
+		}
+	}
+}

Added: trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/PickTest.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/PickTest.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/PickTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,423 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.savara.bpel.model.DefaultBPELLanguageModel;
+import org.savara.bpel.model.component.BPELActivity;
+import org.savara.bpel.model.component.OnAlarm;
+import org.savara.bpel.model.component.OnMessage;
+import org.savara.bpel.model.component.Pick;
+import org.savara.bpel.model.component.Process;
+import org.savara.bpel.model.component.Receive;
+import org.savara.bpel.model.component.Scope;
+import org.savara.bpel.model.component.Sequence;
+
+import junit.framework.TestCase;
+
+public class PickTest extends TestCase {
+
+	public void testIsActivity() {
+		Pick act=new Pick(new DefaultBPELLanguageModel(null));
+		
+		if (act.isActivity() == false) {
+			fail("Should be an activity");
+		}
+	}
+	
+	public void testPickFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<pick xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+		       "<onMessage/>"+
+		       "<onMessage/>"+
+		       "<onAlarm/>"+
+		       "</pick>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Pick component=new Pick(model, elem);		
+		
+		if (component.getOnMessages().size() != 2) {
+			fail("Expecting 2 onMessage: "+
+							component.getOnMessages().size());
+		}
+		
+		if (component.getOnAlarms().size() != 1) {
+			fail("Expecting 1 onAlarm: "+
+							component.getOnAlarms().size());
+		}
+	}
+
+	public void testAddOnMessageToPickInitFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<pick xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+	       		"<targets/>"+
+	       		"<onAlarm/>"+
+	       		"<onAlarm/>"+
+	       		"</pick>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Pick component=new Pick(model, elem);		
+		
+		if (component.getOnAlarms().size() != 2) {
+			fail("Expecting 2 onAlarms: "+
+							component.getOnAlarms().size());
+		}
+		
+		if (component.getOnMessages().size() != 0) {
+			fail("Expecting 0 onMessages: "+
+							component.getOnMessages().size());
+		}
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 3) {
+			fail("Three child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+
+		OnMessage sub=new OnMessage(model);
+		
+		component.addOnMessage(sub, 0);
+		
+		if (component.getOnMessages().size() != 1) {
+			fail("Expecting 1 onMessage: "+
+							component.getOnMessages().size());
+		}
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 4) {
+			fail("Four child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+
+		if (component.getDOMElement().getChildNodes().item(1).
+				getLocalName().equals(OnMessage.ONMESSAGE) == false) {
+			fail("Second element was not a 'onMessage': "+
+					component.getDOMElement().getChildNodes().item(1).
+									getLocalName());
+		}
+	}
+
+
+	public void testAddOnAlarmToPickInitFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<pick xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+	       		"<targets/>"+
+	       		"<onMessage/>"+
+	       		"<onMessage/>"+
+	       		"</pick>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Pick component=new Pick(model, elem);		
+		
+		if (component.getOnMessages().size() != 2) {
+			fail("Expecting 2 onMessages: "+
+							component.getOnMessages().size());
+		}
+		
+		if (component.getOnAlarms().size() != 0) {
+			fail("Expecting 0 onAlarms: "+
+							component.getOnAlarms().size());
+		}
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 3) {
+			fail("Three child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+
+		OnAlarm sub=new OnAlarm(model);
+		
+		component.addOnAlarm(sub, 0);
+		
+		if (component.getOnAlarms().size() != 1) {
+			fail("Expecting 1 onAlarm: "+
+							component.getOnAlarms().size());
+		}
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 4) {
+			fail("Four child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+
+		if (component.getDOMElement().getChildNodes().item(3).
+				getLocalName().equals(OnAlarm.ONALARM) == false) {
+			fail("Second element was not a 'onAlarm': "+
+					component.getDOMElement().getChildNodes().item(3).
+									getLocalName());
+		}
+	}
+	
+	public void testGetURIOnAlarm() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<process xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+				"<sequence>"+
+		       		"<pick>"+
+						"<onAlarm>"+
+							"<scope>"+
+				       		"<sequence>"+
+				       			"<receive/>"+
+			       			"</sequence>"+
+			       			"</scope>"+
+						"</onAlarm>"+
+			       "</pick>"+
+	       		"</sequence>"+
+	       		"</process>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			e.printStackTrace();
+			fail("Failed to convert to doc");
+		}
+		
+		Process component=new Process(model, elem);		
+		
+		BPELActivity topact=component.getActivity();
+		
+		if ((topact instanceof Sequence) == false) {
+			fail("Top level activity is not Sequence");
+		}
+		
+		Sequence topseq=(Sequence)topact;
+		
+		if (topseq.getActivities().size() != 1) {
+			fail("Top sequence should have 1 activity");
+		}
+		
+		if ((topseq.getActivities().get(0) instanceof Pick) == false) {
+			fail("Activity is not Pick");
+		}
+		
+		Pick pick=(Pick)topseq.getActivities().get(0);
+		
+		OnAlarm one=pick.getOnAlarms().get(0);
+		
+		if ((one.getActivity() instanceof Scope) == false) {
+			fail("Activity is not scope");
+		}
+		
+		Scope innerScope=(Scope)one.getActivity();
+		
+		if (innerScope == null) {
+			fail("Inner scope not set");
+		}
+		
+		if ((innerScope.getActivity() instanceof Sequence) == false) {
+			fail("Inner scope activity is not a sequence");
+		}
+		
+		Sequence seq=(Sequence)innerScope.getActivity();
+		
+		if (seq.getActivities().size() != 1) {
+			fail("Expecting 1 child activities: "+
+							seq.getActivities().size());
+		}
+		
+		if ((seq.getActivities().get(0) instanceof Receive) == false) {
+			fail("First activity should be receive");
+		}
+		
+		Receive recv=(Receive)seq.getActivities().get(0);
+		
+		String uri=recv.getURI();
+		
+		if (uri == null) {
+			fail("URI is null");
+		}
+		
+		if (uri.equals("//@activity/@activities.0/@onAlarm.0/@scope/@activity/@activities.0") == false) {
+			fail("URI is invalid: "+uri);
+		}
+	}	
+	
+	public void testGetURIOnMessage() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<process xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+				"<sequence>"+
+		       		"<pick>"+
+						"<onMessage>"+
+							"<scope>"+
+				       		"<sequence>"+
+				       			"<receive/>"+
+			       			"</sequence>"+
+			       			"</scope>"+
+						"</onMessage>"+
+			       "</pick>"+
+	       		"</sequence>"+
+	       		"</process>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			e.printStackTrace();
+			fail("Failed to convert to doc");
+		}
+		
+		org.savara.bpel.model.component.Process component=
+			new org.savara.bpel.model.component.Process(model, elem);		
+		
+		BPELActivity topact=component.getActivity();
+		
+		if ((topact instanceof Sequence) == false) {
+			fail("Top level activity is not Sequence");
+		}
+		
+		Sequence topseq=(Sequence)topact;
+		
+		if (topseq.getActivities().size() != 1) {
+			fail("Top sequence should have 1 activity");
+		}
+		
+		if ((topseq.getActivities().get(0) instanceof Pick) == false) {
+			fail("Activity is not Pick");
+		}
+		
+		Pick pick=(Pick)topseq.getActivities().get(0);
+		
+		OnMessage one=pick.getOnMessages().get(0);
+		
+		if ((one.getActivity() instanceof Scope) == false) {
+			fail("Activity is not scope");
+		}
+		
+		Scope innerScope=(Scope)one.getActivity();
+		
+		if (innerScope == null) {
+			fail("Inner scope not set");
+		}
+		
+		if ((innerScope.getActivity() instanceof Sequence) == false) {
+			fail("Inner scope activity is not a sequence");
+		}
+		
+		Sequence seq=(Sequence)innerScope.getActivity();
+		
+		if (seq.getActivities().size() != 1) {
+			fail("Expecting 1 child activities: "+
+							seq.getActivities().size());
+		}
+		
+		if ((seq.getActivities().get(0) instanceof Receive) == false) {
+			fail("First activity should be receive");
+		}
+		
+		Receive recv=(Receive)seq.getActivities().get(0);
+		
+		String uri=recv.getURI();
+		
+		if (uri == null) {
+			fail("URI is null");
+		}
+		
+		if (uri.equals("//@activity/@activities.0/@onMessage.0/@activity/@activity/@activities.0") == false) {
+			fail("URI is invalid: "+uri);
+		}
+	}	
+}

Added: trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/ProcessTest.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/ProcessTest.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/ProcessTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,440 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.savara.bpel.model.DefaultBPELLanguageModel;
+import org.savara.bpel.model.component.EventHandlers;
+import org.savara.bpel.model.component.FaultHandlers;
+import org.savara.bpel.model.component.PartnerLink;
+import org.savara.bpel.model.component.Process;
+import org.savara.bpel.model.component.Sequence;
+import org.savara.bpel.model.component.Variable;
+
+import junit.framework.TestCase;
+
+public class ProcessTest extends TestCase {
+
+	public void testIsActivity() {
+		Process act=new Process(new DefaultBPELLanguageModel(null));
+		
+		if (act.isActivity() == true) {
+			fail("Should NOT be an activity");
+		}
+	}
+	
+	public void testProcessFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<process xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+				"<partnerLinks><partnerLink/></partnerLinks>"+
+				"<messageExchanges/>"+
+				"<variables><variable/></variables>"+
+				"<correlationSets/>"+
+				"<faultHandlers/>"+
+				"<eventHandlers/>"+
+				"<sequence/>"+
+	       "</process>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Process component=new Process(model, elem);
+		
+		if (component.getPartnerLinks().size() != 1) {
+			fail("Expecting 1 partner link: "+component.getPartnerLinks().size());
+		}
+		
+		if (component.getVariables().size() != 1) {
+			fail("Expecting 1 variable: "+component.getVariables().size());
+		}
+		
+		if (component.getActivity() == null) {
+			fail("Activity not defined");
+		}
+		
+		if (component.getEventHandlers() == null) {
+			fail("Event handlers not defined");
+		}
+		
+		if (component.getFaultHandlers() == null) {
+			fail("Fault handlers not defined");
+		}
+	}
+	
+	public void testAddVariable() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<process xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+			"<partnerLinks><partnerLink/></partnerLinks>"+
+			"<messageExchanges/>"+
+			"<correlationSets/>"+
+			"<faultHandlers/>"+
+			"<eventHandlers/>"+
+			"<sequence/>"+
+		   "</process>";
+		
+		org.w3c.dom.Element ifelem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			ifelem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Process component=new Process(model, ifelem);
+
+		if (component.getVariables().size() != 0) {
+			fail("Should be no variables");
+		}
+		
+		Variable var=new Variable(model);
+		component.addVariable(var, 0);
+		
+		if (component.getVariables().size() != 1) {
+			fail("Should be one variable: "+component.getVariables().size());
+		}
+		
+		if (component.getDOMElement().getChildNodes().
+					item(2).getLocalName().equals("variables") == false) {
+			fail("Child 2 not as expected: "+component.getDOMElement().getChildNodes().
+					item(2).getLocalName());
+		}
+	}	
+	
+	public void testAddPartnerLink() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<process xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+			"<messageExchanges/>"+
+			"<variables><variable/></variables>"+
+			"<correlationSets/>"+
+			"<faultHandlers/>"+
+			"<eventHandlers/>"+
+			"<sequence/>"+
+		   "</process>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Process component=new Process(model, elem);
+
+		if (component.getPartnerLinks().size() != 0) {
+			fail("Should be no partner links");
+		}
+		
+		PartnerLink pl=new PartnerLink(model);
+		component.addPartnerLink(pl, 0);
+		
+		if (component.getPartnerLinks().size() != 1) {
+			fail("Should be one partner link: "+component.getPartnerLinks().size());
+		}
+		
+		if (component.getDOMElement().getChildNodes().
+					item(0).getLocalName().equals("partnerLinks") == false) {
+			fail("Child 0 not as expected: "+component.getDOMElement().getChildNodes().
+					item(0).getLocalName());
+		}
+	}	
+	
+	public void testGetPartnerLink() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		Process component=new Process(model);
+		String name="testName";
+		
+		PartnerLink pl=new PartnerLink(model);
+		pl.setName(name);
+		
+		component.addPartnerLink(pl, 0);
+		
+		if (component.getPartnerLink(name) == null) {
+			fail("Failed to get partner link for '"+name+"'");
+		}
+		
+		if (component.getPartnerLink("unknown") != null) {
+			fail("Should not have returned a partner link");
+		}
+	}	
+
+	public void testSetEventHandlers() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<process xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+			"<partnerLinks><partnerLink/></partnerLinks>"+
+			"<messageExchanges/>"+
+			"<variables><variable/></variables>"+
+			"<correlationSets/>"+
+			"<faultHandlers/>"+
+			"<sequence/>"+
+		   "</process>";
+		
+		org.w3c.dom.Element ifelem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			ifelem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Process component=new Process(model, ifelem);
+
+		if (component.getEventHandlers() != null) {
+			fail("Should be null");
+		}
+		
+		EventHandlers elem=new EventHandlers(model);
+		component.setEventHandlers(elem);
+		
+		if (component.getEventHandlers() == null) {
+			fail("Should NOT be null");
+		}
+		
+		if (component.getDOMElement().getChildNodes().
+					item(5).getLocalName().equals("eventHandlers") == false) {
+			fail("Child 5 not as expected: "+component.getDOMElement().getChildNodes().
+					item(5).getLocalName());
+		}
+	}	
+	
+	public void testSetFaultHandlers() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<process xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+			"<partnerLinks><partnerLink/></partnerLinks>"+
+			"<messageExchanges/>"+
+			"<variables><variable/></variables>"+
+			"<correlationSets/>"+
+			"<eventHandlers/>"+
+			"<sequence/>"+
+		   "</process>";
+		
+		org.w3c.dom.Element ifelem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			ifelem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Process component=new Process(model, ifelem);
+
+		if (component.getFaultHandlers() != null) {
+			fail("Should be null");
+		}
+		
+		FaultHandlers elem=new FaultHandlers(model);
+		component.setFaultHandlers(elem);
+		
+		if (component.getFaultHandlers() == null) {
+			fail("Should NOT be null");
+		}
+		
+		if (component.getDOMElement().getChildNodes().
+					item(4).getLocalName().equals("faultHandlers") == false) {
+			fail("Child 4 not as expected: "+component.getDOMElement().getChildNodes().
+					item(4).getLocalName());
+		}
+	}	
+
+	public void testSetActivity() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<process xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+				"<partnerLinks><partnerLink/></partnerLinks>"+
+				"<messageExchanges/>"+
+				"<variables><variable/></variables>"+
+				"<correlationSets/>"+
+				"<faultHandlers/>"+
+				"<eventHandlers/>"+
+		   "</process>";
+		
+		org.w3c.dom.Element ifelem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			ifelem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Process component=new Process(model, ifelem);
+
+		if (component.getActivity() != null) {
+			fail("Should be null");
+		}
+		
+		Sequence elem=new Sequence(model);
+		component.setActivity(elem);
+		
+		if (component.getActivity() == null) {
+			fail("Should NOT be null");
+		}
+		
+		if (component.getDOMElement().getChildNodes().
+					item(6).getLocalName().equals(Sequence.SEQUENCE) == false) {
+			fail("Child 6 not as expected: "+component.getDOMElement().getChildNodes().
+					item(6).getLocalName());
+		}
+	}	
+
+	public void testAddDistinctNamespaces() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		Process component=new Process(model);
+
+		String prefix1=component.addNamespace("namespace1");
+		String prefix2=component.addNamespace("namespace2");
+		
+		if (prefix1 == null) {
+			fail("First prefix is null");
+		}
+		
+		if (prefix2 == null) {
+			fail("Second prefix is null");
+		}
+		
+		if (prefix1.equals(prefix2)) {
+			fail("Prefixes should be different: "+prefix1+" "+prefix2);
+		}
+	}
+	
+	public void testAddSameNamespaces() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		Process component=new Process(model);
+
+		String prefix1=component.addNamespace("namespace1");
+		String prefix2=component.addNamespace("namespace1");
+		
+		if (prefix1 == null) {
+			fail("First prefix is null");
+		}
+		
+		if (prefix2 == null) {
+			fail("Second prefix is null");
+		}
+		
+		if (prefix1.equals(prefix2) == false) {
+			fail("Prefixes should be same: "+prefix1+" "+prefix2);
+		}
+	}
+	
+	public void testDefaultNamesapces() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		Process component=new Process(model);
+		
+		String ns=component.getNamespace(Process.BPEL_PREFIX);
+		
+		if (ns == null) {
+			fail("Namespace not found");
+		}
+		
+		if (ns.equals(Process.BPEL_NS) == false) {
+			fail("Namespace is wrong: "+ns+" was expecting "+Process.BPEL_NS);
+		}
+	}
+}

Added: trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/ReceiveTest.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/ReceiveTest.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/ReceiveTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,200 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.savara.bpel.model.DefaultBPELLanguageModel;
+import org.savara.bpel.model.component.Receive;
+
+import junit.framework.TestCase;
+
+public class ReceiveTest extends TestCase {
+
+	public void testIsActivity() {
+		Receive act=
+			new Receive(new DefaultBPELLanguageModel(null));
+		
+		if (act.isActivity() == false) {
+			fail("Should be an activity");
+		}
+	}
+	
+	public void testBuildFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String var="testVar";
+		String create="yes";
+		
+		String xml="<receive xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\" "+
+		       "variable=\""+var+"\" "+
+		       "createInstance=\""+create+"\" "+
+		       "/>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Receive component=new Receive(model, elem);		
+		
+		if (component.getVariable().equals(var) == false) {
+			fail("Variable not correct, expecting '"+var+"': "+
+							component.getVariable());
+		}
+		
+		if (component.getCreateInstance() == false) {
+			fail("createInstance not correct, expecting 'true': "+
+							component.getCreateInstance());
+		}
+	}
+
+	public void testGetVariable() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String var="testVariable";
+		
+		Receive component=new Receive(model);		
+		
+		if (component.getVariable() != null) {
+			fail("Should be null");
+		}
+		
+		component.setVariable(var);
+		
+		if (component.getVariable().equals(var) == false) {
+			fail("Variable not correct, expecting '"+var+"': "+
+							component.getVariable());
+		}
+	}
+
+	public void testCreateInstanceFromDOMTrue() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String value="yes";
+		
+		String xml="<activity xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\" "+
+		       "createInstance=\""+value+"\" />";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Receive component=new Receive(model, elem);		
+		
+		if (component.getCreateInstance() == false) {
+			fail("'Suppress Join Failure' not correct, expecting 'true': "+
+							component.getCreateInstance());
+		}
+	}
+	
+	public void testCreateInstanceFromDOMFalse() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String value="no";
+		
+		String xml="<activity xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\" "+
+		       "createInstance=\""+value+"\" />";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Receive component=new Receive(model, elem);		
+		
+		if (component.getCreateInstance() == true) {
+			fail("'Suppress Join Failure' not correct, expecting 'false': "+
+							component.getCreateInstance());
+		}
+	}
+	
+	public void testGetCreateInstanceTrue() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		Receive component=new Receive(model);		
+		
+		component.setCreateInstance(true);
+		
+		if (component.getCreateInstance() == false) {
+			fail("'Suppress Join Failure' not correct, expecting 'true': "+
+							component.getCreateInstance());
+		}
+	}
+	
+	public void testGetCreateInstanceFalse() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		Receive component=new Receive(model);		
+		
+		component.setCreateInstance(false);
+		
+		if (component.getCreateInstance() == true) {
+			fail("'Suppress Join Failure' not correct, expecting 'false': "+
+							component.getCreateInstance());
+		}
+	}
+}

Added: trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/RepeatUntilTest.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/RepeatUntilTest.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/RepeatUntilTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,480 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.savara.bpel.model.DefaultBPELLanguageModel;
+import org.savara.bpel.model.component.BPELActivity;
+import org.savara.bpel.model.component.Condition;
+import org.savara.bpel.model.component.If;
+import org.savara.bpel.model.component.Process;
+import org.savara.bpel.model.component.Receive;
+import org.savara.bpel.model.component.RepeatUntil;
+import org.savara.bpel.model.component.Sequence;
+
+import junit.framework.TestCase;
+
+public class RepeatUntilTest extends TestCase {
+
+	public void testIsActivity() {
+		RepeatUntil act=new RepeatUntil(new DefaultBPELLanguageModel(null));
+		
+		if (act.isActivity() == false) {
+			fail("Should be an activity");
+		}
+	}
+	
+	public void testFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String expr1="Test Expression 1";
+		
+		String xml="<repeatUntil xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+		       "<sequence/>"+
+		       "<condition>"+expr1+"</condition>"+
+		       "</repeatUntil>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		RepeatUntil component=new RepeatUntil(model, elem);		
+		
+		if (component.getCondition() == null) {
+			fail("Condition not set");
+		}
+		
+		String result=component.getCondition().getExpression();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(expr1) == false) {
+			fail("Expression is not valid: expecting '"+
+					expr1+"' but got '"+result+"'");
+		}
+		
+		if (component.getActivity() == null) {
+			fail("Activity not set");
+		}
+		
+		if ((component.getActivity() instanceof Sequence) == false) {
+			fail("Activity not a sequence");
+		}
+	}
+	
+	public void testSetActivityInitFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String expr1="Test Expression 1";
+		
+		String xml="<repeatUntil xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+				"<targets/>"+
+				"<condition>"+expr1+"</condition>"+
+		       "</repeatUntil>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		RepeatUntil component=new RepeatUntil(model, elem);		
+		
+		if (component.getCondition() == null) {
+			fail("Condition not set");
+		}
+
+		if (component.getActivity() != null) {
+			fail("Activity should be null");
+		}
+
+		if (component.getDOMElement().getChildNodes().getLength() != 2) {
+			fail("Two child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+		
+		If sub=new If(model);
+		
+		component.setActivity(sub);
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 3) {
+			fail("Three child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+		
+		if (component.getDOMElement().getChildNodes().item(1).
+				getLocalName().equals(If.IF) == false) {
+			fail("Second element was not an 'if': "+
+					component.getDOMElement().getChildNodes().item(1).
+									getLocalName());
+		}
+	}
+	
+	public void testSetConditionNew() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String expr1="Test Expression 1";
+		
+		String xml="<condition xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+		       expr1+
+		       "</condition>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Condition condition=new Condition(model, elem);
+		
+		RepeatUntil component=new RepeatUntil(model);
+		
+		component.setCondition(condition);
+		
+		if (component.getCondition() == null) {
+			fail("Condition not set");
+		}
+		
+		String result=component.getCondition().getExpression();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(expr1) == false) {
+			fail("Expression is not valid: expecting '"+
+					expr1+"' but got '"+result+"'");
+		}
+	}	
+	
+	public void testSetConditionReplace() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String expr1="Test Expression 1";
+		String expr2="Test Expression 2";
+		
+		String xml1="<condition xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+	       		expr1+
+	       		"</condition>";
+	
+		String xml2="<condition xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+	       		expr2+
+	       		"</condition>";
+	
+		org.w3c.dom.Element elem1=null;
+		org.w3c.dom.Element elem2=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml1.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem1 = doc.getDocumentElement();
+			
+			is.close();
+			
+			is=new java.io.ByteArrayInputStream(xml2.getBytes());
+			
+			doc=builder.parse(is);
+			elem2 = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Condition condition1=new Condition(model, elem1);
+		
+		RepeatUntil component=new RepeatUntil(model);
+		
+		component.setCondition(condition1);
+		
+		if (component.getCondition() == null) {
+			fail("Condition not set");
+		}
+		
+		String result=component.getCondition().getExpression();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(expr1) == false) {
+			fail("Expression1 is not valid: expecting '"+
+					expr1+"' but got '"+result+"'");
+		}
+
+		Condition condition2=new Condition(model, elem2);
+		
+		component.setCondition(condition2);
+		
+		if (component.getCondition() == null) {
+			fail("Condition not set");
+		}
+		
+		result=component.getCondition().getExpression();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(expr2) == false) {
+			fail("Expression2 is not valid: expecting '"+
+					expr2+"' but got '"+result+"'");
+		}
+	}	
+	
+	public void testSetActivityNew() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<repeatUntil xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+		       "<condition/>"+
+		       "</repeatUntil>";
+		
+		org.w3c.dom.Element ifelem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			ifelem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		RepeatUntil component=new RepeatUntil(model, ifelem);
+
+		if (component.getActivity() != null) {
+			fail("Activity should be null");
+		}
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 1) {
+			fail("One child element expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+		
+		Sequence seq=new Sequence(model);
+		
+		component.setActivity(seq);
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 2) {
+			fail("Two child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+		
+		if (component.getDOMElement().getChildNodes().item(0).
+				getLocalName().equals(Sequence.SEQUENCE) == false) {
+			fail("First element was not a sequence: "+
+					component.getDOMElement().getChildNodes().item(0).
+									getLocalName());
+		}
+	}	
+	
+	public void testSetActivityReplace() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<repeatUntil xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+				"<sequence/>"+
+		        "<condition/>"+
+		        "</repeatUntil>";
+		
+		org.w3c.dom.Element ifelem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			ifelem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		RepeatUntil component=new RepeatUntil(model, ifelem);
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 2) {
+			fail("Two child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+		
+		If sub=new If(model);
+		
+		component.setActivity(sub);
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 2) {
+			fail("Two child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+		
+		if (component.getDOMElement().getChildNodes().item(0).
+				getLocalName().equals(If.IF) == false) {
+			fail("First element was not an 'if': "+
+					component.getDOMElement().getChildNodes().item(0).
+									getLocalName());
+		}
+	}	
+
+	public void testGetURI() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<process xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+					"<repeatUntil xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+		       		"<sequence>"+
+	       			"<receive/>"+
+       			"</sequence>"+
+		       "</repeatUntil>"+
+	       		"</process>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			e.printStackTrace();
+			fail("Failed to convert to doc");
+		}
+		
+		Process component=new Process(model, elem);		
+		
+		BPELActivity topact=component.getActivity();
+		
+		if ((topact instanceof RepeatUntil) == false) {
+			fail("Top level activity is not RepeatUntil");
+		}
+		
+		RepeatUntil top=(RepeatUntil)topact;
+		
+		if (top.getActivity() == null) {
+			fail("While activity is null");
+		}
+		
+		if ((top.getActivity() instanceof Sequence) == false) {
+			fail("While activity is not sequence");
+		}
+		
+		Sequence seq=(Sequence)top.getActivity();
+		
+		if (seq.getActivities().size() != 1) {
+			fail("Should have 1 activity: "+seq.getActivities().size());
+		}
+		
+		if ((seq.getActivities().get(0) instanceof Receive) == false) {
+			fail("Activty should be Receive");
+		}
+				
+		Receive recv=(Receive)seq.getActivities().get(0);
+		
+		String uri=recv.getURI();
+		
+		if (uri == null) {
+			fail("URI is null");
+		}
+		
+		if (uri.equals("//@activity/@activity/@activities.0") == false) {
+			fail("URI is invalid: "+uri);
+		}
+	}	
+}

Added: trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/ReplyTest.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/ReplyTest.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/ReplyTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,119 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.savara.bpel.model.DefaultBPELLanguageModel;
+import org.savara.bpel.model.component.Reply;
+
+import junit.framework.TestCase;
+
+public class ReplyTest extends TestCase {
+
+	public void testIsActivity() {
+		Reply act=
+			new Reply(new DefaultBPELLanguageModel(null));
+		
+		if (act.isActivity() == false) {
+			fail("Should be an activity");
+		}
+	}
+	
+	public void testBuildFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String var="testVar";
+		String fault="testFault";
+		
+		String xml="<reply xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\" "+
+		       "variable=\""+var+"\" "+
+		       "faultName=\""+fault+"\" "+
+		       "/>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Reply component=new Reply(model, elem);		
+		
+		if (component.getVariable().equals(var) == false) {
+			fail("Variable not correct, expecting '"+var+"': "+
+							component.getVariable());
+		}
+		
+		if (component.getFaultName().equals(fault) == false) {
+			fail("Fault not correct, expecting '"+fault+"': "+
+							component.getFaultName());
+		}
+	}
+
+	public void testGetVariable() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String var="testVariable";
+		
+		Reply component=new Reply(model);		
+		
+		if (component.getVariable() != null) {
+			fail("Should be null");
+		}
+		
+		component.setVariable(var);
+		
+		if (component.getVariable().equals(var) == false) {
+			fail("Variable not correct, expecting '"+var+"': "+
+							component.getVariable());
+		}
+	}
+
+	public void testGetFaultName() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String fault="testFault";
+		
+		Reply component=new Reply(model);		
+		
+		if (component.getFaultName() != null) {
+			fail("Should be null");
+		}
+		
+		component.setFaultName(fault);
+		
+		if (component.getFaultName().equals(fault) == false) {
+			fail("Fault name not correct, expecting '"+fault+"': "+
+							component.getFaultName());
+		}
+	}
+}

Added: trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/RethrowTest.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/RethrowTest.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/RethrowTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.DefaultBPELLanguageModel;
+import org.savara.bpel.model.component.Rethrow;
+
+import junit.framework.TestCase;
+
+public class RethrowTest extends TestCase {
+
+	public void testIsActivity() {
+		Rethrow act=
+			new Rethrow(new DefaultBPELLanguageModel(null));
+		
+		if (act.isActivity() == false) {
+			fail("Should be an activity");
+		}
+	}
+}

Added: trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/ScopeTest.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/ScopeTest.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/ScopeTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,494 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.savara.bpel.model.DefaultBPELLanguageModel;
+import org.savara.bpel.model.component.CompensationHandler;
+import org.savara.bpel.model.component.EventHandlers;
+import org.savara.bpel.model.component.FaultHandlers;
+import org.savara.bpel.model.component.PartnerLink;
+import org.savara.bpel.model.component.Scope;
+import org.savara.bpel.model.component.Sequence;
+import org.savara.bpel.model.component.TerminationHandler;
+import org.savara.bpel.model.component.Variable;
+
+import junit.framework.TestCase;
+
+public class ScopeTest extends TestCase {
+
+	public void testIsActivity() {
+		Scope act=new Scope(new DefaultBPELLanguageModel(null));
+		
+		if (act.isActivity() == false) {
+			fail("Should be an activity");
+		}
+	}
+	
+	public void testScopeFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<scope xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+				"<partnerLinks><partnerLink/></partnerLinks>"+
+				"<variables><variable/></variables>"+
+				"<messageExchanges/>"+
+				"<correlationSets/>"+
+				"<eventHandlers/>"+
+				"<faultHandlers/>"+
+				"<compensationHandler/>"+
+				"<terminationHandler/>"+
+				"<sequence/>"+
+	       "</scope>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Scope component=new Scope(model, elem);
+		
+		if (component.getPartnerLinks().size() != 1) {
+			fail("Expecting 1 partner link: "+component.getPartnerLinks().size());
+		}
+		
+		if (component.getVariables().size() != 1) {
+			fail("Expecting 1 variable: "+component.getVariables().size());
+		}
+		
+		if (component.getActivity() == null) {
+			fail("Activity not defined");
+		}
+		
+		if (component.getCompensationHandler() == null) {
+			fail("Compensation handler not defined");
+		}
+		
+		if (component.getEventHandlers() == null) {
+			fail("Event handlers not defined");
+		}
+		
+		if (component.getFaultHandlers() == null) {
+			fail("Fault handlers not defined");
+		}
+		
+		if (component.getTerminationHandler() == null) {
+			fail("Termination handler not defined");
+		}
+	}
+	
+	public void testAddVariable() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<scope xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+				"<partnerLinks><partnerLink/></partnerLinks>"+
+				"<messageExchanges/>"+
+				"<correlationSets/>"+
+				"<eventHandlers/>"+
+				"<faultHandlers/>"+
+				"<compensationHandler/>"+
+				"<terminationHandler/>"+
+				"<sequence/>"+
+		   "</scope>";
+		
+		org.w3c.dom.Element ifelem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			ifelem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Scope component=new Scope(model, ifelem);
+
+		if (component.getVariables().size() != 0) {
+			fail("Should be no variables");
+		}
+		
+		Variable var=new Variable(model);
+		component.addVariable(var, 0);
+		
+		if (component.getVariables().size() != 1) {
+			fail("Should be one variable: "+component.getVariables().size());
+		}
+		
+		if (component.getDOMElement().getChildNodes().
+					item(0).getLocalName().equals("variables") == false) {
+			fail("Child 0 not as expected: "+component.getDOMElement().getChildNodes().
+					item(0).getLocalName());
+		}
+	}	
+	
+	public void testAddPartnerLink() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<scope xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+				"<variables><variable/></variables>"+
+				"<messageExchanges/>"+
+				"<correlationSets/>"+
+				"<eventHandlers/>"+
+				"<faultHandlers/>"+
+				"<compensationHandler/>"+
+				"<terminationHandler/>"+
+				"<sequence/>"+
+		   "</scope>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Scope component=new Scope(model, elem);
+
+		if (component.getPartnerLinks().size() != 0) {
+			fail("Should be no partner links");
+		}
+		
+		PartnerLink pl=new PartnerLink(model);
+		component.addPartnerLink(pl, 0);
+		
+		if (component.getPartnerLinks().size() != 1) {
+			fail("Should be one partner link: "+component.getPartnerLinks().size());
+		}
+		
+		if (component.getDOMElement().getChildNodes().
+					item(1).getLocalName().equals("partnerLinks") == false) {
+			fail("Child 1 not as expected: "+component.getDOMElement().getChildNodes().
+					item(1).getLocalName());
+		}
+	}	
+	
+	public void testSetEventHandlers() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<scope xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+				"<partnerLinks><partnerLink/></partnerLinks>"+
+				"<variables><variable/></variables>"+
+				"<messageExchanges/>"+
+				"<correlationSets/>"+
+				"<faultHandlers/>"+
+				"<compensationHandler/>"+
+				"<terminationHandler/>"+
+				"<sequence/>"+
+		   "</scope>";
+		
+		org.w3c.dom.Element ifelem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			ifelem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Scope component=new Scope(model, ifelem);
+
+		if (component.getEventHandlers() != null) {
+			fail("Should be null");
+		}
+		
+		EventHandlers elem=new EventHandlers(model);
+		component.setEventHandlers(elem);
+		
+		if (component.getEventHandlers() == null) {
+			fail("Should NOT be null");
+		}
+		
+		if (component.getDOMElement().getChildNodes().
+					item(4).getLocalName().equals("eventHandlers") == false) {
+			fail("Child 4 not as expected: "+component.getDOMElement().getChildNodes().
+					item(4).getLocalName());
+		}
+	}	
+	
+	public void testSetFaultHandlers() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<scope xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+				"<partnerLinks><partnerLink/></partnerLinks>"+
+				"<variables><variable/></variables>"+
+				"<messageExchanges/>"+
+				"<correlationSets/>"+
+				"<eventHandlers/>"+
+				"<compensationHandler/>"+
+				"<terminationHandler/>"+
+				"<sequence/>"+
+		   "</scope>";
+		
+		org.w3c.dom.Element ifelem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			ifelem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Scope component=new Scope(model, ifelem);
+
+		if (component.getFaultHandlers() != null) {
+			fail("Should be null");
+		}
+		
+		FaultHandlers elem=new FaultHandlers(model);
+		component.setFaultHandlers(elem);
+		
+		if (component.getFaultHandlers() == null) {
+			fail("Should NOT be null");
+		}
+		
+		if (component.getDOMElement().getChildNodes().
+					item(5).getLocalName().equals("faultHandlers") == false) {
+			fail("Child 5 not as expected: "+component.getDOMElement().getChildNodes().
+					item(5).getLocalName());
+		}
+	}	
+	
+	public void testSetCompensationHandler() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<scope xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+				"<partnerLinks><partnerLink/></partnerLinks>"+
+				"<variables><variable/></variables>"+
+				"<messageExchanges/>"+
+				"<correlationSets/>"+
+				"<eventHandlers/>"+
+				"<faultHandlers/>"+
+				"<terminationHandler/>"+
+				"<sequence/>"+
+		   "</scope>";
+		
+		org.w3c.dom.Element ifelem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			ifelem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Scope component=new Scope(model, ifelem);
+
+		if (component.getCompensationHandler() != null) {
+			fail("Should be null");
+		}
+		
+		CompensationHandler elem=new CompensationHandler(model);
+		component.setCompensationHandler(elem);
+		
+		if (component.getCompensationHandler() == null) {
+			fail("Should NOT be null");
+		}
+		
+		if (component.getDOMElement().getChildNodes().
+					item(6).getLocalName().equals("compensationHandler") == false) {
+			fail("Child 6 not as expected: "+component.getDOMElement().getChildNodes().
+					item(6).getLocalName());
+		}
+	}	
+	
+	public void testSetTerminationHandler() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<scope xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+				"<partnerLinks><partnerLink/></partnerLinks>"+
+				"<variables><variable/></variables>"+
+				"<messageExchanges/>"+
+				"<correlationSets/>"+
+				"<eventHandlers/>"+
+				"<faultHandlers/>"+
+				"<compensationHandler/>"+
+				"<sequence/>"+
+		   "</scope>";
+		
+		org.w3c.dom.Element ifelem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			ifelem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Scope component=new Scope(model, ifelem);
+
+		if (component.getTerminationHandler() != null) {
+			fail("Should be null");
+		}
+		
+		TerminationHandler elem=new TerminationHandler(model);
+		component.setTerminationHandler(elem);
+		
+		if (component.getTerminationHandler() == null) {
+			fail("Should NOT be null");
+		}
+		
+		if (component.getDOMElement().getChildNodes().
+					item(7).getLocalName().equals("terminationHandler") == false) {
+			fail("Child 7 not as expected: "+component.getDOMElement().getChildNodes().
+					item(7).getLocalName());
+		}
+	}	
+	
+	public void testSetActivity() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<scope xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+				"<partnerLinks><partnerLink/></partnerLinks>"+
+				"<variables><variable/></variables>"+
+				"<messageExchanges/>"+
+				"<correlationSets/>"+
+				"<eventHandlers/>"+
+				"<faultHandlers/>"+
+				"<compensationHandler/>"+
+				"<terminationHandler/>"+
+		   "</scope>";
+		
+		org.w3c.dom.Element ifelem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			ifelem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Scope component=new Scope(model, ifelem);
+
+		if (component.getActivity() != null) {
+			fail("Should be null");
+		}
+		
+		Sequence elem=new Sequence(model);
+		component.setActivity(elem);
+		
+		if (component.getActivity() == null) {
+			fail("Should NOT be null");
+		}
+		
+		if (component.getDOMElement().getChildNodes().
+					item(8).getLocalName().equals(Sequence.SEQUENCE) == false) {
+			fail("Child 8 not as expected: "+component.getDOMElement().getChildNodes().
+					item(8).getLocalName());
+		}
+	}	
+}

Added: trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/SequenceTest.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/SequenceTest.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/SequenceTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,337 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.savara.bpel.model.DefaultBPELLanguageModel;
+import org.savara.bpel.model.component.BPELActivity;
+import org.savara.bpel.model.component.Invoke;
+import org.savara.bpel.model.component.Process;
+import org.savara.bpel.model.component.Receive;
+import org.savara.bpel.model.component.Sequence;
+import org.savara.bpel.model.component.While;
+
+import junit.framework.TestCase;
+
+public class SequenceTest extends TestCase {
+
+	public void testIsActivity() {
+		Sequence act=new Sequence(new DefaultBPELLanguageModel(null));
+		
+		if (act.isActivity() == false) {
+			fail("Should be an activity");
+		}
+	}
+	
+	public void testSequenceFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<sequence xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+		       "<if/>"+
+		       "<if/>"+
+		       "</sequence>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Sequence component=new Sequence(model, elem);		
+		
+		if (component.getActivities().size() != 2) {
+			fail("Expecting 2 child activities: "+
+							component.getActivities().size());
+		}
+	}
+
+	public void testAddFirstActToSequenceInitFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<sequence xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+	       		"<targets/>"+
+	       		"<if/>"+
+	       		"<if/>"+
+	       		"</sequence>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Sequence component=new Sequence(model, elem);		
+		
+		if (component.getActivities().size() != 2) {
+			fail("Expecting 2 child activities: "+
+							component.getActivities().size());
+		}
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 3) {
+			fail("Three child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+
+		While sub=new While(model);
+		
+		component.addActivity(sub, 0);
+		
+		if (component.getActivities().size() != 3) {
+			fail("Expecting 3 child activities: "+
+							component.getActivities().size());
+		}
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 4) {
+			fail("Four child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+
+		if (component.getDOMElement().getChildNodes().item(1).
+				getLocalName().equals(While.WHILE) == false) {
+			fail("Second element was not a 'while': "+
+					component.getDOMElement().getChildNodes().item(1).
+									getLocalName());
+		}
+	}
+
+	public void testAddSecondActToSequenceInitFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<sequence xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+	       		"<targets/>"+
+	       		"<if/>"+
+	       		"<if/>"+
+	       		"</sequence>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Sequence component=new Sequence(model, elem);		
+		
+		if (component.getActivities().size() != 2) {
+			fail("Expecting 2 child activities: "+
+							component.getActivities().size());
+		}
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 3) {
+			fail("Three child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+
+		While sub=new While(model);
+		
+		component.addActivity(sub, 1);
+		
+		if (component.getActivities().size() != 3) {
+			fail("Expecting 3 child activities: "+
+							component.getActivities().size());
+		}
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 4) {
+			fail("Four child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+
+		if (component.getDOMElement().getChildNodes().item(2).
+				getLocalName().equals(While.WHILE) == false) {
+			fail("Second element was not a 'while': "+
+					component.getDOMElement().getChildNodes().item(2).
+									getLocalName());
+		}
+	}
+
+	public void testAddLastActToSequenceInitFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<sequence xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+	       		"<targets/>"+
+	       		"<if/>"+
+	       		"<if/>"+
+	       		"</sequence>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Sequence component=new Sequence(model, elem);		
+		
+		if (component.getActivities().size() != 2) {
+			fail("Expecting 2 child activities: "+
+							component.getActivities().size());
+		}
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 3) {
+			fail("Three child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+
+		While sub=new While(model);
+		
+		component.addActivity(sub, -1);
+		
+		if (component.getActivities().size() != 3) {
+			fail("Expecting 3 child activities: "+
+							component.getActivities().size());
+		}
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 4) {
+			fail("Four child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+
+		if (component.getDOMElement().getChildNodes().item(3).
+				getLocalName().equals(While.WHILE) == false) {
+			fail("Second element was not a 'while': "+
+					component.getDOMElement().getChildNodes().item(3).
+									getLocalName());
+		}
+	}
+	
+	public void testGetURI() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<process xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+	       		"<sequence>"+
+	       			"<receive/>"+
+	       			"<invoke/>"+
+	       		"</sequence>"+
+	       		"</process>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			e.printStackTrace();
+			fail("Failed to convert to doc");
+		}
+		
+		Process component=new Process(model, elem);		
+		
+		BPELActivity act=component.getActivity();
+		
+		if ((act instanceof Sequence) == false) {
+			fail("Activity is not a sequence");
+		}
+		
+		Sequence seq=(Sequence)act;
+		
+		if (seq.getActivities().size() != 2) {
+			fail("Expecting 2 child activities: "+
+							seq.getActivities().size());
+		}
+		
+		if ((seq.getActivities().get(0) instanceof Receive) == false) {
+			fail("First activity should be receive");
+		}
+		
+		if ((seq.getActivities().get(1) instanceof Invoke) == false) {
+			fail("Second activity should be invoke");
+		}
+		
+		Invoke invoke=(Invoke)seq.getActivities().get(1);
+		
+		String uri=invoke.getURI();
+		
+		if (uri == null) {
+			fail("URI is null");
+		}
+		
+		if (uri.equals("//@activity/@activities.1") == false) {
+			fail("URI is invalid: "+uri);
+		}
+	}
+}

Added: trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/TerminationHandlerTest.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/TerminationHandlerTest.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/TerminationHandlerTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.savara.bpel.model.DefaultBPELLanguageModel;
+import org.savara.bpel.model.component.Sequence;
+import org.savara.bpel.model.component.TerminationHandler;
+
+import junit.framework.TestCase;
+
+public class TerminationHandlerTest extends TestCase {
+
+	public void testIsActivity() {
+		TerminationHandler act=
+				new TerminationHandler(new DefaultBPELLanguageModel(null));
+		
+		if (act.isActivity() == true) {
+			fail("Should NOT be an activity");
+		}
+	}
+	
+	public void testBuildTerminationHandler() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<terminationHandler xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">" +
+				"<sequence/></terminationHandler>";
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+			
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		TerminationHandler construct=new TerminationHandler(model, elem);		
+		
+		if (construct.getActivity() == null) {
+			fail("No activity");
+		}
+		
+		if ((construct.getActivity() instanceof Sequence) == false) {
+			fail("Activity is not a sequence");
+		}
+	}
+}

Added: trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/TestAbstractInteraction.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/TestAbstractInteraction.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/TestAbstractInteraction.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import java.util.List;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.savara.bpel.model.component.AbstractInteraction;
+import org.savara.bpel.model.component.ConversionContext;
+import org.scribble.model.Activity;
+import org.w3c.dom.Element;
+
+public class TestAbstractInteraction extends AbstractInteraction {
+
+	private static final long serialVersionUID = 8254837781661826397L;
+
+	public TestAbstractInteraction(BPELLanguageModel model, Element elem) {
+		super(model, elem);
+	}
+	
+	public TestAbstractInteraction(BPELLanguageModel model) {
+		super(model, "test");
+	}
+
+	/**
+	 * This method does the actual work of converting the specific
+	 * BPEL activity into an equivalent behavioural description for 
+	 * conformance checking. The 'convert' method provides
+	 * a wrapper around this method, to handle the standard elements
+	 * that can be associated with any BPEL activity.
+	 * 
+	 * @param activities The list of activities that will contain
+	 * 				the converted action(s)
+	 * @param context The conversion context
+	 */
+	protected void convertActivity(java.util.List<Activity> activities,
+			ConversionContext context) {
+		// TODO Auto-generated method stub
+		
+	}
+}

Added: trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/TestBPELActivity.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/TestBPELActivity.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/TestBPELActivity.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import java.util.List;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.savara.bpel.model.component.BPELActivity;
+import org.savara.bpel.model.component.ConversionContext;
+import org.scribble.model.Activity;
+import org.w3c.dom.Element;
+
+public class TestBPELActivity extends BPELActivity {
+
+	private static final long serialVersionUID = 6706918585744310399L;
+
+	public TestBPELActivity(BPELLanguageModel model, Element elem) {
+		super(model, elem);
+	}
+	
+	public TestBPELActivity(BPELLanguageModel model) {
+		super(model, "test");
+	}
+
+	/**
+	 * This method does the actual work of converting the specific
+	 * BPEL activity into an equivalent behavioural description for 
+	 * conformance checking. The 'convert' method provides
+	 * a wrapper around this method, to handle the standard elements
+	 * that can be associated with any BPEL activity.
+	 * 
+	 * @param activities The list of activities that will contain
+	 * 				the converted action(s)
+	 * @param context The conversion context
+	 */
+	protected void convertActivity(java.util.List<Activity> activities,
+			ConversionContext context) {
+		// TODO Auto-generated method stub
+		
+	}
+}

Added: trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/TestBPELElement.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/TestBPELElement.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/TestBPELElement.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import java.util.List;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.savara.bpel.model.component.BPELElement;
+import org.savara.bpel.model.component.ConversionContext;
+import org.scribble.model.Activity;
+import org.w3c.dom.Element;
+
+public class TestBPELElement extends BPELElement {
+
+	private static final long serialVersionUID = 6428569513605691840L;
+
+	public TestBPELElement(BPELLanguageModel model, Element elem) {
+		super(model, elem);
+	}
+	
+	public TestBPELElement(BPELLanguageModel model) {
+		super(model, "test");
+	}
+
+	@Override
+	public void convert(List<Activity> activities, ConversionContext context) {
+		// TODO Auto-generated method stub
+		
+	}
+
+}

Added: trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/ThrowTest.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/ThrowTest.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/ThrowTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,119 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.savara.bpel.model.DefaultBPELLanguageModel;
+import org.savara.bpel.model.component.Throw;
+
+import junit.framework.TestCase;
+
+public class ThrowTest extends TestCase {
+
+	public void testIsActivity() {
+		Throw act=
+			new Throw(new DefaultBPELLanguageModel(null));
+		
+		if (act.isActivity() == false) {
+			fail("Should be an activity");
+		}
+	}
+	
+	public void testBuildFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String var="testVar";
+		String fault="testFault";
+		
+		String xml="<throw xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\" "+
+		       "faultVariable=\""+var+"\" "+
+		       "faultName=\""+fault+"\" "+
+		       "/>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Throw component=new Throw(model, elem);		
+		
+		if (component.getFaultVariable().equals(var) == false) {
+			fail("Fault Variable not correct, expecting '"+var+"': "+
+							component.getFaultVariable());
+		}
+		
+		if (component.getFaultName().equals(fault) == false) {
+			fail("Fault not correct, expecting '"+fault+"': "+
+							component.getFaultName());
+		}
+	}
+
+	public void testGetFaultVariable() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String var="testVariable";
+		
+		Throw component=new Throw(model);		
+		
+		if (component.getFaultVariable() != null) {
+			fail("Should be null");
+		}
+		
+		component.setFaultVariable(var);
+		
+		if (component.getFaultVariable().equals(var) == false) {
+			fail("Fault Variable not correct, expecting '"+var+"': "+
+							component.getFaultVariable());
+		}
+	}
+
+	public void testGetFaultName() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String fault="testFault";
+		
+		Throw component=new Throw(model);		
+		
+		if (component.getFaultName() != null) {
+			fail("Should be null");
+		}
+		
+		component.setFaultName(fault);
+		
+		if (component.getFaultName().equals(fault) == false) {
+			fail("Fault name not correct, expecting '"+fault+"': "+
+							component.getFaultName());
+		}
+	}
+}

Added: trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/VariableTest.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/VariableTest.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/VariableTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,119 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.savara.bpel.model.DefaultBPELLanguageModel;
+import org.savara.bpel.model.component.Variable;
+
+import junit.framework.TestCase;
+
+public class VariableTest extends TestCase {
+
+	public void testIsActivity() {
+		Variable act=
+			new Variable(new DefaultBPELLanguageModel(null));
+		
+		if (act.isActivity() == true) {
+			fail("Should NOT be an activity");
+		}
+	}
+	
+	public void testBuildFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String var="testVar";
+		String type="testType";
+		
+		String xml="<variable xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\" "+
+		       "name=\""+var+"\" "+
+		       "type=\""+type+"\" "+
+		       "/>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Variable component=new Variable(model, elem);		
+		
+		if (component.getName().equals(var) == false) {
+			fail("Variable name not correct, expecting '"+var+"': "+
+							component.getName());
+		}
+		
+		if (component.getType().equals(type) == false) {
+			fail("Type not correct, expecting '"+type+"': "+
+							component.getType());
+		}
+	}
+
+	public void testGetVariableName() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String var="testVariable";
+		
+		Variable component=new Variable(model);		
+		
+		if (component.getName() != null) {
+			fail("Should be null");
+		}
+		
+		component.setName(var);
+		
+		if (component.getName().equals(var) == false) {
+			fail("Variable name not correct, expecting '"+var+"': "+
+							component.getName());
+		}
+	}
+
+	public void testGetType() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String type="testType";
+		
+		Variable component=new Variable(model);		
+		
+		if (component.getType() != null) {
+			fail("Should be null");
+		}
+		
+		component.setType(type);
+		
+		if (component.getType().equals(type) == false) {
+			fail("Type not correct, expecting '"+type+"': "+
+							component.getType());
+		}
+	}
+}

Added: trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/WaitTest.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/WaitTest.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/WaitTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,621 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.savara.bpel.model.DefaultBPELLanguageModel;
+import org.savara.bpel.model.component.Condition;
+import org.savara.bpel.model.component.Wait;
+
+import junit.framework.TestCase;
+
+public class WaitTest extends TestCase {
+
+	public void testIsActivity() {
+		Wait act=
+			new Wait(new DefaultBPELLanguageModel(null));
+		
+		if (act.isActivity() == false) {
+			fail("Should be an activity");
+		}
+	}
+
+	public void testUntilFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String expr1="Test Expression 1";
+		
+		String xml="<wait xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+		       "<until>"+expr1+"</until>"+
+		       "</wait>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Wait component=new Wait(model, elem);		
+		
+		if (component.getUntil() == null) {
+			fail("Condition not set");
+		}
+		
+		if (component.getFor() != null) {
+			fail("For condition should is set");
+		}
+		
+		String result=component.getUntil().getExpression();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(expr1) == false) {
+			fail("Expression is not valid: expecting '"+
+					expr1+"' but got '"+result+"'");
+		}
+	}
+
+	public void testForFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String expr1="Test Expression 1";
+		
+		String xml="<wait xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+		       "<for>"+expr1+"</for>"+
+		       "</wait>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Wait component=new Wait(model, elem);		
+		
+		if (component.getFor() == null) {
+			fail("Condition not set");
+		}
+		
+		if (component.getUntil() != null) {
+			fail("For condition should is set");
+		}
+		
+		String result=component.getFor().getExpression();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(expr1) == false) {
+			fail("Expression is not valid: expecting '"+
+					expr1+"' but got '"+result+"'");
+		}
+	}
+
+	public void testSetUntilNew() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String expr1="Test Expression 1";
+		
+		String xml="<until xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+		       expr1+
+		       "</until>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Condition condition=new Condition(model, elem);
+		
+		Wait component=new Wait(model);
+		
+		component.setUntil(condition);
+		
+		if (component.getUntil() == null) {
+			fail("Condition not set");
+		}
+		
+		if (component.getFor() != null) {
+			fail("For condition should not be set");
+		}
+		
+		String result=component.getUntil().getExpression();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(expr1) == false) {
+			fail("Expression is not valid: expecting '"+
+					expr1+"' but got '"+result+"'");
+		}
+	}	
+	
+	public void testSetUntilReplace() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String expr1="Test Expression 1";
+		String expr2="Test Expression 2";
+		
+		String xml1="<until xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+	       		expr1+
+	       		"</until>";
+	
+		String xml2="<until xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+	       		expr2+
+	       		"</until>";
+	
+		org.w3c.dom.Element elem1=null;
+		org.w3c.dom.Element elem2=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml1.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem1 = doc.getDocumentElement();
+			
+			is.close();
+			
+			is=new java.io.ByteArrayInputStream(xml2.getBytes());
+			
+			doc=builder.parse(is);
+			elem2 = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Condition condition1=new Condition(model, elem1);
+		
+		Wait component=new Wait(model);
+		
+		component.setUntil(condition1);
+		
+		if (component.getUntil() == null) {
+			fail("Condition not set");
+		}
+		
+		if (component.getFor() != null) {
+			fail("For condition should not be set");
+		}
+		
+		String result=component.getUntil().getExpression();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(expr1) == false) {
+			fail("Expression1 is not valid: expecting '"+
+					expr1+"' but got '"+result+"'");
+		}
+
+		Condition condition2=new Condition(model, elem2);
+		
+		component.setUntil(condition2);
+		
+		if (component.getUntil() == null) {
+			fail("Condition not set");
+		}
+
+		if (component.getFor() != null) {
+			fail("For condition should still not be set");
+		}
+		
+		result=component.getUntil().getExpression();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(expr2) == false) {
+			fail("Expression2 is not valid: expecting '"+
+					expr2+"' but got '"+result+"'");
+		}
+	}		
+
+	public void testSetForNew() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String expr1="Test Expression 1";
+		
+		String xml="<for xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+		       expr1+
+		       "</for>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Condition condition=new Condition(model, elem);
+		
+		Wait component=new Wait(model);
+		
+		component.setFor(condition);
+		
+		if (component.getFor() == null) {
+			fail("Condition not set");
+		}
+		
+		if (component.getUntil() != null) {
+			fail("Until condition should not be set");
+		}
+		
+		String result=component.getFor().getExpression();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(expr1) == false) {
+			fail("Expression is not valid: expecting '"+
+					expr1+"' but got '"+result+"'");
+		}
+	}	
+	
+	public void testSetForReplace() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String expr1="Test Expression 1";
+		String expr2="Test Expression 2";
+		
+		String xml1="<for xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+	       		expr1+
+	       		"</for>";
+	
+		String xml2="<for xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+	       		expr2+
+	       		"</for>";
+	
+		org.w3c.dom.Element elem1=null;
+		org.w3c.dom.Element elem2=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml1.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem1 = doc.getDocumentElement();
+			
+			is.close();
+			
+			is=new java.io.ByteArrayInputStream(xml2.getBytes());
+			
+			doc=builder.parse(is);
+			elem2 = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Condition condition1=new Condition(model, elem1);
+		
+		Wait component=new Wait(model);
+		
+		component.setFor(condition1);
+		
+		if (component.getFor() == null) {
+			fail("Condition not set");
+		}
+		
+		if (component.getUntil() != null) {
+			fail("Until condition should not be set");
+		}
+		
+		String result=component.getFor().getExpression();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(expr1) == false) {
+			fail("Expression1 is not valid: expecting '"+
+					expr1+"' but got '"+result+"'");
+		}
+
+		Condition condition2=new Condition(model, elem2);
+		
+		component.setFor(condition2);
+		
+		if (component.getFor() == null) {
+			fail("Condition not set");
+		}
+
+		if (component.getUntil() != null) {
+			fail("Until condition should still not be set");
+		}
+		
+		result=component.getFor().getExpression();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(expr2) == false) {
+			fail("Expression2 is not valid: expecting '"+
+					expr2+"' but got '"+result+"'");
+		}
+	}		
+
+	public void testSetForThenUntil() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String expr1="Test Expression 1";
+		String expr2="Test Expression 2";
+		
+		String xml1="<for xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+	       		expr1+
+	       		"</for>";
+	
+		String xml2="<until xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+	       		expr2+
+	       		"</until>";
+	
+		org.w3c.dom.Element elem1=null;
+		org.w3c.dom.Element elem2=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml1.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem1 = doc.getDocumentElement();
+			
+			is.close();
+			
+			is=new java.io.ByteArrayInputStream(xml2.getBytes());
+			
+			doc=builder.parse(is);
+			elem2 = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Condition condition1=new Condition(model, elem1);
+		
+		Wait component=new Wait(model);
+		
+		component.setFor(condition1);
+		
+		if (component.getFor() == null) {
+			fail("Condition not set");
+		}
+		
+		if (component.getUntil() != null) {
+			fail("Until condition should not be set");
+		}
+		
+		String result=component.getFor().getExpression();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(expr1) == false) {
+			fail("Expression1 is not valid: expecting '"+
+					expr1+"' but got '"+result+"'");
+		}
+
+		Condition condition2=new Condition(model, elem2);
+		
+		component.setUntil(condition2);
+		
+		if (component.getUntil() == null) {
+			fail("Condition not set");
+		}
+
+		if (component.getFor() != null) {
+			fail("For condition should still not be set");
+		}
+		
+		result=component.getUntil().getExpression();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(expr2) == false) {
+			fail("Expression2 is not valid: expecting '"+
+					expr2+"' but got '"+result+"'");
+		}
+	}		
+
+	public void testSetUntilThenFor() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String expr1="Test Expression 1";
+		String expr2="Test Expression 2";
+		
+		String xml1="<until xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+	       		expr1+
+	       		"</until>";
+	
+		String xml2="<for xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+	       		expr2+
+	       		"</for>";
+	
+		org.w3c.dom.Element elem1=null;
+		org.w3c.dom.Element elem2=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml1.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem1 = doc.getDocumentElement();
+			
+			is.close();
+			
+			is=new java.io.ByteArrayInputStream(xml2.getBytes());
+			
+			doc=builder.parse(is);
+			elem2 = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Condition condition1=new Condition(model, elem1);
+		
+		Wait component=new Wait(model);
+		
+		component.setUntil(condition1);
+		
+		if (component.getUntil() == null) {
+			fail("Condition not set");
+		}
+		
+		if (component.getFor() != null) {
+			fail("For condition should not be set");
+		}
+		
+		String result=component.getUntil().getExpression();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(expr1) == false) {
+			fail("Expression1 is not valid: expecting '"+
+					expr1+"' but got '"+result+"'");
+		}
+
+		Condition condition2=new Condition(model, elem2);
+		
+		component.setFor(condition2);
+		
+		if (component.getFor() == null) {
+			fail("Condition not set");
+		}
+
+		if (component.getUntil() != null) {
+			fail("Until condition should still not be set");
+		}
+		
+		result=component.getFor().getExpression();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(expr2) == false) {
+			fail("Expression2 is not valid: expecting '"+
+					expr2+"' but got '"+result+"'");
+		}
+	}		
+}

Added: trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/WhileTest.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/WhileTest.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/component/WhileTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,478 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.component;
+
+import org.savara.bpel.model.BPELLanguageModel;
+import org.savara.bpel.model.DefaultBPELLanguageModel;
+import org.savara.bpel.model.component.BPELActivity;
+import org.savara.bpel.model.component.Condition;
+import org.savara.bpel.model.component.If;
+import org.savara.bpel.model.component.Receive;
+import org.savara.bpel.model.component.Sequence;
+import org.savara.bpel.model.component.While;
+
+import junit.framework.TestCase;
+
+public class WhileTest extends TestCase {
+
+	public void testIsActivity() {
+		While act=new While(new DefaultBPELLanguageModel(null));
+		
+		if (act.isActivity() == false) {
+			fail("Should be an activity");
+		}
+	}
+	
+	public void testFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String expr1="Test Expression 1";
+		
+		String xml="<while xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+		       "<condition>"+expr1+"</condition>"+
+		       "<sequence/>"+
+		       "</while>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		While component=new While(model, elem);		
+		
+		if (component.getCondition() == null) {
+			fail("Condition not set");
+		}
+		
+		String result=component.getCondition().getExpression();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(expr1) == false) {
+			fail("Expression is not valid: expecting '"+
+					expr1+"' but got '"+result+"'");
+		}
+		
+		if (component.getActivity() == null) {
+			fail("Activity not set");
+		}
+		
+		if ((component.getActivity() instanceof Sequence) == false) {
+			fail("Activity not a sequence");
+		}
+	}
+	
+	public void testSetConditionInitFromDOM() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String expr1="Test Expression 1";
+		
+		String xml="<while xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+			   "<targets/>"+
+		       "<sequence/>"+
+		       "</while>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		While component=new While(model, elem);		
+		
+		if (component.getActivity() == null) {
+			fail("Activity should be set");
+		}
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 2) {
+			fail("Two child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+
+		Condition cond=new Condition(model);
+		
+		cond.setExpression(expr1);
+		
+		component.setCondition(cond);
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 3) {
+			fail("Three child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+		
+		if (component.getDOMElement().getChildNodes().item(1).
+				getLocalName().equals(Condition.CONDITION) == false) {
+			fail("Second element was not a 'condition': "+
+					component.getDOMElement().getChildNodes().item(1).
+									getLocalName());
+		}
+	}
+	
+	public void testSetConditionNew() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String expr1="Test Expression 1";
+		
+		String xml="<condition xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+		       expr1+
+		       "</condition>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Condition condition=new Condition(model, elem);
+		
+		While component=new While(model);
+		
+		component.setCondition(condition);
+		
+		if (component.getCondition() == null) {
+			fail("Condition not set");
+		}
+		
+		String result=component.getCondition().getExpression();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(expr1) == false) {
+			fail("Expression is not valid: expecting '"+
+					expr1+"' but got '"+result+"'");
+		}
+	}	
+	
+	public void testSetConditionReplace() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String expr1="Test Expression 1";
+		String expr2="Test Expression 2";
+		
+		String xml1="<condition xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+	       		expr1+
+	       		"</condition>";
+	
+		String xml2="<condition xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+	       		expr2+
+	       		"</condition>";
+	
+		org.w3c.dom.Element elem1=null;
+		org.w3c.dom.Element elem2=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml1.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem1 = doc.getDocumentElement();
+			
+			is.close();
+			
+			is=new java.io.ByteArrayInputStream(xml2.getBytes());
+			
+			doc=builder.parse(is);
+			elem2 = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		Condition condition1=new Condition(model, elem1);
+		
+		While component=new While(model);
+		
+		component.setCondition(condition1);
+		
+		if (component.getCondition() == null) {
+			fail("Condition not set");
+		}
+		
+		String result=component.getCondition().getExpression();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(expr1) == false) {
+			fail("Expression1 is not valid: expecting '"+
+					expr1+"' but got '"+result+"'");
+		}
+
+		Condition condition2=new Condition(model, elem2);
+		
+		component.setCondition(condition2);
+		
+		if (component.getCondition() == null) {
+			fail("Condition not set");
+		}
+		
+		result=component.getCondition().getExpression();
+		
+		if (result == null) {
+			fail("Expression is null");
+		}
+		
+		if (result.equals(expr2) == false) {
+			fail("Expression2 is not valid: expecting '"+
+					expr2+"' but got '"+result+"'");
+		}
+	}	
+	
+	public void testSetActivityNew() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<while xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+		       "<condition/>"+
+		       "</while>";
+		
+		org.w3c.dom.Element ifelem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			ifelem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		While component=new While(model, ifelem);
+
+		if (component.getActivity() != null) {
+			fail("Activity should be null");
+		}
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 1) {
+			fail("One child element expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+		
+		Sequence seq=new Sequence(model);
+		
+		component.setActivity(seq);
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 2) {
+			fail("Two child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+		
+		if (component.getDOMElement().getChildNodes().item(1).
+				getLocalName().equals(Sequence.SEQUENCE) == false) {
+			fail("Second element was not a sequence: "+
+					component.getDOMElement().getChildNodes().item(1).
+									getLocalName());
+		}
+	}	
+	
+	public void testSetActivityReplace() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<while xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+		       "<condition/>"+
+		       "<sequence/>"+
+		       "</while>";
+		
+		org.w3c.dom.Element ifelem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			ifelem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			fail("Failed to convert to doc");
+		}
+		
+		While component=new While(model, ifelem);
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 2) {
+			fail("Two child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+		
+		If sub=new If(model);
+		
+		component.setActivity(sub);
+		
+		if (component.getDOMElement().getChildNodes().getLength() != 2) {
+			fail("Two child elements expected: "+
+					component.getDOMElement().getChildNodes().getLength());
+		}
+		
+		if (component.getDOMElement().getChildNodes().item(1).
+				getLocalName().equals(If.IF) == false) {
+			fail("Second element was not an 'if': "+
+					component.getDOMElement().getChildNodes().item(1).
+									getLocalName());
+		}
+	}	
+
+	public void testGetURI() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<process xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+					"<while xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+		       		"<sequence>"+
+	       			"<receive/>"+
+       			"</sequence>"+
+		       "</while>"+
+	       		"</process>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			e.printStackTrace();
+			fail("Failed to convert to doc");
+		}
+		
+		org.savara.bpel.model.component.Process component=
+			new org.savara.bpel.model.component.Process(model, elem);		
+		
+		BPELActivity topact=component.getActivity();
+		
+		if ((topact instanceof While) == false) {
+			fail("Top level activity is not While");
+		}
+		
+		While top=(While)topact;
+		
+		if (top.getActivity() == null) {
+			fail("While activity is null");
+		}
+		
+		if ((top.getActivity() instanceof Sequence) == false) {
+			fail("While activity is not sequence");
+		}
+		
+		Sequence seq=(Sequence)top.getActivity();
+		
+		if (seq.getActivities().size() != 1) {
+			fail("Should have 1 activity: "+seq.getActivities().size());
+		}
+		
+		if ((seq.getActivities().get(0) instanceof Receive) == false) {
+			fail("Activty should be Receive");
+		}
+				
+		Receive recv=(Receive)seq.getActivities().get(0);
+		
+		String uri=recv.getURI();
+		
+		if (uri == null) {
+			fail("URI is null");
+		}
+		
+		if (uri.equals("//@activity/@activity/@activities.0") == false) {
+			fail("URI is invalid: "+uri);
+		}
+	}	
+}

Added: trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/util/InteractionUtilTest.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/util/InteractionUtilTest.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/util/InteractionUtilTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,91 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.model.util;
+
+import junit.framework.TestCase;
+
+import org.scribble.conversation.model.*;
+import org.scribble.model.*;
+
+public class InteractionUtilTest extends TestCase {
+
+	public void testIsFirstInteractionSingleInteraction() {
+		ConversationModel cm=new ConversationModel();
+		Conversation c=new Conversation();
+		cm.setConversation(c);
+		
+		Interaction i1=new Interaction();
+		
+		c.getBlock().getContents().add(i1);
+		
+		if (org.scribble.model.util.InteractionUtil.isInitialInteraction(i1) == false) {
+			fail("Interaction should be first in conversation");
+		}
+	}
+
+	public void testIsFirstInteractionSecondInteraction() {
+		ConversationModel cm=new ConversationModel();
+		Conversation c=new Conversation();
+		cm.setConversation(c);
+		
+		Interaction i1=new Interaction();
+		Interaction i2=new Interaction();
+		
+		c.getBlock().getContents().add(i1);
+		c.getBlock().getContents().add(i2);
+		
+		if (org.scribble.model.util.InteractionUtil.isInitialInteraction(i2)) {
+			fail("Interaction should NOT be first in conversation");
+		}
+	}
+	
+	public void testIsFirstInteractionIfElse() {
+		ConversationModel cm=new ConversationModel();
+		Conversation c=new Conversation();
+		cm.setConversation(c);
+		
+		If choice=new If();
+		c.getBlock().getContents().add(choice);
+		
+		Block b=choice.createNewPath();
+		
+		Interaction i1=new Interaction();
+		
+		b.getContents().add(i1);
+		
+		Block b2=choice.createNewPath();
+		
+		Interaction i2=new Interaction();
+		Interaction i3=new Interaction();
+		
+		b2.getContents().add(i2);
+		b2.getContents().add(i3);
+		
+		if (org.scribble.model.util.InteractionUtil.isInitialInteraction(i1) == false) {
+			fail("Interaction should be first in conversation");
+		}
+		
+		if (org.scribble.model.util.InteractionUtil.isInitialInteraction(i2) == false) {
+			fail("Interaction should be first in conversation");
+		}
+		
+		if (org.scribble.model.util.InteractionUtil.isInitialInteraction(i3)) {
+			fail("Interaction should NOT be first in conversation");
+		}
+	}	
+}

Added: trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/util/XMLUtilsTest.java
===================================================================
--- trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/util/XMLUtilsTest.java	                        (rev 0)
+++ trunk/bundles/org.savara.bpel/src/test/java/org/savara/bpel/util/XMLUtilsTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,172 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.bpel.util;
+
+import org.savara.util.XMLUtils;
+import org.scribble.model.ModelObject;
+
+import junit.framework.TestCase;
+
+public class XMLUtilsTest extends TestCase {
+
+	public void testNamespace() {
+		String namespace="http://namespace";
+		String elemName="testElement";
+
+		String expected="<"+elemName+" xmlns=\""+namespace+"\"/>\r\n";
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.
+							newInstance();
+			factory.setNamespaceAware(true);
+			
+			org.w3c.dom.Document doc=
+					factory.newDocumentBuilder().newDocument();
+
+			org.w3c.dom.Element elem=
+					doc.createElementNS(namespace, elemName);
+			
+			String str=XMLUtils.toText(elem);
+			
+			if (str.equals(expected) == false) {
+				fail("Expected result '"+expected+"', got: '"+str+"'");
+			}
+			
+		} catch(Exception e) {
+			fail("Failed: "+e);
+		}
+	}
+	
+	public void testSetStartAndEndPosition() {
+		String xml="<root><myelem></myelem><myelem></myelem></root>";
+		
+		try {
+			org.w3c.dom.Element node=(org.w3c.dom.Element)XMLUtils.getNode(xml);
+			
+			org.w3c.dom.NodeList nl=node.getElementsByTagName("myelem");
+			
+			if (nl.getLength() != 2) {
+				fail("Should be two elements: "+nl.getLength());
+			}
+			
+			ModelObject obj=new ModelObject(){};
+			
+			XMLUtils.setStartAndEndPosition(obj, xml, (org.w3c.dom.Element)nl.item(1));
+			
+			if (obj.getSource().getStartPosition() != 23) {
+				fail("Start position should be 23: "+obj.getSource().getStartPosition());
+			}
+			
+			if (obj.getSource().getEndPosition() != 39) {
+				fail("End position should be 39: "+obj.getSource().getEndPosition());
+			}
+
+		} catch(Exception e) {
+			fail("Failed: "+e);
+		}
+	}
+	
+	public void testSetStartAndEndPositionWithNS() {
+		String xml="<bpel:root xmlns:bpel=\"myns\" ><bpel:myelem></bpel:myelem><bpel:myelem></bpel:myelem></bpel:root>";
+		
+		try {
+			org.w3c.dom.Element node=(org.w3c.dom.Element)XMLUtils.getNode(xml);
+			
+			org.w3c.dom.NodeList nl=node.getElementsByTagNameNS("myns", "myelem");
+			
+			if (nl.getLength() != 2) {
+				fail("Should be two elements: "+nl.getLength());
+			}
+			
+			ModelObject obj=new ModelObject(){};
+			
+			XMLUtils.setStartAndEndPosition(obj, xml, (org.w3c.dom.Element)nl.item(1));
+			
+			if (obj.getSource().getStartPosition() != 57) {
+				fail("Start position should be 57: "+obj.getSource().getStartPosition());
+			}
+			
+			if (obj.getSource().getEndPosition() != 83) {
+				fail("End position should be 83: "+obj.getSource().getEndPosition());
+			}
+
+		} catch(Exception e) {
+			fail("Failed: "+e);
+		}
+	}
+	
+	public void testSetStartAndEndPositionSingleNodeWithNS() {
+		String xml="<bpel:root xmlns:bpel=\"myns\" ><bpel:myelem attr=\"1\" /><bpel:myelem attr=\"2\" /></bpel:root>";
+		
+		try {
+			org.w3c.dom.Element node=(org.w3c.dom.Element)XMLUtils.getNode(xml);
+			
+			org.w3c.dom.NodeList nl=node.getElementsByTagNameNS("myns", "myelem");
+			
+			if (nl.getLength() != 2) {
+				fail("Should be two elements: "+nl.getLength());
+			}
+			
+			ModelObject obj=new ModelObject(){};
+			
+			XMLUtils.setStartAndEndPosition(obj, xml, (org.w3c.dom.Element)nl.item(1));
+			
+			if (obj.getSource().getStartPosition() != 54) {
+				fail("Start position should be 54: "+obj.getSource().getStartPosition());
+			}
+			
+			if (obj.getSource().getEndPosition() != 77) {
+				fail("End position should be 77: "+obj.getSource().getEndPosition());
+			}
+
+		} catch(Exception e) {
+			fail("Failed: "+e);
+		}
+	}
+	
+	public void testSetStartAndEndPositionWithChildAndNS() {
+		String xml="<bpel:root xmlns:bpel=\"myns\" ><bpel:myelem></bpel:myelem>" +
+				"<bpel:myelem><bpel:myelem></bpel:myelem></bpel:myelem></bpel:root>";
+		
+		try {
+			org.w3c.dom.Element node=(org.w3c.dom.Element)XMLUtils.getNode(xml);
+			
+			org.w3c.dom.NodeList nl=node.getElementsByTagNameNS("myns", "myelem");
+			
+			if (nl.getLength() != 3) {
+				fail("Should be three elements: "+nl.getLength());
+			}
+			
+			ModelObject obj=new ModelObject(){};
+			
+			XMLUtils.setStartAndEndPosition(obj, xml, (org.w3c.dom.Element)nl.item(1));
+			
+			if (obj.getSource().getStartPosition() != 57) {
+				fail("Start position should be 57: "+obj.getSource().getStartPosition());
+			}
+			
+			if (obj.getSource().getEndPosition() != 110) {
+				fail("End position should be 110: "+obj.getSource().getEndPosition());
+			}
+
+		} catch(Exception e) {
+			fail("Failed: "+e);
+		}
+	}
+}

Added: trunk/bundles/org.savara.contract.model/.classpath
===================================================================
--- trunk/bundles/org.savara.contract.model/.classpath	                        (rev 0)
+++ trunk/bundles/org.savara.contract.model/.classpath	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src/main/java"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

Added: trunk/bundles/org.savara.contract.model/.project
===================================================================
--- trunk/bundles/org.savara.contract.model/.project	                        (rev 0)
+++ trunk/bundles/org.savara.contract.model/.project	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.savara.contract.model</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.ManifestBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.SchemaBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.pde.PluginNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

Added: trunk/bundles/org.savara.contract.model/Copyright.txt
===================================================================
--- trunk/bundles/org.savara.contract.model/Copyright.txt	                        (rev 0)
+++ trunk/bundles/org.savara.contract.model/Copyright.txt	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,17 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */

Added: trunk/bundles/org.savara.contract.model/META-INF/MANIFEST.MF
===================================================================
--- trunk/bundles/org.savara.contract.model/META-INF/MANIFEST.MF	                        (rev 0)
+++ trunk/bundles/org.savara.contract.model/META-INF/MANIFEST.MF	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,11 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: SAVARA Contract Model
+Bundle-SymbolicName: org.savara.contract.model
+Bundle-Version: 1.2.0.qualifier
+Bundle-Activator: org.savara.contract.model.osgi.Activator
+Bundle-Vendor: www.savara.org
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Import-Package: org.osgi.framework
+Require-Bundle: org.scribble.core;bundle-version="[1.0.0,2.0.0)"
+Export-Package: org.savara.contract.model

Added: trunk/bundles/org.savara.contract.model/build.properties
===================================================================
--- trunk/bundles/org.savara.contract.model/build.properties	                        (rev 0)
+++ trunk/bundles/org.savara.contract.model/build.properties	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,4 @@
+source.. = src/main/java/
+output.. = bin/
+bin.includes = META-INF/,\
+               .

Added: trunk/bundles/org.savara.contract.model/pom.xml
===================================================================
--- trunk/bundles/org.savara.contract.model/pom.xml	                        (rev 0)
+++ trunk/bundles/org.savara.contract.model/pom.xml	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,33 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  	<modelVersion>4.0.0</modelVersion>
+	<groupId>org.savara.bundles</groupId>
+	<artifactId>org.savara.contract.model</artifactId> 
+	<version>1.2.0-SNAPSHOT</version>
+	<packaging>jar</packaging>
+	<name>Savara::Bundles::ContractModel</name>
+
+	<parent>
+		<groupId>org.savara</groupId>
+		<artifactId>bundles</artifactId>
+		<version>1.2.0-SNAPSHOT</version>
+	</parent>
+  
+	<dependencies>
+		<dependency>
+			<groupId>org.savara.bundles</groupId>
+			<artifactId>org.scribble.core</artifactId>
+			<version>1.2.0-SNAPSHOT</version>
+		</dependency>
+		<dependency>
+			<groupId>org.savara.bundles</groupId>
+			<artifactId>org.scribble.conversation.model</artifactId>
+			<version>1.2.0-SNAPSHOT</version>
+		</dependency>
+	    <dependency>
+	      <groupId>org.apache.felix</groupId>
+	      <artifactId>org.osgi.core</artifactId>
+	      <version>${osgi.version}</version>
+	    </dependency>
+   </dependencies>
+</project>

Added: trunk/bundles/org.savara.contract.model/src/main/java/org/savara/contract/model/Contract.java
===================================================================
--- trunk/bundles/org.savara.contract.model/src/main/java/org/savara/contract/model/Contract.java	                        (rev 0)
+++ trunk/bundles/org.savara.contract.model/src/main/java/org/savara/contract/model/Contract.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,118 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.contract.model;
+
+/**
+ * This class represents the contract.
+ */
+public class Contract {
+	
+	private String m_name=null;
+	private String m_namespace=null;
+	private java.util.Set<Interface> m_interfaces=
+						new java.util.HashSet<Interface>();
+	private java.util.Set<Namespace> m_namespaces=
+			new java.util.HashSet<Namespace>();
+	
+	/**
+	 * The default constructor.
+	 */
+	public Contract() {
+	}
+	
+	/**
+	 * This method returns the name associated with the
+	 * contract.
+	 * 
+	 * @return The name
+	 */
+	public String getName() {
+		return(m_name);
+	}
+	
+	/**
+	 * This method sets the name of the contract.
+	 * 
+	 * @param name The name
+	 */
+	public void setName(String name) {
+		m_name = name;
+	}
+	
+	/**
+	 * This method returns the namespace associated with the
+	 * contract.
+	 * 
+	 * @return The namespace
+	 */
+	public String getNamespace() {
+		return(m_namespace);
+	}
+	
+	/**
+	 * This method sets the namespace of the contract.
+	 * 
+	 * @param namespace The namespace
+	 */
+	public void setNamespace(String namespace) {
+		m_namespace = namespace;
+	}
+	
+	/**
+	 * This method returns the list of interfaces.
+	 * 
+	 * @return The list of interfaces
+	 */
+	public java.util.Set<Interface> getInterfaces() {
+		return(m_interfaces);
+	}
+	
+	/**
+	 * This method returns the interface associated
+	 * with the supplied name.
+	 * 
+	 * @param name The interface name
+	 * @return The interface, or null if not found.
+	 */
+	public Interface getInterface(String name) {
+		Interface ret=null;
+		
+		java.util.Iterator<Interface> iter=getInterfaces().iterator();
+		while (ret == null && iter.hasNext()) {
+			ret = iter.next();
+			
+			if (ret.getName().equals(name) == false) {
+				ret = null;
+			}
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the list of namespaces.
+	 * If a namespace is used in the contract that does
+	 * not exist in this list, then a dynamic prefix should
+	 * be created for the namespace.
+	 * 
+	 * @return The list of namespaces
+	 */
+	public java.util.Set<Namespace> getNamespaces() {
+		return(m_namespaces);
+	}
+}

Added: trunk/bundles/org.savara.contract.model/src/main/java/org/savara/contract/model/FaultDetails.java
===================================================================
--- trunk/bundles/org.savara.contract.model/src/main/java/org/savara/contract/model/FaultDetails.java	                        (rev 0)
+++ trunk/bundles/org.savara.contract.model/src/main/java/org/savara/contract/model/FaultDetails.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.contract.model;
+
+/**
+ * This class represents the fault details.
+ */
+public class FaultDetails {
+	
+	private String m_name=null;
+	private String m_namespace=null;
+	private java.util.List<Type> m_types=
+						new java.util.Vector<Type>();	
+	
+	/**
+	 * The default constructor.
+	 */
+	public FaultDetails() {
+	}
+	
+	/**
+	 * This method returns the name associated with the
+	 * fault.
+	 * 
+	 * @return The name
+	 */
+	public String getName() {
+		return(m_name);
+	}
+	
+	/**
+	 * This method sets the name of the fault.
+	 * 
+	 * @param name The name
+	 */
+	public void setName(String name) {
+		m_name = name;
+	}
+	
+	/**
+	 * This method returns the namespace associated with the
+	 * fault.
+	 * 
+	 * @return The namespace
+	 */
+	public String getNamespace() {
+		return(m_namespace);
+	}
+	
+	/**
+	 * This method sets the namespace of the fault.
+	 * 
+	 * @param namespace The namespace
+	 */
+	public void setNamespace(String namespace) {
+		m_namespace = namespace;
+	}
+	
+	/**
+	 * This method returns the list of types.
+	 * 
+	 * @return The list of types
+	 */
+	public java.util.List<Type> getTypes() {
+		return(m_types);
+	}
+}

Added: trunk/bundles/org.savara.contract.model/src/main/java/org/savara/contract/model/Interface.java
===================================================================
--- trunk/bundles/org.savara.contract.model/src/main/java/org/savara/contract/model/Interface.java	                        (rev 0)
+++ trunk/bundles/org.savara.contract.model/src/main/java/org/savara/contract/model/Interface.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,106 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.contract.model;
+
+/**
+ * This class represents an interface, as part of a contract.
+ *
+ */
+public class Interface {
+	
+	private String m_name=null;
+	private String m_namespace=null;
+	private java.util.List<MessageExchangePattern> m_messageExchangePatterns=
+			new java.util.Vector<MessageExchangePattern>();
+
+	/**
+	 * The default constructor.
+	 */
+	public Interface() {
+	}
+
+	/**
+	 * This method returns the name associated with the
+	 * interface.
+	 * 
+	 * @return The name
+	 */
+	public String getName() {
+		return(m_name);
+	}
+	
+	/**
+	 * This method sets the name of the interface.
+	 * 
+	 * @param name The name
+	 */
+	public void setName(String name) {
+		m_name = name;
+	}
+	
+	/**
+	 * This method returns the namespace associated with the
+	 * interface.
+	 * 
+	 * @return The namespace
+	 */
+	public String getNamespace() {
+		return(m_namespace);
+	}
+	
+	/**
+	 * This method sets the namespace of the interface.
+	 * 
+	 * @param namespace The namespace
+	 */
+	public void setNamespace(String namespace) {
+		m_namespace = namespace;
+	}
+	
+	/**
+	 * This method returns the list of message exchange patterns.
+	 * 
+	 * @return The list of message exchange patterns
+	 */
+	public java.util.List<MessageExchangePattern> getMessageExchangePatterns() {
+		return(m_messageExchangePatterns);
+	}
+	
+	/**
+	 * This method retrieves an existing message exchange pattern,
+	 * associated with the supplied operation name, if one exists.
+	 * 
+	 * @param op The operation
+	 * @return The message exchange pattern, or null if not found
+	 */
+	public MessageExchangePattern getMessageExchangePatternForOperation(String op) {
+		MessageExchangePattern ret=null;
+		
+		java.util.Iterator<MessageExchangePattern> iter=getMessageExchangePatterns().iterator();
+		
+		while (ret == null && iter.hasNext()) {
+			ret = iter.next();
+			
+			if (op.equals(ret.getOperation()) == false) {
+				ret = null;
+			}
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.savara.contract.model/src/main/java/org/savara/contract/model/MessageExchangePattern.java
===================================================================
--- trunk/bundles/org.savara.contract.model/src/main/java/org/savara/contract/model/MessageExchangePattern.java	                        (rev 0)
+++ trunk/bundles/org.savara.contract.model/src/main/java/org/savara/contract/model/MessageExchangePattern.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.contract.model;
+
+/**
+ * This class represents the message exchange pattern.
+ */
+public abstract class MessageExchangePattern {
+	
+	private String m_operation=null;
+	private java.util.List<Type> m_types=
+			new java.util.Vector<Type>();	
+	
+	/**
+	 * The default constructor.
+	 */
+	public MessageExchangePattern() {
+	}
+	
+	/**
+	 * This method returns the optional operation.
+	 * 
+	 * @return The optional operation
+	 */
+	public String getOperation() {
+		return(m_operation);
+	}
+	
+	/**
+	 * This method sets the operation.
+	 * 
+	 * @param operation The operation
+	 */
+	public void setOperation(String operation) {
+		m_operation = operation;
+	}
+	
+	/**
+	 * This method returns the list of types. If
+	 * no operation name is defined, then only one type
+	 * should be defined.
+	 * 
+	 * @return The list of types
+	 */
+	public java.util.List<Type> getTypes() {
+		return(m_types);
+	}
+}

Added: trunk/bundles/org.savara.contract.model/src/main/java/org/savara/contract/model/Namespace.java
===================================================================
--- trunk/bundles/org.savara.contract.model/src/main/java/org/savara/contract/model/Namespace.java	                        (rev 0)
+++ trunk/bundles/org.savara.contract.model/src/main/java/org/savara/contract/model/Namespace.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,91 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.contract.model;
+
+/**
+ * This class represents the namespace.
+ */
+public class Namespace {
+	
+	private String m_prefix=null;
+	private String m_uri=null;
+	private String m_schemaLocation=null;
+	
+	/**
+	 * The default constructor.
+	 */
+	public Namespace() {
+	}
+	
+	/**
+	 * This method returns the prefix associated with the
+	 * prefix.
+	 * 
+	 * @return The name
+	 */
+	public String getPrefix() {
+		return(m_prefix);
+	}
+	
+	/**
+	 * This method sets the prefix of the namespace.
+	 * 
+	 * @param prefix The prefix
+	 */
+	public void setPrefix(String prefix) {
+		m_prefix = prefix;
+	}
+	
+	/**
+	 * This method returns the URI associated with the
+	 * namespace.
+	 * 
+	 * @return The URI
+	 */
+	public String getURI() {
+		return(m_uri);
+	}
+	
+	/**
+	 * This method sets the URI of the namespace.
+	 * 
+	 * @param uri The URI
+	 */
+	public void setURI(String uri) {
+		m_uri = uri;
+	}
+	
+	/**
+	 * This method returns the schema location associated with the
+	 * namespace.
+	 * 
+	 * @return The URI
+	 */
+	public String getSchemaLocation() {
+		return(m_schemaLocation);
+	}
+	
+	/**
+	 * This method sets the schema location of the namespace.
+	 * 
+	 * @param schemaLocation The optional schema location
+	 */
+	public void setSchemaLocation(String schemaLocation) {
+		m_schemaLocation = schemaLocation;
+	}
+}

Added: trunk/bundles/org.savara.contract.model/src/main/java/org/savara/contract/model/OneWayRequestMEP.java
===================================================================
--- trunk/bundles/org.savara.contract.model/src/main/java/org/savara/contract/model/OneWayRequestMEP.java	                        (rev 0)
+++ trunk/bundles/org.savara.contract.model/src/main/java/org/savara/contract/model/OneWayRequestMEP.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.contract.model;
+
+/**
+ * This class represents the one-way message exchange pattern.
+ */
+public class OneWayRequestMEP extends MessageExchangePattern {
+	
+	/**
+	 * The default constructor.
+	 */
+	public OneWayRequestMEP() {
+	}
+	
+}

Added: trunk/bundles/org.savara.contract.model/src/main/java/org/savara/contract/model/RequestResponseMEP.java
===================================================================
--- trunk/bundles/org.savara.contract.model/src/main/java/org/savara/contract/model/RequestResponseMEP.java	                        (rev 0)
+++ trunk/bundles/org.savara.contract.model/src/main/java/org/savara/contract/model/RequestResponseMEP.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.contract.model;
+
+/**
+ * This class represents the request response message exchange pattern.
+ */
+public class RequestResponseMEP extends MessageExchangePattern {
+	
+	private java.util.List<Type> m_responseTypes=
+			new java.util.Vector<Type>();	
+	private java.util.List<FaultDetails> m_faultDetails=
+			new java.util.Vector<FaultDetails>();	
+	
+	/**
+	 * The default constructor.
+	 */
+	public RequestResponseMEP() {
+	}
+	
+	/**
+	 * This method returns the list of response types.
+	 * 
+	 * @return The list of response types
+	 */
+	public java.util.List<Type> getResponseTypes() {
+		return(m_responseTypes);
+	}
+	
+	/**
+	 * This method returns the list of fault details.
+	 * 
+	 * @return The list of fault details
+	 */
+	public java.util.List<FaultDetails> getFaultDetails() {
+		return(m_faultDetails);
+	}
+}

Added: trunk/bundles/org.savara.contract.model/src/main/java/org/savara/contract/model/Type.java
===================================================================
--- trunk/bundles/org.savara.contract.model/src/main/java/org/savara/contract/model/Type.java	                        (rev 0)
+++ trunk/bundles/org.savara.contract.model/src/main/java/org/savara/contract/model/Type.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.contract.model;
+
+/**
+ * This class represents a type associated with information passed by the contract.
+ */
+public class Type {
+	
+	private String m_name=null;
+	private java.util.Set<TypeDefinition> m_typeDefinitions=
+		new java.util.HashSet<TypeDefinition>();
+	
+	/**
+	 * The default constructor.
+	 */
+	public Type() {
+	}
+	
+	/**
+	 * This method returns the name associated with the
+	 * type.
+	 * 
+	 * @return The name
+	 */
+	public String getName() {
+		return(m_name);
+	}
+	
+	/**
+	 * This method sets the name of the type.
+	 * 
+	 * @param name The name
+	 */
+	public void setName(String name) {
+		m_name = name;
+	}
+	
+	/**
+	 * This method returns the list of type definitions.
+	 * 
+	 * @return The list of type definitions
+	 */
+	public java.util.Set<TypeDefinition> getTypeDefinitions() {
+		return(m_typeDefinitions);
+	}
+}

Added: trunk/bundles/org.savara.contract.model/src/main/java/org/savara/contract/model/TypeDefinition.java
===================================================================
--- trunk/bundles/org.savara.contract.model/src/main/java/org/savara/contract/model/TypeDefinition.java	                        (rev 0)
+++ trunk/bundles/org.savara.contract.model/src/main/java/org/savara/contract/model/TypeDefinition.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,95 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.contract.model;
+
+/**
+ * This class represents a type definition within
+ */
+public class TypeDefinition {
+	
+	public static final String XSD_ELEMENT="##XSDElement";
+	public static final String XSD_TYPE="##XSDType";
+	
+	private String m_name=null;	
+	private String m_namespace=null;
+	private String m_typeSystem=null;
+	
+	/**
+	 * The default constructor.
+	 */
+	public TypeDefinition() {
+	}
+	
+	/**
+	 * This method returns the name associated with the
+	 * type.
+	 * 
+	 * @return The name
+	 */
+	public String getName() {
+		return(m_name);
+	}
+	
+	/**
+	 * This method returns the namespace associated with the
+	 * type definition.
+	 * 
+	 * @return The namespace
+	 */
+	public String getNamespace() {
+		return(m_namespace);
+	}
+	
+	/**
+	 * This method sets the namespace of the type definition.
+	 * 
+	 * @param namespace The namespace
+	 */
+	public void setNamespace(String namespace) {
+		m_namespace = namespace;
+	}
+	
+	/**
+	 * This method sets the name of the type.
+	 * 
+	 * @param name The name
+	 */
+	public void setName(String name) {
+		m_name = name;
+	}
+	
+	/**
+	 * This method returns the type system associated with the
+	 * type definition.
+	 * 
+	 * @return The type system
+	 */
+	public String getTypeSystem() {
+		return(m_typeSystem);
+	}
+	
+	/**
+	 * This method sets the type system associated with the
+	 * type definition.
+	 * 
+	 * @param typeSystem The type system
+	 */
+	public void setTypeSystem(String typeSystem) {
+		m_typeSystem = typeSystem;
+	}
+}

Added: trunk/bundles/org.savara.contract.model/src/main/java/org/savara/contract/model/osgi/Activator.java
===================================================================
--- trunk/bundles/org.savara.contract.model/src/main/java/org/savara/contract/model/osgi/Activator.java	                        (rev 0)
+++ trunk/bundles/org.savara.contract.model/src/main/java/org/savara/contract/model/osgi/Activator.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.contract.model.osgi;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator {
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+	 */
+	public void start(BundleContext context) throws Exception {
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+	 */
+	public void stop(BundleContext context) throws Exception {
+	}
+
+}

Added: trunk/bundles/org.savara.core/.classpath
===================================================================
--- trunk/bundles/org.savara.core/.classpath	                        (rev 0)
+++ trunk/bundles/org.savara.core/.classpath	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src/main/java"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

Added: trunk/bundles/org.savara.core/.project
===================================================================
--- trunk/bundles/org.savara.core/.project	                        (rev 0)
+++ trunk/bundles/org.savara.core/.project	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.savara.core</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.ManifestBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.SchemaBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.pde.PluginNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

Added: trunk/bundles/org.savara.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/bundles/org.savara.core/META-INF/MANIFEST.MF	                        (rev 0)
+++ trunk/bundles/org.savara.core/META-INF/MANIFEST.MF	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,11 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: SAVARA Core
+Bundle-SymbolicName: org.savara.core
+Bundle-Version: 1.2.0.qualifier
+Bundle-Activator: org.savara.core.osgi.Activator
+Bundle-Vendor: www.savara.org
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Import-Package: org.osgi.framework;version="1.3.0"
+Require-Bundle: org.scribble.core;bundle-version="[1.0.0,2.0.0)"
+Export-Package: org.savara.util

Added: trunk/bundles/org.savara.core/build.properties
===================================================================
--- trunk/bundles/org.savara.core/build.properties	                        (rev 0)
+++ trunk/bundles/org.savara.core/build.properties	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,4 @@
+source.. = src/java/
+output.. = bin/
+bin.includes = META-INF/,\
+               .

Added: trunk/bundles/org.savara.core/pom.xml
===================================================================
--- trunk/bundles/org.savara.core/pom.xml	                        (rev 0)
+++ trunk/bundles/org.savara.core/pom.xml	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,28 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  	<modelVersion>4.0.0</modelVersion>
+	<groupId>org.savara.bundles</groupId>
+	<artifactId>org.savara.core</artifactId> 
+	<version>1.2.0-SNAPSHOT</version>
+	<packaging>jar</packaging>
+	<name>Savara::Bundles::Core</name>
+
+	<parent>
+		<groupId>org.savara</groupId>
+		<artifactId>bundles</artifactId>
+		<version>1.2.0-SNAPSHOT</version>
+	</parent>
+   
+	<dependencies>
+		<dependency>
+			<groupId>org.savara.bundles</groupId>
+			<artifactId>org.scribble.core</artifactId>
+			<version>1.2.0-SNAPSHOT</version>
+		</dependency>
+	    <dependency>
+	      <groupId>org.apache.felix</groupId>
+	      <artifactId>org.osgi.core</artifactId>
+	      <version>${osgi.version}</version>
+	    </dependency>
+   </dependencies>
+</project>

Added: trunk/bundles/org.savara.core/src/main/java/org/savara/core/osgi/Activator.java
===================================================================
--- trunk/bundles/org.savara.core/src/main/java/org/savara/core/osgi/Activator.java	                        (rev 0)
+++ trunk/bundles/org.savara.core/src/main/java/org/savara/core/osgi/Activator.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,30 @@
+package org.savara.core.osgi;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator {
+
+	private static BundleContext context;
+
+	static BundleContext getContext() {
+		return context;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+	 */
+	public void start(BundleContext bundleContext) throws Exception {
+		Activator.context = bundleContext;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+	 */
+	public void stop(BundleContext bundleContext) throws Exception {
+		Activator.context = null;
+	}
+
+}

Added: trunk/bundles/org.savara.core/src/main/java/org/savara/util/XMLUtils.java
===================================================================
--- trunk/bundles/org.savara.core/src/main/java/org/savara/util/XMLUtils.java	                        (rev 0)
+++ trunk/bundles/org.savara.core/src/main/java/org/savara/util/XMLUtils.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,300 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.util;
+
+import java.io.ByteArrayOutputStream;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.scribble.model.ModelObject;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+/**
+ * This class defines a set of XML related utility functions.
+ */
+public final class XMLUtils {
+	
+	private static final String NS_LABEL = "ns";
+
+	/**
+	 * This class converts a DOM representation node to text.
+	 * @param node
+	 * @return
+	 * @throws Exception
+	 */
+	public static final String toText(Node node) throws Exception {
+		String ret = null;
+		try {
+			// Transform the DOM represent to text
+			ByteArrayOutputStream xmlstr= new ByteArrayOutputStream();
+			DOMSource source=new DOMSource(node);
+			//source.setNode(node);
+			
+			StreamResult result=new StreamResult(xmlstr);			
+			Transformer trans= TransformerFactory.newInstance().newTransformer();
+			trans.transform(source, result);
+			
+			xmlstr.close();
+			
+			ret = new String(xmlstr.toByteArray());
+			
+			if ((node instanceof Document) == false) {				
+				// Strip off any <?xml> header
+				int index=ret.indexOf("<?xml");
+				if (index != -1) {
+					index = ret.indexOf("<", 1);
+					if (index != -1) {
+						ret = ret.substring(index);
+					} else {
+						index = ret.indexOf("?>");
+						if (index != -1) {
+							index += 2;
+							
+							// Remove any trailing whitespaces after XML header
+							while (index < ret.length() &&
+									Character.isWhitespace(ret.charAt(index))) {
+								index++;
+							}
+							
+							ret = ret.substring(index);
+						}
+					}
+				}
+			}
+
+		} catch(Exception e) {
+			throw new Exception("Failed to transform DOM representation into text", e);
+		}
+		if (ret != null) {
+			 return format(ret);
+		}
+		return ret;
+	}
+	
+	
+	/**
+	 * Format the xml to well print.
+	 * 
+	 * @param xmltext
+	 * @return
+	 */
+	public static final String format(String xmltext) {
+		String ret=xmltext;
+		int pos=0;
+		int prevpos=0;
+		StringBuffer buf=new StringBuffer();
+		int level=0;
+		
+		while ((pos=ret.indexOf('<', prevpos)) != -1) {
+			
+			if (prevpos < pos &&
+					ret.substring(prevpos, pos).trim().length() > 0 &&
+					ret.charAt(prevpos-1) != '?') {
+				
+				if (ret.charAt(prevpos) == '\r' &&
+						ret.charAt(prevpos+1) == '\n') {
+					prevpos += 2;
+				}
+				for (int i=0; i < level; i++) {
+					buf.append("    ");
+				}
+				
+				buf.append(ret.substring(prevpos, pos).trim());
+				buf.append("\r\n");
+			}
+			
+			int endpos=ret.indexOf('>', pos);
+		
+			if (endpos > 0) {
+				boolean noreturn=false;
+				
+				if (pos > 0 && ret.charAt(pos+1) == '/') {
+					level--;
+				}
+				
+				for (int i=0; i < level; i++) {
+					buf.append("    ");
+				}
+				buf.append(ret.substring(pos, endpos+1));
+				
+				if (ret.charAt(endpos-1)== '?') {
+					//noreturn = true;
+					
+				} else if (ret.charAt(endpos-1) == '/') {
+					// Ignore
+				} else if (pos > 0 && ret.charAt(pos+1) == '/') {
+					// Ignore
+					
+				} else if (pos > 0 && ret.charAt(pos+1) == '!') {
+					// Ignore
+					
+				} else {
+					level++;
+				}
+							
+				if (noreturn == false) {
+					buf.append("\r\n");
+				}
+				
+				pos = endpos+1;
+			}
+			
+			prevpos = pos;
+		}
+		
+		if (prevpos != -1 &&
+				ret.substring(prevpos).trim().length() > 0) {
+			buf.append(ret.substring(prevpos));
+		}
+		
+		ret = buf.toString();
+		
+		return(ret);
+	}
+	
+	public static Node getNode(String text) throws Exception {
+		Node ret=null;
+		
+		// Transform the text representation to DOM
+		DocumentBuilderFactory fact=DocumentBuilderFactory.newInstance();
+		fact.setNamespaceAware(true);
+		
+		java.io.InputStream xmlstr=
+			new java.io.ByteArrayInputStream(text.getBytes());
+
+		DocumentBuilder builder=fact.newDocumentBuilder();
+		org.w3c.dom.Document doc=builder.parse(xmlstr);
+		
+		ret = doc.getDocumentElement();
+
+		return(ret);
+	}
+
+	/**
+	 * This method returns the localname part of the supplied
+	 * qualified name.
+	 * 
+	 * @param qname The qualified name
+	 * @return The localname part
+	 */
+	public static String getLocalname(String qname) {
+		String ret=qname;
+		int pos=0;
+		
+		if (qname != null && ((pos=qname.indexOf(':')) != -1)) {
+			ret = qname.substring(pos+1);
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the prefix associated with the supplied namespace.
+	 * 
+	 * @param namespace The namespace
+	 * @param nsMap The existing namespace prefix mappings
+	 * @return The prefix
+	 */
+	public static String getPrefix(String namespace, java.util.Map<String,String> nsMap) {
+		String prefix=null;
+		
+		prefix = nsMap.get(namespace);
+		
+		if (prefix == null) {
+			prefix = NS_LABEL+(nsMap.size()+1);
+			nsMap.put(namespace, prefix);
+		}
+
+		return(prefix);
+	}
+	
+	/**
+	 * This method calculates the start and end position of a supplied DOM element, within
+	 * the supplied text contents, and sets the values on the supplied ModelObject.
+	 * 
+	 * @param obj The ModelObject to be initialized
+	 * @param contents The text contents
+	 * @param elem The DOM element to be located in the text
+	 */
+	public static void setStartAndEndPosition(ModelObject obj, String contents, org.w3c.dom.Element elem) {
+
+		if (contents != null) {
+			org.w3c.dom.NodeList nl=elem.getOwnerDocument().getElementsByTagName(elem.getNodeName());
+			int elempos=-1;
+			
+			for (int i=0; elempos == -1 && i < nl.getLength(); i++) {
+				if (nl.item(i) == elem) {
+					elempos = i;
+				}
+			}
+			
+			if (elempos != -1) {
+				int startpos=-1;
+					
+				for (int i=0; i <= elempos; i++) {
+					int val1=contents.indexOf("<"+elem.getNodeName()+">", startpos+1);
+					int val2=contents.indexOf("<"+elem.getNodeName()+" ", startpos+1);
+					
+					if (val1 == -1 && val2 != -1) {
+						startpos = val2;
+					} else if (val1 != -1 && val2 == -1) {
+						startpos = val1;
+					} else if (val1 == -1 && val2 == -1) {
+						// TODO: Error condition
+						break;
+					} else if (val1 > val2) {
+						startpos = val2;
+					} else {
+						startpos = val1;
+					}
+				}
+				
+				if (startpos != -1) {
+					obj.getSource().setStartPosition(startpos);
+					
+					// Check if single node
+					int p1=contents.indexOf('>', startpos);
+					
+					if (p1 != -1 && contents.charAt(p1-1) == '/') {
+						obj.getSource().setEndPosition(p1);
+					} else {
+					
+						org.w3c.dom.NodeList enl=elem.getElementsByTagName(elem.getNodeName());
+						
+						int endpos=startpos;
+						String nodetxt="</"+elem.getNodeName()+">";
+						
+						for (int i=0; endpos != -1 && i <= enl.getLength(); i++) {
+							endpos = contents.indexOf(nodetxt, endpos+1);
+						}
+						
+						if (endpos != -1) {
+							obj.getSource().setEndPosition(endpos+nodetxt.length()-1);
+						}
+					}
+				}
+			}
+		}
+	}
+}

Added: trunk/bundles/org.savara.wsdl/.classpath
===================================================================
--- trunk/bundles/org.savara.wsdl/.classpath	                        (rev 0)
+++ trunk/bundles/org.savara.wsdl/.classpath	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src/main/java"/>
+	<classpathentry kind="src" path="src/test/java"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

Added: trunk/bundles/org.savara.wsdl/.project
===================================================================
--- trunk/bundles/org.savara.wsdl/.project	                        (rev 0)
+++ trunk/bundles/org.savara.wsdl/.project	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.savara.wsdl</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.ManifestBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.SchemaBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.pde.PluginNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

Added: trunk/bundles/org.savara.wsdl/Copyright.txt
===================================================================
--- trunk/bundles/org.savara.wsdl/Copyright.txt	                        (rev 0)
+++ trunk/bundles/org.savara.wsdl/Copyright.txt	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,17 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */

Added: trunk/bundles/org.savara.wsdl/META-INF/MANIFEST.MF
===================================================================
--- trunk/bundles/org.savara.wsdl/META-INF/MANIFEST.MF	                        (rev 0)
+++ trunk/bundles/org.savara.wsdl/META-INF/MANIFEST.MF	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,19 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: SAVARA WSDL
+Bundle-SymbolicName: org.savara.wsdl
+Bundle-Version: 1.2.0.qualifier
+Bundle-Activator: org.savara.wsdl.osgi.Activator
+Bundle-Vendor: www.savara.org
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Import-Package: org.osgi.framework;version="1.3.0"
+Require-Bundle: javax.wsdl;visibility:=reexport,
+ org.savara.contract.model,
+ org.apache.commons.logging,
+ org.scribble.core;bundle-version="[1.0.0,2.0.0)",
+ org.scribble.conversation.model;bundle-version="[1.0.0,2.0.0)",
+ org.junit
+Export-Package: org.savara.wsdl.generator,
+ org.savara.wsdl.generator.impl,
+ org.savara.wsdl.generator.soap,
+ org.savara.wsdl.util

Added: trunk/bundles/org.savara.wsdl/build.properties
===================================================================
--- trunk/bundles/org.savara.wsdl/build.properties	                        (rev 0)
+++ trunk/bundles/org.savara.wsdl/build.properties	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,4 @@
+source.. = src/main/java/
+output.. = bin/
+bin.includes = META-INF/,\
+               .

Added: trunk/bundles/org.savara.wsdl/pom.xml
===================================================================
--- trunk/bundles/org.savara.wsdl/pom.xml	                        (rev 0)
+++ trunk/bundles/org.savara.wsdl/pom.xml	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,54 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  	<modelVersion>4.0.0</modelVersion>
+	<groupId>org.savara.bundles</groupId>
+	<artifactId>org.savara.wsdl</artifactId> 
+	<version>1.2.0-SNAPSHOT</version>
+	<packaging>jar</packaging>
+	<name>Savara::Bundles::WSDL</name>
+
+	<parent>
+		<groupId>org.savara</groupId>
+		<artifactId>bundles</artifactId>
+		<version>1.2.0-SNAPSHOT</version>
+	</parent>
+  
+	<dependencies>
+		<dependency>
+			<groupId>org.savara.bundles</groupId>
+			<artifactId>org.scribble.core</artifactId>
+			<version>1.2.0-SNAPSHOT</version>
+		</dependency>
+		<dependency>
+			<groupId>org.savara.bundles</groupId>
+			<artifactId>org.scribble.conversation.model</artifactId>
+			<version>1.2.0-SNAPSHOT</version>
+		</dependency>
+		<dependency>
+			<groupId>org.savara.bundles</groupId>
+			<artifactId>org.savara.contract.model</artifactId>
+			<version>1.2.0-SNAPSHOT</version>
+		</dependency>
+		<dependency>
+		    <groupId>commons-logging</groupId>
+		    <artifactId>commons-logging</artifactId>
+		    <version>1.1.1</version>
+		</dependency>
+		<dependency>
+		    <groupId>wsdl4j</groupId>
+		    <artifactId>wsdl4j</artifactId>
+		    <version>1.6.2</version>
+		</dependency>
+		<dependency>
+	      <groupId>org.apache.felix</groupId>
+	      <artifactId>org.osgi.core</artifactId>
+	      <version>${osgi.version}</version>
+	    </dependency>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+           	<version>${junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+   </dependencies>
+</project>

Added: trunk/bundles/org.savara.wsdl/src/main/java/org/savara/wsdl/generator/WSDLBinding.java
===================================================================
--- trunk/bundles/org.savara.wsdl/src/main/java/org/savara/wsdl/generator/WSDLBinding.java	                        (rev 0)
+++ trunk/bundles/org.savara.wsdl/src/main/java/org/savara/wsdl/generator/WSDLBinding.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,92 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.wsdl.generator;
+
+/**
+ * This interface is used to establish binding information on a
+ * WSDL definition.
+ *
+ */
+public interface WSDLBinding {
+
+	/**
+	 * This method returns the name of the WSDL binding implementation.
+	 * 
+	 * @return The WSDL binding
+	 */
+	public String getName();
+	
+	/**
+	 * This method initializes the WSDL definition for the binding.
+	 * 
+	 * @param defn The definition
+	 */
+	public void initDefinition(javax.wsdl.Definition defn);
+	
+	/**
+	 * This method adds WSDL binding information to the port binding.
+	 * 
+	 * @param defn The definition
+	 * @param binding The port type
+	 */
+	public void updateBinding(javax.wsdl.Definition defn, javax.wsdl.Binding binding);
+	
+	/**
+	 * This method adds WSDL binding information to the operation.
+	 * 
+	 * @param defn The definition
+	 * @param mep The message exchange pattern
+	 * @param operation The operation
+	 */
+	public void updateOperation(javax.wsdl.Definition defn,
+			org.savara.contract.model.MessageExchangePattern mep,
+			javax.wsdl.BindingOperation operation);
+	
+	/**
+	 * This method adds WSDL binding information to the input.
+	 * 
+	 * @param defn The definition
+	 * @param input The input
+	 */
+	public void updateInput(javax.wsdl.Definition defn, javax.wsdl.BindingInput input);
+	
+	/**
+	 * This method adds WSDL binding information to the output.
+	 * 
+	 * @param defn The definition
+	 * @param output The output
+	 */
+	public void updateOutput(javax.wsdl.Definition defn, javax.wsdl.BindingOutput output);
+	
+	/**
+	 * This method adds WSDL binding information to the fault.
+	 * 
+	 * @param defn The definition
+	 * @param fault The fault
+	 */
+	public void updateFault(javax.wsdl.Definition defn, javax.wsdl.BindingFault fault);
+	
+	/**
+	 * This method adds WSDL binding information to the fault.
+	 * 
+	 * @param defn The definition
+	 * @param port The port
+	 */
+	public void updatePort(javax.wsdl.Definition defn, javax.wsdl.Port port);
+	
+}

Added: trunk/bundles/org.savara.wsdl/src/main/java/org/savara/wsdl/generator/WSDLGenerator.java
===================================================================
--- trunk/bundles/org.savara.wsdl/src/main/java/org/savara/wsdl/generator/WSDLGenerator.java	                        (rev 0)
+++ trunk/bundles/org.savara.wsdl/src/main/java/org/savara/wsdl/generator/WSDLGenerator.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.wsdl.generator;
+
+/**
+ * This interface generates a WSDL definition from a Contract model.
+ *
+ */
+public interface WSDLGenerator {
+
+	/**
+	 * This method generates a WSDL definition from a Scribble contract model.
+	 * 
+	 * @param contract The contract model
+	 * @param wsdlBinding The WSDL binding to use, or null if no binding
+	 * @return The WSDL definition
+	 */
+	public java.util.List<javax.wsdl.Definition> generate(org.savara.contract.model.Contract contract,
+								WSDLBinding wsdlBinding);
+
+}

Added: trunk/bundles/org.savara.wsdl/src/main/java/org/savara/wsdl/generator/WSDLGeneratorFactory.java
===================================================================
--- trunk/bundles/org.savara.wsdl/src/main/java/org/savara/wsdl/generator/WSDLGeneratorFactory.java	                        (rev 0)
+++ trunk/bundles/org.savara.wsdl/src/main/java/org/savara/wsdl/generator/WSDLGeneratorFactory.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.wsdl.generator;
+
+import org.savara.wsdl.generator.impl.WSDLGeneratorImpl;
+
+/**
+ * This class provides a factory for WSDL Generators.
+ *
+ */
+public class WSDLGeneratorFactory {
+
+	/**
+	 * This method returns a WSDL generator.
+	 * 
+	 * @return The WSDL generator
+	 */
+	public static WSDLGenerator getWSDLGenerator() {
+		return(new WSDLGeneratorImpl());
+	}
+
+}

Added: trunk/bundles/org.savara.wsdl/src/main/java/org/savara/wsdl/generator/impl/WSDLGeneratorImpl.java
===================================================================
--- trunk/bundles/org.savara.wsdl/src/main/java/org/savara/wsdl/generator/impl/WSDLGeneratorImpl.java	                        (rev 0)
+++ trunk/bundles/org.savara.wsdl/src/main/java/org/savara/wsdl/generator/impl/WSDLGeneratorImpl.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,537 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.wsdl.generator.impl;
+
+import javax.wsdl.Part;
+import javax.xml.namespace.QName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.savara.contract.model.FaultDetails;
+import org.savara.contract.model.Interface;
+import org.savara.contract.model.Namespace;
+import org.savara.contract.model.RequestResponseMEP;
+import org.savara.contract.model.Type;
+import org.savara.contract.model.TypeDefinition;
+import org.savara.wsdl.generator.WSDLBinding;
+import org.savara.wsdl.generator.WSDLGenerator;
+import org.savara.wsdl.util.WSDLGeneratorUtil;
+
+/**
+ * This class generates a WSDL definition from a Contract model.
+ *
+ */
+public class WSDLGeneratorImpl implements WSDLGenerator {
+
+	public static final String BINDING_SUFFIX = "Binding";
+	
+	private static Log logger = LogFactory.getLog(WSDLGeneratorImpl.class);
+	
+	public WSDLGeneratorImpl() {
+	}
+	
+	/**
+	 * This method generates a WSDL definition from a Scribble contract model.
+	 * 
+	 * @param contract The contract model
+	 * @param wsdlBinding The WSDL binding to use, or null if no binding
+	 * @return The WSDL definition
+	 */
+	public java.util.List<javax.wsdl.Definition> generate(org.savara.contract.model.Contract contract,
+								WSDLBinding wsdlBinding) {
+		java.util.List<javax.wsdl.Definition> ret=new java.util.Vector<javax.wsdl.Definition>();
+		
+		try {
+			// Create definition for contract's target namespace
+			javax.wsdl.Definition main=getDefinition(ret, contract, contract.getNamespace(), wsdlBinding);
+			
+			// If no definition, then return
+			if (main == null) {
+				return(ret);
+			}
+			
+			// Create service
+			javax.wsdl.Service service=main.createService();
+			service.setQName(new javax.xml.namespace.QName(contract.getNamespace(),
+								contract.getName()+"Service"));
+
+			main.addService(service);
+			
+			// Define a port type per interface
+			java.util.Iterator<Interface> iter=contract.getInterfaces().iterator();
+			
+			while (iter.hasNext()) {
+				Interface intf=iter.next();
+				
+				javax.wsdl.PortType portType=
+							createPortType(ret, contract, intf, wsdlBinding);
+				
+				javax.wsdl.Binding binding=
+							createBinding(ret, contract, intf, portType, wsdlBinding);
+				
+				// Create service port for interface
+				javax.wsdl.Port port=main.createPort();
+				
+				port.setName(intf.getName()+"Port");
+				port.setBinding(binding);
+				
+				service.addPort(port);
+				
+				if (wsdlBinding != null) {
+					wsdlBinding.updatePort(main, port);
+				}
+			}
+			
+		} catch(Exception e) {
+			logger.error("Failed to generate WSDL", e);
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the definition associated with the supplied target namespace.
+	 * 
+	 * @param wsdls The list of current WSDL definitions
+	 * @param contract The contract
+	 * @param targetNamespace The target namespace
+	 * @param wsdlBinding The WSDL binding to use, or null if no binding
+	 * @return The WSDL definition for the target namespace, or null if unable to find or create
+	 */
+	protected javax.wsdl.Definition getDefinition(java.util.List<javax.wsdl.Definition> wsdls,
+				org.savara.contract.model.Contract contract, String targetNamespace,
+				WSDLBinding wsdlBinding) {
+		javax.wsdl.Definition ret=null;
+		
+		if (targetNamespace != null) {
+			for (int i=0; ret == null && i < wsdls.size(); i++) {
+				ret = wsdls.get(i);
+				
+				if (ret.getTargetNamespace() == null || 
+						ret.getTargetNamespace().equals(targetNamespace) == false) {
+					ret = null;
+				}
+			}
+			
+			if (ret == null) {
+				ret = createDefinition(contract, targetNamespace);
+				
+				if (ret != null) {
+					
+					// Initialize definition using the WSDL binding
+					if (wsdlBinding != null) {
+						wsdlBinding.initDefinition(ret);
+					}
+					
+					wsdls.add(ret);
+				}
+			}
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method creates a new WSDL definition associated with the supplied
+	 * target namespace.
+	 * 
+	 * @param contract The contract
+	 * @param targetNamespace The target namespace
+	 * @return The WSDL definition
+	 */
+	protected javax.wsdl.Definition createDefinition(org.savara.contract.model.Contract contract,
+									String targetNamespace) {
+		javax.wsdl.Definition ret=null;
+		
+		try {
+			javax.wsdl.factory.WSDLFactory fact=
+				javax.wsdl.factory.WSDLFactory.newInstance();
+	
+			ret = fact.newDefinition();
+			
+			// Set details on the definition
+			if (contract.getName() != null) {
+				ret.setQName(new javax.xml.namespace.QName(contract.getName()));
+			}
+			ret.setTargetNamespace(targetNamespace);
+			
+			// Set up namespace mappings
+			java.util.Iterator<Namespace> iter=contract.getNamespaces().iterator();
+			
+			while (iter.hasNext()) {
+				Namespace ns=iter.next();
+				
+				ret.addNamespace(ns.getPrefix(), ns.getURI());
+			}
+
+		} catch(Exception e) {
+			logger.error("Failed to create WSDL definition for target namespace '"+targetNamespace+"'", e);
+		}
+
+		return(ret);
+	}
+
+	/**
+	 * This method generates a port type, using the supplied WSDL definition,
+	 * based on the information in the supplied interface definition.
+	 * 
+	 * @param wsdls The list of current WSDL definitions
+	 * @param contract The contract
+	 * @param intf The interface model
+	 * @return The WSDL port type
+	 */
+	public javax.wsdl.PortType createPortType(java.util.List<javax.wsdl.Definition> wsdls,
+						org.savara.contract.model.Contract contract,
+								org.savara.contract.model.Interface intf,
+								WSDLBinding wsdlBinding) {
+		javax.wsdl.PortType ret=null;
+		
+		if (intf != null) {
+			javax.wsdl.Definition defn=getDefinition(wsdls, contract, intf.getNamespace(), wsdlBinding);
+
+			if (defn != null) {
+				ret = defn.createPortType();
+				ret.setUndefined(false);
+				
+				if (intf.getName() != null) {
+					ret.setQName(new javax.xml.namespace.QName(intf.getNamespace(), intf.getName()));
+				}
+				
+				for (int i=0; i < intf.getMessageExchangePatterns().size(); i++) {
+					createOperation(wsdls, contract, ret,
+								intf.getMessageExchangePatterns().get(i), wsdlBinding);
+				}
+
+				// Only add portType to definition if they have atleast one operation
+				if (ret != null && ret.getOperations().size() > 0) {
+					defn.addPortType(ret);
+				}
+			}
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method generates a port type binding, using the supplied WSDL definition,
+	 * based on the information in the supplied interface definition.
+	 * 
+	 * @param wsdls The list of current WSDL definitions
+	 * @param contract The contract
+	 * @param intf The interface model
+	 * @param portType The port type
+	 * @return The WSDL port type binding
+	 */
+	public javax.wsdl.Binding createBinding(java.util.List<javax.wsdl.Definition> wsdls,
+						org.savara.contract.model.Contract contract,
+								org.savara.contract.model.Interface intf,
+								javax.wsdl.PortType portType,
+								WSDLBinding wsdlBinding) {
+		javax.wsdl.Binding ret=null;
+		
+		if (intf != null) {
+			javax.wsdl.Definition defn=getDefinition(wsdls, contract, intf.getNamespace(), wsdlBinding);
+
+			if (defn != null) {
+				ret = defn.createBinding();
+				ret.setUndefined(false);
+				
+				// Check if WSDL binding details
+				if (wsdlBinding != null) {
+					wsdlBinding.updateBinding(defn, ret);
+				}
+				
+				if (intf.getName() != null) {
+					ret.setQName(new javax.xml.namespace.QName(intf.getNamespace(), 
+							intf.getName()+BINDING_SUFFIX));
+				}
+				
+				ret.setPortType(portType);
+				
+				for (int i=0; i < intf.getMessageExchangePatterns().size(); i++) {
+					createBindingOperation(wsdls, contract, ret,
+								intf.getMessageExchangePatterns().get(i), wsdlBinding);
+				}
+
+				// Only add portType to definition if they have atleast one operation
+				if (ret != null && ret.getBindingOperations().size() > 0) {
+					defn.addBinding(ret);
+				}
+			}
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method generates an operation, using the supplied WSDL definition,
+	 * based on the information in the supplied message exchange pattern.
+	 * 
+	 * @param wsdls The list of current WSDL definitions
+	 * @param contract The contract
+	 * @param portType The port type
+	 * @param mep The message exchange pattern
+	 * @return The WSDL operation
+	 */
+	public javax.wsdl.Operation createOperation(java.util.List<javax.wsdl.Definition> wsdls,
+			org.savara.contract.model.Contract contract, javax.wsdl.PortType portType,
+								org.savara.contract.model.MessageExchangePattern mep,
+								WSDLBinding wsdlBinding) {
+		javax.wsdl.Operation ret=null;
+		
+		javax.wsdl.Definition defn=null;
+		
+		if (portType != null) {
+			defn = getDefinition(wsdls, contract, portType.getQName().getNamespaceURI(), wsdlBinding);
+		}
+
+		if (defn != null && mep != null) {
+			ret = defn.createOperation();
+			ret.setUndefined(false);
+			
+			ret.setName(mep.getOperation());
+			
+			QName msgname=WSDLGeneratorUtil.getRequestMessageType(portType.getQName().getNamespaceURI(),
+								mep.getOperation());
+			
+			javax.wsdl.Message mesg=getMessage(wsdls, contract, msgname,
+								mep.getTypes(), wsdlBinding);
+			
+			if (mesg != null) {
+				javax.wsdl.Input input=defn.createInput();
+				input.setMessage(mesg);
+				ret.setInput(input);
+			}
+			
+			// Check if a request/response MEP
+			if (mep instanceof RequestResponseMEP) {
+				RequestResponseMEP rr=(RequestResponseMEP)mep;
+				
+				msgname=WSDLGeneratorUtil.getResponseMessageType(portType.getQName().getNamespaceURI(),
+								mep.getOperation());
+			
+				javax.wsdl.Message om=getMessage(wsdls, contract, msgname,
+									rr.getResponseTypes(), wsdlBinding);
+				if (om != null) {
+					javax.wsdl.Output output=defn.createOutput();
+					output.setMessage(om);
+					ret.setOutput(output);
+				}
+				
+				// Generate fault details
+				if (rr.getFaultDetails() != null) {
+					for (int i=0; i < rr.getFaultDetails().size(); i++) {
+						FaultDetails fd=rr.getFaultDetails().get(i);
+						
+						msgname = WSDLGeneratorUtil.getFaultMessageType(portType.getQName().getNamespaceURI(),
+												fd.getName());
+					
+						javax.wsdl.Message fm=getMessage(wsdls, contract, msgname,
+											fd.getTypes(), wsdlBinding);
+						if (fm != null) {
+							javax.wsdl.Fault fault=defn.createFault();
+							fault.setName(fd.getName());
+							fault.setMessage(fm);
+							
+							ret.addFault(fault);
+						}
+					}
+				}
+			}
+			
+			portType.addOperation(ret);
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method generates a binding operation, using the supplied WSDL definition,
+	 * based on the information in the supplied message exchange pattern.
+	 * 
+	 * @param wsdls The list of current WSDL definitions
+	 * @param contract The contract
+	 * @param binding The port type binding
+	 * @param mep The message exchange pattern
+	 * @return The WSDL binding operation
+	 */
+	public javax.wsdl.BindingOperation createBindingOperation(java.util.List<javax.wsdl.Definition> wsdls,
+			org.savara.contract.model.Contract contract, javax.wsdl.Binding binding,
+								org.savara.contract.model.MessageExchangePattern mep,
+								WSDLBinding wsdlBinding) {
+		javax.wsdl.BindingOperation ret=null;
+		
+		javax.wsdl.Definition defn=null;
+		
+		if (binding != null) {
+			defn = getDefinition(wsdls, contract, binding.getQName().getNamespaceURI(), wsdlBinding);
+		}
+
+		if (defn != null && mep != null) {
+			ret = defn.createBindingOperation();
+			//ret.setUndefined(false);
+			
+			// Check if WSDL operation details
+			if (wsdlBinding != null) {
+				wsdlBinding.updateOperation(defn, mep, ret);
+			}
+			
+			ret.setName(mep.getOperation());
+			
+			QName msgname=WSDLGeneratorUtil.getRequestMessageType(binding.getQName().getNamespaceURI(),
+											mep.getOperation());
+		
+			javax.wsdl.Message mesg=getMessage(wsdls, contract,msgname,
+								mep.getTypes(), wsdlBinding);
+			
+			if (mesg != null) {
+				javax.wsdl.BindingInput input=defn.createBindingInput();
+				
+				// Check if WSDL operation details
+				if (wsdlBinding != null) {
+					wsdlBinding.updateInput(defn, input);
+				}
+
+				ret.setBindingInput(input);
+			}
+			
+			// Check if a request/response MEP
+			if (mep instanceof RequestResponseMEP) {
+				RequestResponseMEP rr=(RequestResponseMEP)mep;
+				
+				msgname=WSDLGeneratorUtil.getResponseMessageType(binding.getQName().getNamespaceURI(),
+										mep.getOperation());
+	
+				javax.wsdl.Message om=getMessage(wsdls, contract, msgname,
+									rr.getResponseTypes(), wsdlBinding);
+				if (om != null) {
+					javax.wsdl.BindingOutput output=defn.createBindingOutput();
+					
+					// Check if WSDL operation details
+					if (wsdlBinding != null) {
+						wsdlBinding.updateOutput(defn, output);
+					}
+
+					ret.setBindingOutput(output);
+				}
+				
+				// Generate fault details
+				if (rr.getFaultDetails() != null) {
+					for (int i=0; i < rr.getFaultDetails().size(); i++) {
+						FaultDetails fd=rr.getFaultDetails().get(i);
+						
+						msgname = WSDLGeneratorUtil.getFaultMessageType(binding.getQName().getNamespaceURI(),
+												fd.getName());
+			
+						javax.wsdl.Message fm=getMessage(wsdls, contract, msgname,
+									fd.getTypes(), wsdlBinding);
+						if (fm != null) {
+							javax.wsdl.BindingFault fault=defn.createBindingFault();
+							fault.setName(fd.getName());
+							
+							// Check if WSDL operation details
+							if (wsdlBinding != null) {
+								wsdlBinding.updateFault(defn, fault);
+							}
+
+							ret.addBindingFault(fault);
+						}
+					}
+				}
+			}
+			
+			binding.addBindingOperation(ret);
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns a message, using the supplied WSDL definition,
+	 * based on the information supplied in the list of type references. If
+	 * a single type reference is supplied, this will be the message type,
+	 * if multiple type references are supplied, then these will be considered
+	 * the message parts.<p>
+	 * <p>
+	 * The returned message will be part of the supplied definition. If it
+	 * does not exist prior to the call to this method, then it will be
+	 * created and added to the definition upon returning the message.
+	 * 
+	 * @param wsdls The list of current WSDL definitions
+	 * @param contract The contract
+	 * @param msgname The message name
+	 * @param types The list of type references
+	 * @return The WSDL message
+	 */
+	public javax.wsdl.Message getMessage(java.util.List<javax.wsdl.Definition> wsdls,
+						org.savara.contract.model.Contract contract,
+						javax.xml.namespace.QName msgname,
+						java.util.List<org.savara.contract.model.Type> types,
+								WSDLBinding wsdlBinding) {
+		javax.wsdl.Message ret=null;
+		
+		if (types == null || types.size() == 0) {
+			throw new UnsupportedOperationException("Expecting single type reference");
+		} else if (types.size() > 1) {
+			throw new UnsupportedOperationException("Currently only supports single type reference");			
+		} else {
+			Type ref=types.get(0);
+			
+			java.util.Iterator<TypeDefinition> iter=ref.getTypeDefinitions().iterator();
+			boolean f_done=false;
+			
+			while (f_done == false && iter.hasNext()) {
+				TypeDefinition td=iter.next();
+				
+				if (TypeDefinition.XSD_ELEMENT.equals(td.getTypeSystem()) ||
+						TypeDefinition.XSD_TYPE.equals(td.getTypeSystem())) {
+					javax.xml.namespace.QName qname=
+						new javax.xml.namespace.QName(td.getNamespace(),td.getName());
+					javax.wsdl.Definition defn=
+						getDefinition(wsdls, contract, msgname.getNamespaceURI(), wsdlBinding);
+							
+					if (defn != null && qname != null &&
+							(ret = defn.getMessage(msgname)) == null) {
+						ret = defn.createMessage();
+						ret.setUndefined(false);
+						
+						ret.setQName(msgname);
+						
+						// Create single part for type or element
+						Part part=defn.createPart();
+						part.setName("content");
+						
+						if (TypeDefinition.XSD_ELEMENT.equals(td.getTypeSystem())) {
+							part.setElementName(qname);					
+						} else {
+							part.setTypeName(qname);
+						}
+						
+						ret.addPart(part);
+						
+						defn.addMessage(ret);
+						
+						f_done = true;
+					}
+				}
+			}
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.savara.wsdl/src/main/java/org/savara/wsdl/generator/soap/SOAPDocLitWSDLBinding.java
===================================================================
--- trunk/bundles/org.savara.wsdl/src/main/java/org/savara/wsdl/generator/soap/SOAPDocLitWSDLBinding.java	                        (rev 0)
+++ trunk/bundles/org.savara.wsdl/src/main/java/org/savara/wsdl/generator/soap/SOAPDocLitWSDLBinding.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,166 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.wsdl.generator.soap;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.savara.wsdl.generator.WSDLBinding;
+
+/**
+ * This interface is used to establish binding information on a
+ * WSDL definition.
+ *
+ */
+public class SOAPDocLitWSDLBinding implements WSDLBinding {
+	private static Log logger = LogFactory.getLog(SOAPDocLitWSDLBinding.class);
+
+	/**
+	 * This method returns the name of the WSDL binding implementation.
+	 * 
+	 * @return The WSDL binding
+	 */
+	public String getName() {
+		return("SOAP DocLit");
+	}
+	
+	/**
+	 * This method initializes the WSDL definition for the binding.
+	 * 
+	 * @param defn The definition
+	 */
+	public void initDefinition(javax.wsdl.Definition defn) {
+		defn.addNamespace("soap", "http://schemas.xmlsoap.org/wsdl/soap/");
+	}
+	
+	/**
+	 * This method adds WSDL binding information to the port binding.
+	 * 
+	 * @param defn The definition
+	 * @param binding The port type
+	 */
+	public void updateBinding(javax.wsdl.Definition defn, javax.wsdl.Binding binding) {
+		try {
+			javax.wsdl.extensions.soap.SOAPBinding sb=(javax.wsdl.extensions.soap.SOAPBinding)
+				defn.getExtensionRegistry().createExtension(javax.wsdl.Binding.class,
+							new javax.xml.namespace.QName("http://schemas.xmlsoap.org/wsdl/soap/", "binding"));
+			sb.setStyle("document");
+			sb.setTransportURI("http://schemas.xmlsoap.org/soap/http");
+			binding.addExtensibilityElement(sb);
+		} catch(Exception e) {
+			logger.error("Failed to add SOAP binding", e);
+		}
+	}
+	
+	/**
+	 * This method adds WSDL binding information to the operation.
+	 * 
+	 * @param defn The definition
+	 * @param mep The message exchange pattern
+	 * @param operation The operation
+	 */
+	public void updateOperation(javax.wsdl.Definition defn,
+			org.savara.contract.model.MessageExchangePattern mep,
+			javax.wsdl.BindingOperation operation) {
+		try {
+			javax.wsdl.extensions.soap.SOAPOperation soap=(javax.wsdl.extensions.soap.SOAPOperation)
+				defn.getExtensionRegistry().createExtension(javax.wsdl.BindingOperation.class,
+							new javax.xml.namespace.QName("http://schemas.xmlsoap.org/wsdl/soap/", "operation"));
+			soap.setSoapActionURI(defn.getTargetNamespace()+"/"+mep.getOperation());
+			operation.addExtensibilityElement(soap);
+		} catch(Exception e) {
+			logger.error("Failed to add SOAP operation", e);
+		}
+	}
+	
+	/**
+	 * This method adds WSDL binding information to the input.
+	 * 
+	 * @param defn The definition
+	 * @param input The input
+	 */
+	public void updateInput(javax.wsdl.Definition defn, javax.wsdl.BindingInput input) {
+		try {
+			javax.wsdl.extensions.soap.SOAPBody soap=(javax.wsdl.extensions.soap.SOAPBody)
+				defn.getExtensionRegistry().createExtension(javax.wsdl.BindingInput.class,
+							new javax.xml.namespace.QName("http://schemas.xmlsoap.org/wsdl/soap/", "body"));
+			soap.setUse("literal");
+			input.addExtensibilityElement(soap);
+		} catch(Exception e) {
+			logger.error("Failed to add SOAP body to input", e);
+		}
+	}
+	
+	/**
+	 * This method adds WSDL binding information to the output.
+	 * 
+	 * @param defn The definition
+	 * @param output The output
+	 */
+	public void updateOutput(javax.wsdl.Definition defn, javax.wsdl.BindingOutput output) {
+		try {
+			javax.wsdl.extensions.soap.SOAPBody soap=(javax.wsdl.extensions.soap.SOAPBody)
+				defn.getExtensionRegistry().createExtension(javax.wsdl.BindingOutput.class,
+							new javax.xml.namespace.QName("http://schemas.xmlsoap.org/wsdl/soap/", "body"));
+			soap.setUse("literal");
+			output.addExtensibilityElement(soap);
+		} catch(Exception e) {
+			logger.error("Failed to add SOAP body to output", e);
+		}
+	}
+	
+	/**
+	 * This method adds WSDL binding information to the fault.
+	 * 
+	 * @param defn The definition
+	 * @param fault The fault
+	 */
+	public void updateFault(javax.wsdl.Definition defn, javax.wsdl.BindingFault fault) {
+		try {
+			javax.wsdl.extensions.soap.SOAPFault soap=(javax.wsdl.extensions.soap.SOAPFault)
+				defn.getExtensionRegistry().createExtension(javax.wsdl.BindingFault.class,
+							new javax.xml.namespace.QName("http://schemas.xmlsoap.org/wsdl/soap/", "fault"));
+			soap.setUse("literal");
+			soap.setName(fault.getName());
+			
+			fault.addExtensibilityElement(soap);
+		} catch(Exception e) {
+			logger.error("Failed to add SOAP body to fault", e);
+		}
+	}
+	
+	/**
+	 * This method adds WSDL binding information to the fault.
+	 * 
+	 * @param defn The definition
+	 * @param port The port
+	 */
+	public void updatePort(javax.wsdl.Definition defn, javax.wsdl.Port port) {
+		try {
+			javax.wsdl.extensions.soap.SOAPAddress soap=(javax.wsdl.extensions.soap.SOAPAddress)
+				defn.getExtensionRegistry().createExtension(javax.wsdl.Port.class,
+							new javax.xml.namespace.QName("http://schemas.xmlsoap.org/wsdl/soap/", "address"));
+			soap.setLocationURI("http://localhost:8080/"+defn.getQName().getLocalPart()+"Service/"+
+								port.getName());
+			
+			port.addExtensibilityElement(soap);
+		} catch(Exception e) {
+			logger.error("Failed to add SOAP address to port", e);
+		}
+	}
+	
+}

Added: trunk/bundles/org.savara.wsdl/src/main/java/org/savara/wsdl/generator/soap/SOAPRPCWSDLBinding.java
===================================================================
--- trunk/bundles/org.savara.wsdl/src/main/java/org/savara/wsdl/generator/soap/SOAPRPCWSDLBinding.java	                        (rev 0)
+++ trunk/bundles/org.savara.wsdl/src/main/java/org/savara/wsdl/generator/soap/SOAPRPCWSDLBinding.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,170 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.wsdl.generator.soap;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.savara.wsdl.generator.WSDLBinding;
+
+/**
+ * This interface is used to establish binding information on a
+ * WSDL definition.
+ *
+ */
+public class SOAPRPCWSDLBinding implements WSDLBinding {
+	private static Log logger = LogFactory.getLog(SOAPRPCWSDLBinding.class);
+
+	/**
+	 * This method returns the name of the WSDL binding implementation.
+	 * 
+	 * @return The WSDL binding
+	 */
+	public String getName() {
+		return("SOAP RPC");
+	}
+	
+	/**
+	 * This method initializes the WSDL definition for the binding.
+	 * 
+	 * @param defn The definition
+	 */
+	public void initDefinition(javax.wsdl.Definition defn) {
+		defn.addNamespace("soap", "http://schemas.xmlsoap.org/wsdl/soap/");
+	}
+	
+	/**
+	 * This method adds WSDL binding information to the port binding.
+	 * 
+	 * @param defn The definition
+	 * @param binding The port type
+	 */
+	public void updateBinding(javax.wsdl.Definition defn, javax.wsdl.Binding binding) {
+		try {
+			javax.wsdl.extensions.soap.SOAPBinding sb=(javax.wsdl.extensions.soap.SOAPBinding)
+				defn.getExtensionRegistry().createExtension(javax.wsdl.Binding.class,
+							new javax.xml.namespace.QName("http://schemas.xmlsoap.org/wsdl/soap/", "binding"));
+			sb.setStyle("rpc");
+			sb.setTransportURI("http://schemas.xmlsoap.org/soap/http");
+			binding.addExtensibilityElement(sb);
+		} catch(Exception e) {
+			logger.error("Failed to add SOAP binding", e);
+		}
+	}
+	
+	/**
+	 * This method adds WSDL binding information to the operation.
+	 * 
+	 * @param defn The definition
+	 * @param mep The message exchange pattern
+	 * @param operation The operation
+	 */
+	public void updateOperation(javax.wsdl.Definition defn,
+			org.savara.contract.model.MessageExchangePattern mep,
+			javax.wsdl.BindingOperation operation) {
+		try {
+			javax.wsdl.extensions.soap.SOAPOperation soap=(javax.wsdl.extensions.soap.SOAPOperation)
+				defn.getExtensionRegistry().createExtension(javax.wsdl.BindingOperation.class,
+							new javax.xml.namespace.QName("http://schemas.xmlsoap.org/wsdl/soap/", "operation"));
+			soap.setStyle("rpc");
+			soap.setSoapActionURI("");
+			operation.addExtensibilityElement(soap);
+		} catch(Exception e) {
+			logger.error("Failed to add SOAP operation", e);
+		}
+	}
+	
+	/**
+	 * This method adds WSDL binding information to the input.
+	 * 
+	 * @param defn The definition
+	 * @param input The input
+	 */
+	public void updateInput(javax.wsdl.Definition defn, javax.wsdl.BindingInput input) {
+		try {
+			javax.wsdl.extensions.soap.SOAPBody soap=(javax.wsdl.extensions.soap.SOAPBody)
+				defn.getExtensionRegistry().createExtension(javax.wsdl.BindingInput.class,
+							new javax.xml.namespace.QName("http://schemas.xmlsoap.org/wsdl/soap/", "body"));
+			soap.setUse("literal");
+			soap.setNamespaceURI(defn.getTargetNamespace());
+			input.addExtensibilityElement(soap);
+		} catch(Exception e) {
+			logger.error("Failed to add SOAP body to input", e);
+		}
+	}
+	
+	/**
+	 * This method adds WSDL binding information to the output.
+	 * 
+	 * @param defn The definition
+	 * @param output The output
+	 */
+	public void updateOutput(javax.wsdl.Definition defn, javax.wsdl.BindingOutput output) {
+		try {
+			javax.wsdl.extensions.soap.SOAPBody soap=(javax.wsdl.extensions.soap.SOAPBody)
+				defn.getExtensionRegistry().createExtension(javax.wsdl.BindingOutput.class,
+							new javax.xml.namespace.QName("http://schemas.xmlsoap.org/wsdl/soap/", "body"));
+			soap.setUse("literal");
+			soap.setNamespaceURI(defn.getTargetNamespace());
+			output.addExtensibilityElement(soap);
+		} catch(Exception e) {
+			logger.error("Failed to add SOAP body to output", e);
+		}
+	}
+	
+	/**
+	 * This method adds WSDL binding information to the fault.
+	 * 
+	 * @param defn The definition
+	 * @param fault The fault
+	 */
+	public void updateFault(javax.wsdl.Definition defn, javax.wsdl.BindingFault fault) {
+		try {
+			javax.wsdl.extensions.soap.SOAPFault soap=(javax.wsdl.extensions.soap.SOAPFault)
+				defn.getExtensionRegistry().createExtension(javax.wsdl.BindingFault.class,
+							new javax.xml.namespace.QName("http://schemas.xmlsoap.org/wsdl/soap/", "fault"));
+			soap.setUse("literal");
+			soap.setNamespaceURI(defn.getTargetNamespace());
+			soap.setName(fault.getName());
+			
+			fault.addExtensibilityElement(soap);
+		} catch(Exception e) {
+			logger.error("Failed to add SOAP body to fault", e);
+		}
+	}
+	
+	/**
+	 * This method adds WSDL binding information to the fault.
+	 * 
+	 * @param defn The definition
+	 * @param port The port
+	 */
+	public void updatePort(javax.wsdl.Definition defn, javax.wsdl.Port port) {
+		try {
+			javax.wsdl.extensions.soap.SOAPAddress soap=(javax.wsdl.extensions.soap.SOAPAddress)
+				defn.getExtensionRegistry().createExtension(javax.wsdl.Port.class,
+							new javax.xml.namespace.QName("http://schemas.xmlsoap.org/wsdl/soap/", "address"));
+			soap.setLocationURI("http://localhost:8080/"+defn.getQName().getLocalPart()+"Service/"+
+								port.getName());
+			
+			port.addExtensibilityElement(soap);
+		} catch(Exception e) {
+			logger.error("Failed to add SOAP address to port", e);
+		}
+	}
+	
+}

Added: trunk/bundles/org.savara.wsdl/src/main/java/org/savara/wsdl/osgi/Activator.java
===================================================================
--- trunk/bundles/org.savara.wsdl/src/main/java/org/savara/wsdl/osgi/Activator.java	                        (rev 0)
+++ trunk/bundles/org.savara.wsdl/src/main/java/org/savara/wsdl/osgi/Activator.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.savara.wsdl.osgi;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator {
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+	 */
+	public void start(BundleContext context) throws Exception {
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+	 */
+	public void stop(BundleContext context) throws Exception {
+	}
+
+}

Added: trunk/bundles/org.savara.wsdl/src/main/java/org/savara/wsdl/util/WSDLGeneratorUtil.java
===================================================================
--- trunk/bundles/org.savara.wsdl/src/main/java/org/savara/wsdl/util/WSDLGeneratorUtil.java	                        (rev 0)
+++ trunk/bundles/org.savara.wsdl/src/main/java/org/savara/wsdl/util/WSDLGeneratorUtil.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.wsdl.util;
+
+/**
+ * This class provides general utility functions for
+ * use when generating artefacts.
+ */
+public class WSDLGeneratorUtil {
+
+	private static final String RESPONSE = "Response";
+	private static final String FAULT = "Fault";
+	private static final String REQUEST = "Request";
+
+	/**
+	 * This method returns the request message type QName.
+	 * 
+	 * @param intfNamespace The interface namespace
+	 * @param op The operation name
+	 * @return The request message type
+	 */
+	public static javax.xml.namespace.QName getRequestMessageType(String intfNamespace, String op) {
+		return(new javax.xml.namespace.QName(intfNamespace, op+REQUEST));
+	}
+
+	/**
+	 * This method returns the response message type QName.
+	 * 
+	 * @param intfNamespace The interface namespace
+	 * @param op The operation name
+	 * @return The response message type
+	 */
+	public static javax.xml.namespace.QName getResponseMessageType(String intfNamespace, String op) {
+		return(new javax.xml.namespace.QName(intfNamespace, op+RESPONSE));
+	}
+
+	/**
+	 * This method returns the fault message type QName.
+	 * 
+	 * @param intfNamespace The interface namespace
+	 * @param faultName The fault name
+	 * @return The fault message type
+	 */
+	public static javax.xml.namespace.QName getFaultMessageType(String intfNamespace, String faultName) {
+		return(new javax.xml.namespace.QName(intfNamespace, faultName+FAULT));
+	}
+}

Added: trunk/bundles/org.savara.wsdl/src/test/java/org/savara/tools/wsdl/tests/WSDLGeneratorTest.java
===================================================================
--- trunk/bundles/org.savara.wsdl/src/test/java/org/savara/tools/wsdl/tests/WSDLGeneratorTest.java	                        (rev 0)
+++ trunk/bundles/org.savara.wsdl/src/test/java/org/savara/tools/wsdl/tests/WSDLGeneratorTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,591 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.savara.tools.wsdl.tests;
+
+import javax.wsdl.Part;
+import javax.xml.namespace.QName;
+
+import org.savara.contract.model.*;
+import org.savara.wsdl.generator.WSDLGenerator;
+import org.savara.wsdl.generator.WSDLGeneratorFactory;
+import org.savara.wsdl.generator.impl.WSDLGeneratorImpl;
+
+import junit.framework.TestCase;
+
+public class WSDLGeneratorTest extends TestCase {
+
+	private static final String TEST_LOCALPART = "test.localpart";
+	private static final String HTTP_TEST_NAMESPACE = "http://test.namespace";
+	private static final String TEST_TYPE_NS = "testTypeNS";
+	private static final String TEST_TYPE_LP = "testTypeLP";
+	private static final String TEST_NAME_SPACE = "testNameSpace";
+	private static final String TEST_NAME_SPACE2 = "testNameSpace2";
+	private static final String TEST_NAME_SPACE3 = "testNameSpace3";
+	private static final String TEST_NAME = "testName";
+
+	public void testDefnNameAndNamespace() {
+		
+		Contract c=new Contract();
+		
+		c.setName(TEST_NAME);
+		c.setNamespace(TEST_NAME_SPACE);
+		
+		WSDLGeneratorImpl gen=new WSDLGeneratorImpl();
+		
+		java.util.List<javax.wsdl.Definition> defns=gen.generate(c, null);
+		
+		if (defns.size() != 1) {
+			fail("Only one Definition found: "+defns.size());
+		}
+		
+		javax.wsdl.Definition defn=defns.get(0);
+		
+		if (defn.getTargetNamespace() == null) {
+			fail("Target namespace not set");
+		}
+		
+		if (TEST_NAME_SPACE.equals(defn.getTargetNamespace()) == false) {
+			fail("Target namespace not correct: "+defn.getTargetNamespace());
+		}
+		
+		if (defn.getQName() == null) {
+			fail("QName not set");
+		}
+		
+		if (defn.getQName().getLocalPart() == null) {
+			fail("QName localpart not set");
+		}
+		
+		if (TEST_NAME.equals(defn.getQName().getLocalPart()) == false) {
+			fail("QName localpart not correct: "+defn.getQName().getLocalPart());
+		}
+	}
+	
+	public void testPortTypeNameAndNamespace() {
+		Interface src=new Interface();
+		
+		src.setName(TEST_NAME);
+		src.setNamespace(TEST_NAME_SPACE);
+		
+		WSDLGeneratorImpl gen=new WSDLGeneratorImpl();
+		
+		java.util.List<javax.wsdl.Definition> defns=new java.util.Vector<javax.wsdl.Definition>();
+		
+		javax.wsdl.PortType result=gen.createPortType(defns, new Contract(), src, null);
+		
+		if (result == null) {
+			fail("PortType is null");
+		}
+		
+		if (result.getQName() == null) {
+			fail("QName not set");
+		}
+		
+		if (result.getQName().getNamespaceURI() == null) {
+			fail("QName namespace not set");
+		}
+		
+		if (TEST_NAME_SPACE.equals(result.getQName().getNamespaceURI()) == false) {
+			fail("Namespace not correct: "+result.getQName().getNamespaceURI());
+		}
+		
+		if (result.getQName().getLocalPart() == null) {
+			fail("QName localpart not set");
+		}
+		
+		if (TEST_NAME.equals(result.getQName().getLocalPart()) == false) {
+			fail("QName localpart not correct: "+result.getQName().getLocalPart());
+		}
+	}
+	
+	public void testPortTypeBindingNameAndNamespace() {
+		Interface src=new Interface();
+		
+		src.setName(TEST_NAME);
+		src.setNamespace(TEST_NAME_SPACE);
+		
+		WSDLGeneratorImpl gen=new WSDLGeneratorImpl();
+		
+		java.util.List<javax.wsdl.Definition> defns=new java.util.Vector<javax.wsdl.Definition>();
+		
+		javax.wsdl.Binding result=gen.createBinding(defns, new Contract(), src, null, null);
+		
+		if (result == null) {
+			fail("PortType is null");
+		}
+		
+		if (result.getQName() == null) {
+			fail("QName not set");
+		}
+		
+		if (result.getQName().getNamespaceURI() == null) {
+			fail("QName namespace not set");
+		}
+		
+		if (TEST_NAME_SPACE.equals(result.getQName().getNamespaceURI()) == false) {
+			fail("Namespace not correct: "+result.getQName().getNamespaceURI());
+		}
+		
+		if (result.getQName().getLocalPart() == null) {
+			fail("QName localpart not set");
+		}
+		
+		if (result.getQName().getLocalPart().equals(TEST_NAME+WSDLGeneratorImpl.BINDING_SUFFIX) == false) {
+			fail("QName localpart not correct: "+result.getQName().getLocalPart());
+		}
+	}
+	
+	public void testDefnWithPortTypesAndBindings() {
+		
+		Contract c=new Contract();
+		c.setNamespace(TEST_NAME_SPACE);
+
+		Interface i1=new Interface();
+		i1.setName("I1");
+		i1.setNamespace(TEST_NAME_SPACE);
+		
+		// Need to associate a message, to ensure port type
+		// is generated
+		OneWayRequestMEP m1=new OneWayRequestMEP();
+		
+		m1.setOperation(TEST_NAME);
+		
+		Type tref1=new Type();
+		TypeDefinition ref1=new TypeDefinition();
+		tref1.getTypeDefinitions().add(ref1);
+		ref1.setName(TEST_TYPE_LP);
+		ref1.setNamespace(TEST_NAME_SPACE);
+		ref1.setTypeSystem(TypeDefinition.XSD_TYPE);
+		m1.getTypes().add(tref1);
+		
+		i1.getMessageExchangePatterns().add(m1);
+		
+		Interface i2=new Interface();
+		i2.setName("I2");
+		i2.setNamespace(TEST_NAME_SPACE);
+		
+		OneWayRequestMEP m2=new OneWayRequestMEP();
+		
+		m2.setOperation(TEST_NAME);
+		
+		Type tref2=new Type();
+		TypeDefinition ref2=new TypeDefinition();
+		tref2.getTypeDefinitions().add(ref1);
+		ref2.setName(TEST_TYPE_LP);
+		ref2.setNamespace(TEST_NAME_SPACE);
+		ref2.setTypeSystem(TypeDefinition.XSD_TYPE);
+		m2.getTypes().add(tref2);
+		
+		i2.getMessageExchangePatterns().add(m2);
+		
+		Interface i3=new Interface();
+		i3.setName("I3");
+		i3.setNamespace(TEST_NAME_SPACE);
+		
+		OneWayRequestMEP m3=new OneWayRequestMEP();
+		
+		m3.setOperation(TEST_NAME);
+		
+		Type tref3=new Type();
+		TypeDefinition ref3=new TypeDefinition();
+		tref3.getTypeDefinitions().add(ref1);
+		ref3.setName(TEST_TYPE_LP);
+		ref3.setNamespace(TEST_NAME_SPACE);
+		ref3.setTypeSystem(TypeDefinition.XSD_TYPE);
+		m3.getTypes().add(tref3);
+		
+		i3.getMessageExchangePatterns().add(m3);
+		
+		c.getInterfaces().add(i1);
+		c.getInterfaces().add(i2);
+		c.getInterfaces().add(i3);
+		
+		WSDLGeneratorImpl gen=new WSDLGeneratorImpl();
+		
+		java.util.List<javax.wsdl.Definition> defns=gen.generate(c, null);
+		
+		if (defns.size() != 1) {
+			fail("Only one Definition found: "+defns.size());
+		}
+		
+		javax.wsdl.Definition defn=defns.get(0);
+
+		if (defn.getPortTypes().size() != c.getInterfaces().size()) {
+			fail("Number of port types ("+defn.getPortTypes().size()+
+					") does not match number of interfaces ("+
+					c.getInterfaces().size()+")");
+		}
+
+		if (defn.getBindings().size() != c.getInterfaces().size()) {
+			fail("Number of port type bindings ("+defn.getBindings().size()+
+					") does not match number of interfaces ("+
+					c.getInterfaces().size()+")");
+		}
+	}
+	
+	public void testOperationOneWay() {
+		javax.wsdl.Definition defn=null;
+		try {
+			javax.wsdl.factory.WSDLFactory fact=
+						javax.wsdl.factory.WSDLFactory.newInstance();
+			
+			defn = fact.newDefinition();
+			
+		} catch(Exception e) {
+			fail("Failed to get definition");
+		}
+		
+		OneWayRequestMEP src=new OneWayRequestMEP();
+		
+		src.setOperation(TEST_NAME);
+		
+		Type tref=new Type();
+		TypeDefinition ref=new TypeDefinition();
+		tref.getTypeDefinitions().add(ref);
+		ref.setName(TEST_TYPE_LP);
+		ref.setNamespace(TEST_TYPE_NS);
+		ref.setTypeSystem(TypeDefinition.XSD_TYPE);
+		tref.setName(ref.getName());
+		src.getTypes().add(tref);
+		
+		WSDLGeneratorImpl gen=new WSDLGeneratorImpl();
+		
+		java.util.List<javax.wsdl.Definition> defns=new java.util.Vector<javax.wsdl.Definition>();
+		defns.add(defn);
+		
+		defn.setTargetNamespace(TEST_NAME_SPACE);
+		
+		javax.wsdl.PortType ptype=defn.createPortType();
+		ptype.setQName(new javax.xml.namespace.QName(TEST_NAME_SPACE, TEST_NAME));
+		
+		javax.wsdl.Operation result=gen.createOperation(defns, new Contract(), ptype, src, null);
+		
+		if (result == null) {
+			fail("Operation is null");
+		}
+		
+		if (TEST_NAME.equals(result.getName()) == false) {
+			fail("Operation name mismatch: "+result.getName());
+		}
+		
+		if (result.getInput() == null) {
+			fail("Input not set");
+		}
+		
+		if (result.getOutput() != null) {
+			fail("Output should NOT be set");
+		}
+		
+		if (result.getFaults().size() != 0) {
+			fail("Faults should NOT be defined");
+		}
+	}
+	
+	public void testOperationReqRespFaults() {
+		javax.wsdl.Definition defn=null;
+		try {
+			javax.wsdl.factory.WSDLFactory fact=
+						javax.wsdl.factory.WSDLFactory.newInstance();
+			
+			defn = fact.newDefinition();
+			
+		} catch(Exception e) {
+			fail("Failed to get definition");
+		}
+		
+		RequestResponseMEP src=new RequestResponseMEP();
+		
+		src.setOperation(TEST_NAME);
+		
+		Type tref1=new Type();
+		TypeDefinition ref1=new TypeDefinition();
+		tref1.getTypeDefinitions().add(ref1);
+		ref1.setName(TEST_TYPE_LP);
+		ref1.setNamespace(TEST_TYPE_NS);
+		ref1.setTypeSystem(TypeDefinition.XSD_TYPE);
+		src.getTypes().add(tref1);
+		
+		Type tref2=new Type();
+		TypeDefinition ref2=new TypeDefinition();
+		tref2.getTypeDefinitions().add(ref2);
+		ref2.setName(TEST_TYPE_LP);
+		ref2.setNamespace(TEST_TYPE_NS);
+		ref2.setTypeSystem(TypeDefinition.XSD_TYPE);
+		src.getResponseTypes().add(tref2);
+		
+		FaultDetails fd1=new FaultDetails();
+		fd1.setName("faultName1");
+
+		Type tref3=new Type();
+		TypeDefinition ref3=new TypeDefinition();
+		tref3.getTypeDefinitions().add(ref3);
+		ref3.setName(TEST_TYPE_LP);
+		ref3.setNamespace(TEST_TYPE_NS);
+		ref3.setTypeSystem(TypeDefinition.XSD_TYPE);
+		fd1.getTypes().add(tref3);
+		
+		src.getFaultDetails().add(fd1);
+		
+		FaultDetails fd2=new FaultDetails();
+		fd2.setName("faultName2");
+
+		Type tref4=new Type();
+		TypeDefinition ref4=new TypeDefinition();
+		tref4.getTypeDefinitions().add(ref4);
+		ref4.setName(TEST_TYPE_LP);
+		ref4.setNamespace(TEST_TYPE_NS);
+		ref4.setTypeSystem(TypeDefinition.XSD_TYPE);
+		fd2.getTypes().add(tref4);
+		
+		src.getFaultDetails().add(fd2);
+		
+		WSDLGeneratorImpl gen=new WSDLGeneratorImpl();
+		
+		java.util.List<javax.wsdl.Definition> defns=new java.util.Vector<javax.wsdl.Definition>();
+		defns.add(defn);
+		
+		defn.setTargetNamespace(TEST_NAME_SPACE);
+		
+		javax.wsdl.PortType ptype=defn.createPortType();
+		ptype.setQName(new javax.xml.namespace.QName(TEST_NAME_SPACE, TEST_NAME));
+		
+		javax.wsdl.Operation result=gen.createOperation(defns, new Contract(), ptype, src, null);
+		
+		if (result == null) {
+			fail("Operation is null");
+		}
+		
+		if (TEST_NAME.equals(result.getName()) == false) {
+			fail("Operation name mismatch: "+result.getName());
+		}
+		
+		if (result.getInput() == null) {
+			fail("Input not set");
+		}
+		
+		if (result.getOutput() == null) {
+			fail("Output not set");
+		}
+		
+		if (result.getFaults().size() != src.getFaultDetails().size()) {
+			fail("Faults number ("+result.getFaults().size()+
+						") does not match contract ("+src.getFaultDetails().size()+")");
+		}
+	}
+	
+	public void testMessage() {
+		javax.wsdl.Definition defn=null;
+		try {
+			javax.wsdl.factory.WSDLFactory fact=
+						javax.wsdl.factory.WSDLFactory.newInstance();
+			
+			defn = fact.newDefinition();
+			
+		} catch(Exception e) {
+			fail("Failed to get definition");
+		}
+		
+		TypeDefinition src=new TypeDefinition();
+		src.setName(TEST_TYPE_LP);
+		src.setNamespace(TEST_TYPE_NS);
+		src.setTypeSystem(TypeDefinition.XSD_TYPE);
+		
+		Type t=new Type();
+		t.getTypeDefinitions().add(src);
+		
+		java.util.List<Type> refs=new java.util.Vector<Type>();
+		refs.add(t);
+		
+		WSDLGeneratorImpl gen=new WSDLGeneratorImpl();
+		
+		java.util.List<javax.wsdl.Definition> defns=new java.util.Vector<javax.wsdl.Definition>();
+		
+		QName msgname=new QName(HTTP_TEST_NAMESPACE,TEST_LOCALPART);
+		
+		javax.wsdl.Message result=gen.getMessage(defns, new Contract(), msgname, refs, null);
+		
+		if (result == null) {
+			fail("Message is null");
+		}
+		
+		if (result.getQName() == null) {
+			fail("QName not set");
+		}
+		
+		if (result.getQName().getLocalPart() == null) {
+			fail("QName localpart not set");
+		}
+		
+		if (TEST_LOCALPART.equals(result.getQName().getLocalPart()) == false) {
+			fail("QName localpart not correct: "+result.getQName().getLocalPart());
+		}
+		
+		if (result.getQName().getNamespaceURI() == null) {
+			fail("QName namespace not set");
+		}
+		
+		if (HTTP_TEST_NAMESPACE.equals(result.getQName().getNamespaceURI()) == false) {
+			fail("QName namespace not correct: "+result.getQName().getNamespaceURI());
+		}
+		
+		if (result.getParts().size() != 1) {
+			fail("Should be one part: "+result.getParts().size());
+		}
+		
+		Part part=(Part)result.getParts().values().toArray()[0];
+		
+		if (part.getElementName() != null) {
+			fail("Element name should not be set");
+		}
+		
+		if (part.getTypeName() == null) {
+			fail("Type name not set");
+		}
+		
+		if (TEST_TYPE_NS.equals(part.getTypeName().getNamespaceURI()) == false) {
+			fail("Element namespace incorrect: "+part.getTypeName().getNamespaceURI());
+		}
+		
+		if (TEST_TYPE_LP.equals(part.getTypeName().getLocalPart()) == false) {
+			fail("Element localpart incorrect: "+part.getTypeName().getLocalPart());
+		}
+	}
+	
+	public void testDefnWithPortTypesAndMesgsInDiffNamespaces() {
+		
+		Contract c=new Contract();
+		c.setNamespace(TEST_NAME_SPACE);
+
+		Interface i1=new Interface();
+		i1.setName("I1");
+		i1.setNamespace(TEST_NAME_SPACE);
+		
+		// Need to associate a message, to ensure port type
+		// is generated
+		OneWayRequestMEP m1=new OneWayRequestMEP();
+		
+		m1.setOperation(TEST_NAME);
+		
+		Type tref1=new Type();
+		TypeDefinition ref1=new TypeDefinition();
+		tref1.getTypeDefinitions().add(ref1);
+		ref1.setName(TEST_TYPE_LP);
+		ref1.setNamespace(TEST_NAME_SPACE);
+		ref1.setTypeSystem(TypeDefinition.XSD_TYPE);
+		m1.getTypes().add(tref1);
+		
+		i1.getMessageExchangePatterns().add(m1);
+		
+		Interface i2=new Interface();
+		i2.setName("I2");
+		i2.setNamespace(TEST_NAME_SPACE2);
+		
+		OneWayRequestMEP m2=new OneWayRequestMEP();
+		
+		m2.setOperation(TEST_NAME);
+		
+		Type tref2=new Type();
+		TypeDefinition ref2=new TypeDefinition();
+		tref2.getTypeDefinitions().add(ref2);
+		ref2.setName(TEST_TYPE_LP);
+		ref2.setNamespace(TEST_NAME_SPACE2);
+		ref2.setTypeSystem(TypeDefinition.XSD_TYPE);
+		m2.getTypes().add(tref2);
+		
+		i2.getMessageExchangePatterns().add(m2);
+		
+		Interface i3=new Interface();
+		i3.setName("I3");
+		i3.setNamespace(TEST_NAME_SPACE2);
+		
+		OneWayRequestMEP m3=new OneWayRequestMEP();
+		
+		m3.setOperation(TEST_NAME);
+		
+		Type tref3=new Type();
+		TypeDefinition ref3=new TypeDefinition();
+		tref3.getTypeDefinitions().add(ref3);
+		ref3.setName(TEST_TYPE_LP);
+		ref3.setNamespace(TEST_NAME_SPACE3);
+		ref3.setTypeSystem(TypeDefinition.XSD_TYPE);
+		m3.getTypes().add(tref3);
+		
+		i3.getMessageExchangePatterns().add(m3);
+		
+		c.getInterfaces().add(i1);
+		c.getInterfaces().add(i2);
+		c.getInterfaces().add(i3);
+		
+		WSDLGeneratorImpl gen=new WSDLGeneratorImpl();
+		
+		java.util.List<javax.wsdl.Definition> defns=gen.generate(c, null);
+		
+		if (defns.size() != 2) {
+			fail("Two Definitions expected, but got: "+defns.size());
+		}
+		
+		javax.wsdl.Definition defn1=defns.get(0);
+
+		if (defn1.getPortTypes().size() != 1) {
+			fail("1: Number of port types ("+defn1.getPortTypes().size()+
+					") does not match number expected (1)");
+		}
+		
+		if (defn1.getBindings().size() != 1) {
+			fail("1: Number of port type bindings ("+defn1.getBindings().size()+
+					") does not match number expected (1)");
+		}
+		
+		if (defn1.getMessages().size() != 1) {
+			fail("1: Number of message ("+defn1.getMessages().size()+
+			") does not match number expected (1)");
+		}
+		
+		javax.wsdl.Definition defn2=defns.get(1);
+
+		if (defn2.getPortTypes().size() != 2) {
+			fail("2: Number of port types ("+defn2.getPortTypes().size()+
+					") does not match number expected (2)");
+		}
+		
+		if (defn2.getBindings().size() != 2) {
+			fail("2: Number of port type bindings ("+defn2.getBindings().size()+
+					") does not match number expected (2)");
+		}
+		
+		if (defn2.getMessages().size() != 1) {
+			fail("2: Number of message ("+defn2.getMessages().size()+
+			") does not match number expected (1)");
+		}
+		
+		// Check service only associated with the first defn
+		if (defn1.getServices().size() != 1) {
+			fail("First definition should only have 1 service: "+defn1.getServices().size());
+		}
+		
+		javax.wsdl.Service s=(javax.wsdl.Service)
+					defn1.getServices().values().iterator().next();
+		if (s.getPorts().size() != 3) {
+			fail("Should be 3 ports: "+s.getPorts().size());
+		}
+		
+		if (defn2.getServices().size() != 0) {
+			fail("Second definition should not have any services: "+defn2.getServices().size());
+		}
+	}
+}

Added: trunk/bundles/org.scribble.conformance/.classpath
===================================================================
--- trunk/bundles/org.scribble.conformance/.classpath	                        (rev 0)
+++ trunk/bundles/org.scribble.conformance/.classpath	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src/test"/>
+	<classpathentry kind="src" path="src/plugintest"/>
+	<classpathentry kind="src" path="src/main/java"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
+	<classpathentry kind="output" path="classes"/>
+</classpath>

Added: trunk/bundles/org.scribble.conformance/.project
===================================================================
--- trunk/bundles/org.scribble.conformance/.project	                        (rev 0)
+++ trunk/bundles/org.scribble.conformance/.project	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.scribble.conformance</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.ManifestBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.SchemaBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.pde.PluginNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

Added: trunk/bundles/org.scribble.conformance/LICENSE.txt
===================================================================
--- trunk/bundles/org.scribble.conformance/LICENSE.txt	                        (rev 0)
+++ trunk/bundles/org.scribble.conformance/LICENSE.txt	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,201 @@
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   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.

Added: trunk/bundles/org.scribble.conformance/META-INF/MANIFEST.MF
===================================================================
--- trunk/bundles/org.scribble.conformance/META-INF/MANIFEST.MF	                        (rev 0)
+++ trunk/bundles/org.scribble.conformance/META-INF/MANIFEST.MF	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,24 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Scribble Conformance Plug-in
+Bundle-SymbolicName: org.scribble.conformance;singleton:=true
+Bundle-Version: 1.2.0.qualifier
+Bundle-Activator: org.scribble.conformance.osgi.Activator
+Bundle-Vendor: www.scribble.org
+Import-Package: org.osgi.framework;version="1.3.0"
+Require-Bundle: org.scribble.core;bundle-version="[1.0.0,2.0.0)",
+ org.eclipse.core.runtime;resolution:=optional,
+ org.junit;resolution:=optional
+Bundle-ActivationPolicy: lazy
+Export-Package: org.scribble.conformance.comparator,
+ org.scribble.conformance.model,
+ org.scribble.conformance.model.transform
+Scribble-Extensions: org.scribble.conformance.comparator.BehaviourListComparatorRule,
+  org.scribble.conformance.comparator.StatelessDefinitionComparatorRule,
+  org.scribble.conformance.model.transform.DefaultStatelessTransformer,
+  org.scribble.conformance.model.transform.BlockStatelessTransformationRule,
+  org.scribble.conformance.model.transform.InteractionStatelessTransformationRule,
+  org.scribble.conformance.model.transform.MessageSignatureStatelessTransformationRule,
+  org.scribble.conformance.model.transform.RoleStatelessTransformationRule,
+  org.scribble.conformance.model.transform.TypeReferenceStatelessTransformationRule
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6

Added: trunk/bundles/org.scribble.conformance/build.properties
===================================================================
--- trunk/bundles/org.scribble.conformance/build.properties	                        (rev 0)
+++ trunk/bundles/org.scribble.conformance/build.properties	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,5 @@
+source.. = src/main/java/
+output.. = classes/
+bin.includes = META-INF/,\
+               .,\
+               plugin.xml

Added: trunk/bundles/org.scribble.conformance/pom.xml
===================================================================
--- trunk/bundles/org.scribble.conformance/pom.xml	                        (rev 0)
+++ trunk/bundles/org.scribble.conformance/pom.xml	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,28 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  	<modelVersion>4.0.0</modelVersion>
+	<groupId>org.savara.bundles</groupId>
+	<artifactId>org.scribble.conformance</artifactId> 
+	<version>1.2.0-SNAPSHOT</version>
+	<packaging>jar</packaging>
+	<name>Savara::Bundles::ScribbleConformance</name>
+
+	<parent>
+		<groupId>org.savara</groupId>
+		<artifactId>bundles</artifactId>
+		<version>1.2.0-SNAPSHOT</version>
+	</parent>
+
+	<dependencies>
+		<dependency>
+			<groupId>org.savara.bundles</groupId>
+			<artifactId>org.scribble.core</artifactId>
+			<version>1.2.0-SNAPSHOT</version>
+		</dependency>
+	    <dependency>
+	      <groupId>org.apache.felix</groupId>
+	      <artifactId>org.osgi.core</artifactId>
+	      <version>${osgi.version}</version>
+	    </dependency>
+	</dependencies>
+</project>

Added: trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/comparator/BehaviourListComparatorRule.java
===================================================================
--- trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/comparator/BehaviourListComparatorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/comparator/BehaviourListComparatorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,881 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 27 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.conformance.comparator;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.DefaultModelListener;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.model.resolutions.*;
+import org.scribble.comparator.*;
+import org.scribble.conformance.model.*;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This class provides the BehaviourList comparator rule.
+ */
+ at RegistryInfo(extension=ComparatorRule.class)
+public class BehaviourListComparatorRule implements ComparatorRule {
+
+	/**
+	 * This method determines whether the comparison rule is
+	 * associated with the supplied type.
+	 * 
+	 * @param obj The object to check
+	 * @return Whether the object is of a type supported by the
+	 * 					comparison rule
+	 */
+	public boolean isTypeSupported(ModelObject obj) {
+		return(obj instanceof BehaviourList);
+	}
+	
+	/**
+	 * This method determines whether the comparison rule is
+	 * appropriate for the supplied model objects.
+	 * 
+	 * @param main The main model object to be compared
+	 * @param ref The reference model object to be compared against
+	 * @return Whether the rule is relevant for the
+	 * 				model objects
+	 */
+	public boolean isComparisonSupported(ModelObject main, ModelObject ref) {
+		return(main instanceof BehaviourList &&
+				ref instanceof BehaviourList);
+	}
+	
+	/**
+	 * This method compares a model object against a reference
+	 * component to determine if they are equal.
+	 * 
+	 * @param context The context
+	 * @param main The main model object
+	 * @param reference The reference model object
+	 * @param l The model listener
+	 * @param deep Perform a deep compare
+	 * @return Whether the model objects are comparable
+	 */
+	public boolean compare(ComparatorContext context, ModelObject main,
+					ModelObject reference, ModelListener l, boolean deep) {
+		boolean ret=false;
+		BehaviourList mainbl=(BehaviourList)main;
+		BehaviourList refbl=(BehaviourList)reference;
+
+		if (context.compare(mainbl.getBlock(), refbl.getBlock(),
+							l, false)) {
+		
+			ret = true;
+			
+			// Get iterators for the two lists
+			BehaviourListIterator mainiter=mainbl.getIterator();
+			BehaviourListIterator refiter=refbl.getIterator();
+			
+			SyncPoint syncPoint=null;
+			
+			while ((syncPoint=findNextSyncPoint(context, mainiter, refiter,
+								true, null)) != null) {
+				
+				// Process behaviours between previous and new sync point
+				if (syncPoint.isGap()) {
+					BehaviourListIterator innerMainIter=mainiter.snapshot();
+					BehaviourListIterator innerRefIter=refiter.snapshot();
+					
+					SyncPoint innerSyncPoint=null;
+					
+					while ((innerSyncPoint=findNextSyncPoint(context, innerMainIter,
+									innerRefIter, false, syncPoint)) != null) {
+											
+						if (innerSyncPoint.isGap()) {
+							int mainCount=innerSyncPoint.getMainCount();
+							int refCount=innerSyncPoint.getReferenceCount();
+							Behaviour mainPoint=null;
+							
+							while (mainCount > 0) {
+								mainPoint = innerMainIter.next();
+							
+								if (isConditionalDecisionMaker(mainPoint) == false) {
+									String mesg=org.scribble.util.MessageUtil.format(
+										java.util.PropertyResourceBundle.getBundle(
+										"org.scribble.comparator.Messages").
+										getString("_UNEXPECTED_BEHAVIOUR"), null);
+								
+									ModelIssue issue=new ModelIssue(mainPoint, mesg);
+								
+									issue.getResolutions().add(new DeleteFromModel());
+								
+									l.error(issue);
+								
+									ret = false;
+									
+									// Exit loop
+									mainCount = 0;
+								} else {
+									mainCount--;
+								}
+							}
+							
+							// Get main activity to be compared
+							mainPoint = innerMainIter.next();
+							
+							Behaviour refPoint=null;
+							
+							while (refCount > 0) {
+								refPoint = innerRefIter.next();
+
+								if (isConditionalDecisionMaker(refPoint) == false) {
+									
+									// TODO: Check if 'refPoint' is a conditional
+									// activity that is located at the projected role
+									// and if so, then don't report as an expected
+									// activity error
+									
+									String mesg=org.scribble.util.MessageUtil.format(
+											java.util.PropertyResourceBundle.getBundle(
+											"org.scribble.conformance.comparator.Messages").
+											getString("_EXPECTING_ACTIVITY"), null);
+										
+									ModelIssue issue=null;
+									
+									if (mainPoint != null) {
+										issue = new ModelIssue(mainPoint, mesg);
+									} else {
+										issue = new ModelIssue(mainbl.getBlock(), mesg);
+									}
+									
+									// Add 'show reference description' resolution
+									ShowReferencedDescription showrefd=new ShowReferencedDescription();
+									
+									if (refiter.getComposedSource() != null) {
+										showrefd.setModel(refiter.getComposedSource());
+									} else {
+										showrefd.setModel(context.getReferenceSource());
+									}
+									showrefd.setSourceReference(refPoint.getSource());
+									
+									issue.getResolutions().add(showrefd);
+									
+									// Add 'insert model object' resolution
+									InsertFromReferencedDescription imo=new InsertFromReferencedDescription();
+									
+									if (refiter.getComposedSource() != null) {
+										imo.setModel(refiter.getComposedSource());
+									} else {
+										imo.setModel(context.getReferenceSource());
+									}
+									imo.setSourceReference(refPoint.getSource());
+									
+									issue.getResolutions().add(imo);
+									
+									l.error(issue);
+									
+									ret = false;
+									
+									// Exit loop
+									refCount = 0;
+								} else {
+									refCount--;
+								}
+							}
+
+							// Get ref activity to be compared
+							refPoint = innerRefIter.next();
+
+							/*
+							 * Perform comparison after dealing with
+							 * additional or missing activities,
+							 * when reached sync point, in case
+							 * not fully compaible (i.e. full compare
+							 * was set to false to find this inner
+							 * sync point)
+							 */
+							if (mainPoint != null && refPoint != null) {
+								DefaultModelListener subl=new 
+								DefaultModelListener(innerMainIter.getComposedSource());
+						
+								// Redo comparison with model listener
+								if (compareBehaviours(context, mainPoint, refPoint,
+										mainiter, refiter, subl, true) == false) {
+									ret = false;
+								}
+												
+								subl.apply(l, innerMainIter.getModelInclude(), null, null);		
+							}
+						} else {
+							Behaviour mainPoint=innerMainIter.next();
+							Behaviour refPoint=innerRefIter.next();
+
+							DefaultModelListener subl=new 
+									DefaultModelListener(innerMainIter.getComposedSource());
+							
+							// Redo comparison with model listener
+							ret = compareBehaviours(context, mainPoint, refPoint,
+									mainiter, refiter, subl, true);
+											
+							subl.apply(l, innerMainIter.getModelInclude(), null, null);
+						}
+	
+						// Move iterators to the sync point
+						innerMainIter = innerSyncPoint.getMainIterator();
+						innerRefIter = innerSyncPoint.getReferenceIterator();
+					}
+	
+					//ret = false;
+				}
+				
+				// Move iterators to the sync point
+				mainiter = syncPoint.getMainIterator();
+				refiter = syncPoint.getReferenceIterator();
+			}
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method finds the point in both descriptions where
+	 * the behaviour is the same (i.e. they are synchronized).
+	 * 
+	 * @param context The context
+	 * @param mainiter The main behaviour iterator
+	 * @param refiter The reference behaviour iterator
+	 * @param fullCompare Whether to do a full or basic comparison
+	 * @param end An optional sync point where this search should
+	 * 					finish
+	 * @return The sync point
+	 */
+	protected SyncPoint findNextSyncPoint(ComparatorContext context,
+					BehaviourListIterator mainiter,
+					BehaviourListIterator refiter,
+					boolean fullCompare, SyncPoint end) {
+		SyncPoint ret=null;
+		SyncPoint mainSyncPoint=null;
+		SyncPoint refSyncPoint=null;
+		int mainCount=0;
+		int refCount=0;
+		int maxMainCount=0;
+		int maxRefCount=0;
+		
+		if (mainiter != null && refiter != null) {
+			BehaviourListIterator mainiter2=mainiter.snapshot();
+			boolean f_end=false;
+			
+			while (f_end == false && mainSyncPoint == null && 
+								mainiter2.hasNext()) {
+				Behaviour main=mainiter2.next();
+				
+				if (end != null && end.getMain() == main) {
+					f_end = true;
+				} else {
+					BehaviourListIterator refiter2=refiter.snapshot();
+					
+					refCount = 0;
+					
+					boolean f_innerEnd=false;
+					
+					while (f_innerEnd == false && mainSyncPoint == null &&
+									refiter2.hasNext()) {
+						Behaviour ref=refiter2.next();
+						
+						if (end != null && end.getReference() == ref) {
+							f_innerEnd = true;
+						} else {
+							DefaultModelListener l=new DefaultModelListener(refiter2.getComposedSource());
+							
+							if (compareBehaviours(context, main, ref,
+									mainiter, refiter, l, fullCompare)) {
+								
+								mainSyncPoint = new SyncPoint(main, ref,
+										mainiter2, refiter2, mainCount, refCount);
+							} else {
+								refCount++;
+							}
+						}
+					}
+					
+					if (mainSyncPoint == null) {
+						mainCount++;
+						maxMainCount++;
+					}
+				}
+			}
+			
+			BehaviourListIterator refiter2=refiter.snapshot();
+			refCount = 0;
+			f_end = false;
+			
+			while (f_end == false && refSyncPoint == null &&
+							refiter2.hasNext()) {
+				Behaviour ref=refiter2.next();
+				if (end != null && end.getReference() == ref) {
+					f_end = true;
+				} else {
+					mainiter2 = mainiter.snapshot();
+					
+					mainCount = 0;
+					
+					boolean f_innerEnd=false;
+					
+					while (f_innerEnd == false &&
+							refSyncPoint == null && mainiter2.hasNext()) {
+						Behaviour main=mainiter2.next();
+						
+						if (end != null && end.getMain() == main) {
+							f_innerEnd = true;
+						} else {
+							DefaultModelListener l=new DefaultModelListener();
+							
+							if (compareBehaviours(context, main, ref,
+									mainiter, refiter, l, fullCompare)) {
+								
+								refSyncPoint = new SyncPoint(main, ref,
+										mainiter2, refiter2, mainCount, refCount);
+							} else {
+								mainCount++;
+							}
+						}
+					}
+					
+					if (refSyncPoint == null) {
+						refCount++;
+						maxRefCount++;					
+					}
+				}
+			}
+			
+			if (mainSyncPoint != null && refSyncPoint != null) {
+				if (mainSyncPoint.getTotal() <=
+								refSyncPoint.getTotal()) {
+					ret = mainSyncPoint;
+				} else {
+					ret = refSyncPoint;
+				}
+			} else if (mainSyncPoint != null) {
+				ret = mainSyncPoint;
+			} else {
+				ret = refSyncPoint;
+			}
+			
+			// If no sync point found, but components were remaining
+			// in main and/or ref list, then return a sync point with
+			// the number of components skipped
+			if (ret == null && (maxMainCount+maxRefCount) > 0) {
+				ret = new SyncPoint(null, null, null, null, maxMainCount, maxRefCount);
+			}
+		}
+		
+		return(ret);
+	}
+	
+	protected boolean compareBehaviours(ComparatorContext context,
+			Behaviour mainb, Behaviour refb,
+			BehaviourListIterator mainiter, BehaviourListIterator refiter,
+			ModelListener l, boolean fullCompare) {
+		boolean ret=false;
+		
+		if (mainb != null && refb != null) {
+			// TODO:
+			// how do we deal with grouping constructs - 
+			// they are behaviours, but if different, then
+			// no comparator rule will be found, which will
+			// currently default to true - should it return
+			// false???
+			
+			if (fullCompare) {
+			
+				// Check if multi-path elements
+				if (mainb instanceof BehaviourListPaths &&
+						refb instanceof BehaviourListPaths) {
+					
+					ret = compareMultiplePaths(context,
+							(BehaviourListPaths)mainb,
+							(BehaviourListPaths)refb,
+							mainiter, refiter, l, true);
+					
+				} else {
+					ret = compareSingleComponents(context,
+							mainb, refb, mainiter, refiter, l, true);
+				}
+				
+			} else if (mainb instanceof BehaviourListPaths &&
+					refb instanceof BehaviourListPaths) {
+				ret = context.isComparisonSupported(
+						((BehaviourListPaths)mainb).getSourceBehaviour(),
+						((BehaviourListPaths)refb).getSourceBehaviour());
+			} else {
+				
+				// Just check that a rule exists for the types
+				ret = context.isComparisonSupported(mainb, refb);
+			}
+		}
+
+		return(ret);
+	}
+	
+	protected boolean compareSingleComponents(ComparatorContext context,
+			Behaviour mainb, Behaviour refb,
+			BehaviourListIterator mainiter, BehaviourListIterator refiter,
+			ModelListener l, boolean deep) {
+		boolean ret=false;
+		
+		DefaultModelListener dml=new DefaultModelListener(
+					mainiter.getComposedSource());
+
+		// Add name map to comparator context
+		context.pushMainNameMap(mainiter.getNameMap());
+		context.pushReferenceNameMap(refiter.getNameMap());
+		
+		// Do shallow compare, to just check 
+		ret = context.compare(mainb, refb, dml, true);
+		
+		context.popReferenceNameMap();
+		context.popMainNameMap();
+		
+		ModelObject override=null;
+		
+		if (mainiter.getComposedSource() != null) {
+			override = mainiter.getModelInclude();
+		}
+		
+		// Associate reference description information
+		java.util.Map<String,Object> props=new java.util.HashMap<String,Object>();
+		
+		// TODO: GPB: NEED TO ADD 'ShowReferencedRescription'
+		// resolution ?????
+
+		/*
+		if (refiter.getExternalSource() != null) {
+			props.put(ModelListener.REFERENCE_MODEL,
+						refiter.getExternalSource());
+		} else {
+			props.put(ModelListener.REFERENCE_MODEL,
+						context.getReferenceSource());
+		}
+		
+		props.put(ModelListener.REFERENCE_MODEL_START_POSITION,
+						refb.getSource().getStartPosition());
+		props.put(ModelListener.REFERENCE_MODEL_END_POSITION,
+					refb.getSource().getEndPosition());
+		if (refb.getSource().getComponentURI() != null) {
+			props.put(ModelListener.REFERENCE_MODEL_COMPONENT,
+							refb.getSource().getComponentURI());
+		}
+		props.put(ModelListener.RESOLUTIONS,
+				ModelListener.SHOW_REFERENCE_DESCRIPTION_RESOLUTION);
+		*/
+		
+		java.util.List<Resolution> resolutions=new java.util.Vector<Resolution>();
+		
+		ShowReferencedDescription res=new ShowReferencedDescription();
+		res.setSourceReference(refb.getSource());
+
+		if (refiter.getComposedSource() != null) {
+			res.setModel(refiter.getComposedSource());
+		} else {
+			res.setModel(context.getReferenceSource());
+		}
+		
+		resolutions.add(res);
+
+		dml.apply(l, override, props, resolutions);
+
+		return(ret);
+	}
+	
+	protected boolean compareMultiplePaths(ComparatorContext context,
+			BehaviourListPaths mainblp, BehaviourListPaths refblp,
+			BehaviourListIterator mainiter, BehaviourListIterator refiter,
+					ModelListener l, boolean deep) {
+		boolean ret=false;
+		
+		DefaultModelListener dml=new DefaultModelListener(
+				mainiter.getComposedSource());
+		
+		ret = context.compare(mainblp.getSourceBehaviour(),
+				refblp.getSourceBehaviour(), dml, false);
+		
+		if (ret) {
+			dml = null;
+			
+			// Work through paths to find matching pairs and
+			// remove them from the lists
+			BehaviourList mainlist=null;
+			
+			while ((mainlist=mainblp.getNext()) != null) {
+				
+				refblp.reset();
+				
+				BehaviourList reflist=null;
+				boolean pathvalid=false;
+				
+				do {
+					reflist = refblp.getNext();
+					
+					if (reflist != null) {
+						
+						// TODO: Need to record model
+						// listener messages in temporary
+						// place and transfer
+						DefaultModelListener tmpl=
+							new DefaultModelListener(mainiter.getComposedSource());
+						
+						pathvalid = context.compare(mainlist,
+								reflist, tmpl, true);
+						
+						if (pathvalid) {
+							// Remove found list
+							refblp.handled(reflist);
+						}
+					}
+				} while (reflist != null && pathvalid == false);
+				
+				if (pathvalid) {
+					mainblp.handled(mainlist);
+				}
+			}
+			
+			// Reset main, to find errors in matching
+			mainblp.reset();
+			
+			// This time, the checks will focus on finding
+			// errors in the remaining unmatched paths
+			while (ret && (mainlist=mainblp.getNext()) != null) {
+				
+				refblp.reset();
+				
+				BehaviourList reflist=null;
+				
+				do {
+					reflist = refblp.getNext();
+					
+					if (reflist != null) {
+						
+						// TODO: Need to record model
+						// listener messages in temporary
+						// place and transfer
+						dml = new DefaultModelListener(mainiter.getComposedSource());
+								//mainlist.getModelInclude().getReference());
+						
+						ret = context.compare(mainlist,
+								reflist, dml, true);
+						
+						if (ret == true) {
+							dml = null;
+						}
+					}
+				} while (ret && reflist != null);
+			}
+
+			if (ret) {
+				refblp.reset();
+				mainblp.reset();
+				
+				// If reference behaviour list paths still exist, and the
+				// main behaviour list paths are not the decision maker,
+				// then check the paths for error.
+				// NOTE: Checking for main blp being decision maker, for
+				// situations where checking composability - so not related
+				// to whether ref blp is decision maker (as this will be
+				// determined when checking each path), but if main is
+				// decision maker, then additional paths are not relevant.
+				if (refblp.hasNext() &&
+						isMutuallyExclusiveDecisionMaker(mainblp) == false) {// &&
+						//isMutuallyExclusiveDecisionMaker(refblp) == false) {
+					BehaviourList refb=null;
+					
+					while ((refb=refblp.getNext()) != null) { //&&
+							//isMutuallyExclusiveDecisionMaker(refblp) == false) {
+						
+						if (isDecisionMaker(refb) == false &&
+								refb.getBehaviourList().size() > 0) {
+						
+							// TODO: Need to check if additional ref
+							// path belongs to a conditional multipath
+							// construct that is located at the projected
+							// role
+							
+							String mesg=java.util.PropertyResourceBundle.getBundle(
+									"org.scribble.conformance.comparator.Messages").
+									getString("_ADDITIONAL_UNMATCHED_REF_PATHS");
+							
+							ModelIssue issue=new ModelIssue(mainblp, mesg);
+							
+							ShowReferencedDescription res=new ShowReferencedDescription();
+							
+							if (refiter.getComposedSource() != null) {
+								res.setModel(refiter.getComposedSource());
+							} else {
+								res.setModel(context.getReferenceSource());
+							}
+							res.setSourceReference(refb.getSource());
+							
+							issue.getResolutions().add(res);
+	
+							l.error(issue);
+							
+							ret = false;
+						}
+					}
+					
+					//ret = false;
+					
+				}// else if (mainblp.hasNext() &&
+				//		isMutuallyExclusiveDecisionMaker(mainblp) == false) {
+				
+				if (mainblp.hasNext()&&
+						isMutuallyExclusiveDecisionMaker(refblp) == false) {
+					BehaviourList src=null;
+					
+					while ((src=mainblp.getNext()) != null) {
+		
+						if (isDecisionMaker(src) == false &&
+								src.getBehaviourList().size() > 0) {
+
+							String mesg=java.util.PropertyResourceBundle.getBundle(
+									"org.scribble.conformance.comparator.Messages").
+									getString("_ADDITIONAL_UNMATCHED_PATHS");
+					
+							ModelIssue issue=new ModelIssue(src, mesg);
+							
+							ShowReferencedDescription res=new ShowReferencedDescription();
+							
+							if (refiter.getComposedSource() != null) {
+								res.setModel(refiter.getComposedSource());
+							} else {
+								res.setModel(context.getReferenceSource());
+							}
+							
+							issue.getResolutions().add(res);
+							
+							l.error(issue);
+							
+							ret = false;
+						}
+					}
+					
+					//ret = false;
+				}
+			}
+		}
+		
+		// Copy errors into the main listener
+		if (dml != null) {
+			ModelObject override=null;
+			
+			if (mainiter.getComposedSource() != null) {
+				override = mainiter.getModelInclude();
+			}
+			
+			// Associate reference description information
+			java.util.Map<String,Object> props=
+				new java.util.HashMap<String,Object>();
+
+			// TODO: GPB: NEED TO ADD 'ShowReferencedRescription'
+			// resolution ?????
+			
+			/*
+			
+			if (refiter.getExternalSource() != null) {
+				props.put(ModelListener.REFERENCE_MODEL,
+							refiter.getExternalSource());
+			} else {
+				props.put(ModelListener.REFERENCE_MODEL,
+							context.getReferenceSource());
+			}
+			
+			props.put(ModelListener.REFERENCE_MODEL_START_POSITION,
+						refblp.getSource().getStartPosition());
+			props.put(ModelListener.REFERENCE_MODEL_END_POSITION,
+						refblp.getSource().getEndPosition());
+			if (refblp.getSource().getComponentURI() != null) {
+				props.put(ModelListener.REFERENCE_MODEL_COMPONENT,
+								refblp.getSource().getComponentURI());
+			}
+			props.put(ModelListener.RESOLUTIONS,
+					ModelListener.SHOW_REFERENCE_DESCRIPTION_RESOLUTION);
+			
+			*/
+			
+			java.util.List<Resolution> resolutions=new java.util.Vector<Resolution>();
+			
+			ShowReferencedDescription res=new ShowReferencedDescription();
+			res.setSourceReference(refblp.getSource());
+
+			if (refiter.getComposedSource() != null) {
+				res.setModel(refiter.getComposedSource());
+			} else {
+				res.setModel(context.getReferenceSource());
+			}
+			
+			resolutions.add(res);
+			
+			dml.apply(l, override, props, resolutions);
+			
+		/*
+		} else if (ret == false) {
+			// TODO: Need to report fact that
+			// no more reference lists are
+			// available
+			String mesg=java.util.PropertyResourceBundle.getBundle(
+					"org.scribble.conformance.comparator.Messages").
+					getString("_NO_MATCHING_PATH");
+			
+			
+			l.error(mainblp, mesg, null);
+		*/
+		}
+		
+		return(ret);
+	}
+	
+	protected Behaviour getNextBehaviour(ComparatorContext context,
+						BehaviourListIterator iter) {
+		Behaviour ret=null;
+		
+		while (ret == null && iter.hasNext()) {
+			Behaviour behaviour=iter.next();
+			if ((behaviour instanceof BehaviourListPaths &&
+					context.isTypeSupported(((BehaviourListPaths)
+							behaviour).getSourceBehaviour())) ||
+					context.isTypeSupported(behaviour)) {
+				ret = behaviour;
+			}
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method helps to locate the relevant top level behaviour
+	 * list, where comparison should start from.
+	 * 
+	 * @param bl The proposed behaviour list
+	 * @return The actual top level behaviour list of interest
+	 */
+	protected BehaviourList getTopLevelBehaviourList(BehaviourList bl) {
+		BehaviourList ret=bl;
+		
+		if (ret.getBehaviourList().size() == 1) {
+			
+			if (ret.getBehaviourList().get(0) instanceof BehaviourList) {
+				ret = getTopLevelBehaviourList((BehaviourList)
+								ret.getBehaviourList().get(0));
+			} else if (ret.getBehaviourList().get(0) instanceof
+							BehaviourListPaths) {
+				BehaviourListPaths blps=(BehaviourListPaths)
+							ret.getBehaviourList().get(0);
+				
+				if (blps.getPaths().size() == 1) {
+					ret = getTopLevelBehaviourList(blps.getPaths().get(0));
+				}
+			}
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method determines whether the supplied behaviour
+	 * is a conditional grouping construct that is the
+	 * decision maker - i.e. its located role is the same as
+	 * the projected role associated with the local model
+	 * definition.
+	 * 
+	 * @param b The behaviour
+	 * @return Whether the behaviour is a conditional decision
+	 * 						maker
+	 */
+	protected boolean isConditionalDecisionMaker(Behaviour b) {
+		boolean ret=false;
+		
+		// TODO: Check if conditional and a grouping construct
+		// rather than single or multi path. Then make 'if'
+		// conditional if it does not have a default 'else'
+		// clause
+		
+		//if (b instanceof SinglePathBehaviour &&
+		if (b.isGroupingConstruct() &&
+				b.isConditional()) {
+			Definition d=b.getEnclosingDefinition();
+			
+			if (d != null && d.getLocatedName() != null &&
+					d.getLocatedName().getRole() != null &&
+					b.getInitiatorRoles().contains(
+							d.getLocatedName().getRole())) {
+				ret = true;
+			}
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method determines whether the supplied behaviour
+	 * is a conditional grouping construct that is the
+	 * decision maker - i.e. its located role is the same as
+	 * the projected role associated with the local model
+	 * definition.
+	 * 
+	 * @param b The behaviour
+	 * @return Whether the behaviour is a conditional decision
+	 * 						maker
+	 */
+	protected boolean isMutuallyExclusiveDecisionMaker(BehaviourListPaths blp) {
+		boolean ret=false;
+		
+		if (blp.getSourceBehaviour() instanceof MultiPathBehaviour &&
+				((MultiPathBehaviour)blp.getSourceBehaviour()).
+							isMutuallyExclusivePaths()) {
+			Definition d=blp.getSourceBehaviour().getEnclosingDefinition();
+			
+			if (d != null && d.getLocatedName() != null &&
+					d.getLocatedName().getRole() != null &&
+					blp.getSourceBehaviour().getInitiatorRoles().contains(
+							d.getLocatedName().getRole())) {
+				ret = true;
+			}
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method determines whether the supplied behaviour
+	 * is a block that is the decision maker - i.e. it is
+	 * located role is the same as the projected role associated 
+	 * with the local model definition.
+	 * 
+	 * @param b The behaviour list
+	 * @return Whether the behaviour is a block initiated at the
+	 * 					located role.
+	 */
+	protected boolean isDecisionMaker(BehaviourList b) {
+		boolean ret=false;
+		
+		Definition d=b.getBlock().getEnclosingDefinition();
+			
+		if (d != null && d.getLocatedName() != null &&
+				d.getLocatedName().getRole() != null &&
+				b.getBlock().getInitiatorRoles().contains(
+							d.getLocatedName().getRole())) {
+			ret = true;
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/comparator/Messages.properties
===================================================================
--- trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/comparator/Messages.properties	                        (rev 0)
+++ trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/comparator/Messages.properties	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,24 @@
+# /*
+# * Copyright 2007 Pi4 Technologies Ltd
+# *
+# * 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.
+# *
+# *
+# * Change History:
+# * 24 Nov 2007 : Initial version created by gary
+# */
+
+_ADDITIONAL_UNMATCHED_PATHS=Additional unmatched paths in model
+_ADDITIONAL_UNMATCHED_REF_PATHS=Additional unmatched paths in reference description
+_EXPECTING_ACTIVITY=Expecting additional activities as defined in referenced description
+_NO_MATCHING_PATH=No matching path

Added: trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/comparator/StatelessDefinitionComparatorRule.java
===================================================================
--- trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/comparator/StatelessDefinitionComparatorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/comparator/StatelessDefinitionComparatorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,217 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 22 Nov 2008 : Initial version created by gary
+ */
+package org.scribble.conformance.comparator;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.DefaultModelListener;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.model.resolutions.*;
+import org.scribble.comparator.*;
+import org.scribble.conformance.model.*;
+import org.scribble.conformance.model.transform.StatelessTransformer;
+import org.scribble.extensions.RegistryFactory;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This class provides the comparator rule for creating a
+ * stateless reference model for comparison against a
+ * stateless main model.
+ */
+ at RegistryInfo(extension=ComparatorRule.class)
+public class StatelessDefinitionComparatorRule implements ComparatorRule {
+
+	/**
+	 * This method determines whether the comparison rule is
+	 * associated with the supplied type.
+	 * 
+	 * @param obj The object to check
+	 * @return Whether the object is of a type supported by the
+	 * 					comparison rule
+	 */
+	public boolean isTypeSupported(ModelObject obj) {
+		// Don't want this to indicate that the definition
+		// has a comparator rule - only want to use this
+		// rule to trigger a stateless conversion if necessary
+		return(false);
+	}
+	
+	/**
+	 * This method determines whether the comparison rule is
+	 * appropriate for the supplied model objects.
+	 * 
+	 * @param main The main model object to be compared
+	 * @param ref The reference model object to be compared against
+	 * @return Whether the rule is relevant for the
+	 * 				model objects
+	 */
+	public boolean isComparisonSupported(ModelObject main, ModelObject ref) {
+		return(main instanceof Definition &&
+				ref instanceof Definition &&
+				((Definition)main).isStateless() !=
+					((Definition)ref).isStateless() &&
+				((Definition)main).getLocatedName().getRole() != null &&
+				((Definition)ref).getLocatedName().getRole() != null);
+	}
+	
+	/**
+	 * This method compares a model object against a reference
+	 * component to determine if they are equal.
+	 * 
+	 * @param context The context
+	 * @param main The main model object
+	 * @param reference The reference model object
+	 * @param l The model listener
+	 * @param deep Perform a deep compare
+	 * @return Whether the model objects are comparable
+	 */
+	public boolean compare(ComparatorContext context, ModelObject main,
+					ModelObject reference, ModelListener l, boolean deep) {
+		boolean ret=false;
+		
+		// Generate a stateless (or rather stateful fragments) version of the
+		// reference definition, and then compare this against the main model
+		if (((Definition)reference).isStateless() == false) {
+			StatelessTransformer transformer=
+				(StatelessTransformer)
+					RegistryFactory.getRegistry().getExtension(
+						StatelessTransformer.class,
+						context.getReferenceSource().getNotation());
+
+			if (transformer != null) {				
+				org.scribble.export.Exporter exporter=
+					(org.scribble.export.Exporter)
+					RegistryFactory.getRegistry().getExtension(
+							org.scribble.export.Exporter.class, null);
+
+				try {
+					org.scribble.export.text.TextFormatter formatter=
+						new org.scribble.export.text.TextFormatter();
+					
+					java.io.ByteArrayOutputStream os=
+						new java.io.ByteArrayOutputStream();
+					
+					formatter.setOutputStream(os);
+					
+					exporter.export(context.getReferenceSource(),
+								reference, formatter);
+					
+					String str=new String(os.toByteArray());
+					
+					System.out.println("EXPORTED REFERENCE STATEFUL:");
+					System.out.println(str);
+					
+				} catch(Exception e) {
+					e.printStackTrace();
+				}
+				
+				reference = transformer.transform((Definition)reference,
+							context.getReferenceSource());
+
+				try {
+					org.scribble.export.text.TextFormatter formatter=
+						new org.scribble.export.text.TextFormatter();
+					
+					java.io.ByteArrayOutputStream os=
+						new java.io.ByteArrayOutputStream();
+					
+					formatter.setOutputStream(os);
+					
+					exporter.export(context.getReferenceSource(),
+							reference, formatter);
+					
+					String str=new String(os.toByteArray());
+					
+					System.out.println("EXPORTED REFERENCE STATELESS:");
+					System.out.println(str);
+					
+				} catch(Exception e) {
+					e.printStackTrace();
+				}
+			}
+		} else if (((Definition)main).isStateless() == false) {
+			StatelessTransformer transformer=
+				(StatelessTransformer)
+					RegistryFactory.getRegistry().getExtension(
+						StatelessTransformer.class,
+						context.getMainSource().getNotation());
+
+			if (transformer != null) {				
+				org.scribble.export.Exporter exporter=
+					(org.scribble.export.Exporter)
+					RegistryFactory.getRegistry().getExtension(
+							org.scribble.export.Exporter.class, null);
+				
+				try {
+					org.scribble.export.text.TextFormatter formatter=
+						new org.scribble.export.text.TextFormatter();
+					
+					java.io.ByteArrayOutputStream os=
+						new java.io.ByteArrayOutputStream();
+					
+					formatter.setOutputStream(os);
+					
+					exporter.export(context.getMainSource(),
+							main, formatter);
+					
+					String str=new String(os.toByteArray());
+					
+					System.out.println("EXPORTED MAIN STATEFUL:");
+					System.out.println(str);
+					
+				} catch(Exception e) {
+					e.printStackTrace();
+				}
+
+				main = transformer.transform((Definition)main,
+						context.getMainSource());
+
+				try {
+					org.scribble.export.text.TextFormatter formatter=
+						new org.scribble.export.text.TextFormatter();
+					
+					java.io.ByteArrayOutputStream os=
+						new java.io.ByteArrayOutputStream();
+					
+					formatter.setOutputStream(os);
+					
+					exporter.export(context.getMainSource(),
+							main, formatter);
+					
+					String str=new String(os.toByteArray());
+					
+					System.out.println("EXPORTED MAIN STATELESS:");
+					System.out.println(str);
+					
+				} catch(Exception e) {
+					e.printStackTrace();
+				}
+			}
+		}
+				
+		if (reference != null && main != null &&
+				((Definition)main).isStateless() &&
+				((Definition)reference).isStateless()) {
+			ret = context.compare(main, reference, l, deep);
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/comparator/SyncPoint.java
===================================================================
--- trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/comparator/SyncPoint.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/comparator/SyncPoint.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 18 Jul 2008 : Initial version created by gary
+ */
+package org.scribble.conformance.comparator;
+
+import org.scribble.model.*;
+import org.scribble.conformance.model.*;
+
+public class SyncPoint {
+
+	public SyncPoint(Behaviour main, Behaviour ref,
+			BehaviourListIterator mainiter,
+			BehaviourListIterator refiter,
+			int mainCount, int refCount) {
+		m_main = main;
+		m_reference = ref;
+		m_mainIterator = mainiter;
+		m_referenceIterator = refiter;
+		m_mainCount = mainCount;
+		m_referenceCount = refCount;
+	}
+	
+	public Behaviour getMain() {
+		return(m_main);
+	}
+	
+	public Behaviour getReference() {
+		return(m_reference);
+	}
+	
+	public BehaviourListIterator getMainIterator() {
+		return(m_mainIterator);
+	}
+	
+	public BehaviourListIterator getReferenceIterator() {
+		return(m_referenceIterator);
+	}
+	
+	public int getMainCount() {
+		return(m_mainCount);
+	}
+	
+	public int getReferenceCount() {
+		return(m_referenceCount);
+	}
+	
+	public int getTotal() {
+		return(m_mainCount+m_referenceCount);
+	}
+	
+	public boolean isGap() {
+		return(getTotal() > 0);
+	}
+	
+	private Behaviour m_main=null;
+	private Behaviour m_reference=null;
+	private BehaviourListIterator m_mainIterator=null;
+	private BehaviourListIterator m_referenceIterator=null;
+	private int m_mainCount=0;
+	private int m_referenceCount=0;
+}

Added: trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/BehaviourList.java
===================================================================
--- trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/BehaviourList.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/BehaviourList.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,356 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 27 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.conformance.model;
+
+import org.scribble.model.*;
+
+/**
+ * This class provides a list mechanism for serialising the
+ * behaviours associated with a definition. This makes it
+ * easier to compare the behaviours between definitions.
+ */
+public class BehaviourList extends Behaviour
+						implements org.scribble.model.Visitor,
+								org.scribble.comparator.NameMap {
+
+	/**
+	 * This method returns the top level behaviour list associated
+	 * with the supplied block.
+	 * 
+	 * @param defn The block
+	 * @return The top level behaviour list
+	 */
+	public static BehaviourList createBehaviourList(Block defn) {
+		BehaviourList ret=new BehaviourList(defn);
+		
+		ret = getTopLevelBehaviourList(ret);
+		
+		return(ret);
+	}
+	
+	/**
+	 * This constructor initializes the behaviour list with the
+	 * supplied block.
+	 * 
+	 * @param defn The block
+	 */
+	protected BehaviourList(Block defn) {
+		m_block = defn;
+		
+		initialize();
+	}
+
+	/**
+	 * This constructor initializes the behaviour list with the
+	 * supplied block and model inclusion.
+	 * 
+	 * @param defn The block
+	 * @param include The model inclusion construct
+	 */
+	protected BehaviourList(Block defn, org.scribble.model.ModelInclude include) {
+		m_block = defn;
+		m_include = include;
+		
+		initialize();
+	}
+	
+	protected BehaviourList() {
+		// Create a dummy block associated with the
+		// behaviour list - required for test purposes,
+		// to report as target of errors if comparison
+		// detects a missing activity at the end of the
+		// block.
+		m_block = new Block();
+	}
+	
+	protected void initialize() {
+		derivedFrom(m_block);
+		m_block.visit(this);
+	}
+	
+	/**
+	 * This method sets the name map associated with the behaviour
+	 * list.
+	 * 
+	 * @param map The name map
+	 */
+	public void setNameMap(java.util.Map<String,String> map) {
+		m_nameMap = map;
+	}
+	
+	/**
+	 * This method returns the name that has been mapped
+	 * to the supplied name. If the supplied name has
+	 * no mapping, then the same name will be returned.
+	 * 
+	 * @param name The current name
+	 * @return The original name
+	 */
+	public String getName(String name) {
+		return(m_nameMap == null || m_nameMap.containsKey(name) == false
+					? name : m_nameMap.get(name));
+	}
+	
+	public boolean visit(ModelObject obj) {
+		boolean ret=false;
+		
+		if (obj instanceof org.scribble.model.MultiPathBehaviour) {
+			org.scribble.model.MultiPathBehaviour paths=
+					(org.scribble.model.MultiPathBehaviour)obj;
+			java.util.List<BehaviourList> bllist=
+					new java.util.Vector<BehaviourList>();
+			
+			for (int i=0; i < paths.getPaths().size(); i++) {
+				org.scribble.model.Block block=paths.getPaths().get(i);
+				
+				BehaviourList bl=new BehaviourList(block);
+				
+				//bl.derivedFrom(block);
+				
+				bl.setNameMap(m_nameMap);
+				
+				//block.visit(bl);
+				
+				bllist.add(bl);
+			}
+			
+			BehaviourListPaths blpaths=new BehaviourListPaths((Behaviour)obj,
+									bllist);
+			
+			if (blpaths.isVisible()) {
+				addToList(blpaths);
+			}
+
+		} else if (obj instanceof org.scribble.model.SinglePathBehaviour) {
+			org.scribble.model.SinglePathBehaviour path=
+					(org.scribble.model.SinglePathBehaviour)obj;
+			java.util.List<BehaviourList> bllist=
+					new java.util.Vector<BehaviourList>();
+			
+			BehaviourList bl=new BehaviourList(path.getBlock());
+				
+			//bl.derivedFrom(path.getBlock());
+				
+			bl.setNameMap(m_nameMap);
+				
+			//path.getBlock().visit(bl);
+				
+			bllist.add(bl);
+			
+			BehaviourListPaths blpaths=new BehaviourListPaths((Behaviour)obj,
+									bllist);
+			
+			if (blpaths.isVisible()) {
+				addToList(blpaths);
+			}
+
+		} else if (obj instanceof org.scribble.model.ModelInclude) {
+			org.scribble.model.ModelInclude include=
+					(org.scribble.model.ModelInclude)obj;
+			org.scribble.model.Definition defn=
+					((org.scribble.model.ModelInclude)obj).getDefinition();
+			
+			if (defn != null) {
+				BehaviourList list=null;
+				
+				// Check if external model - if so, then
+				// need to supply reference to list, so can be
+				// used in error reporting
+				if (include.getReference() != null &&
+							include.getReference().isInner() == false) {
+					list = new BehaviourList(defn.getBlock(), include);
+				} else {
+					list = new BehaviourList(defn.getBlock());
+				}
+				
+				list.setNameMap(getNameMap(include.getBindings()));
+				
+//				list.derivedFrom(include);
+				
+//				defn.visit(list);
+			
+				// Add list, if async (to identify existence of
+				// async composed conversation), or if the list
+				// has elements
+				if (include.isAsynchronous()) {
+					
+					// If async, then need to add 'behaviour
+					// list path' to isolate the behaviour
+					// list, to ensure it does not get merged
+					// into the outer list (as with the
+					// sync run)
+					java.util.List<BehaviourList> bllist=
+						new java.util.Vector<BehaviourList>();
+				
+					bllist.add(list);
+				
+					BehaviourListPaths blpaths=new BehaviourListPaths((Behaviour)obj,
+										bllist);
+				
+					addToList(blpaths);
+					
+				} else if (list.getBehaviourList().size() > 0) {
+					addToList(list);					
+				}
+			}
+			
+		} else if (obj instanceof org.scribble.model.Block) {
+			
+			// Iterate through each activity checking its a behaviour
+			ret = true;
+			
+		} else if (obj instanceof org.scribble.model.Behaviour) {
+			addToList((Behaviour)obj);
+		
+			// Only recursively check for behaviours
+			// inside other behaviours. This will ensure
+			// inner protocols will not be indirectly
+			// processed - only if invoked as part of
+			// a run statement.
+			ret = true;
+			
+		} else if (obj == m_block) {
+			// Visiting the main definition, so visit contents
+			ret = true;
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method adds the supplied behaviour to the list.
+	 * 
+	 * @param behaviour The behaviour
+	 */
+	protected void addToList(Behaviour behaviour) {
+		boolean f_added=false;
+		
+		if (m_list.size() > 0) {
+			// Check behaviour at the end of the list, to determine
+			// whether the behaviour to be added to be added to
+			// a contained single or multi path behaviour
+			Behaviour prev=m_list.get(m_list.size()-1);
+			
+			if (prev instanceof BehaviourListPaths &&
+					((BehaviourListPaths)prev).isStrictScope() == false) {
+				BehaviourListPaths blpaths=(BehaviourListPaths)prev;
+				
+				// Place the entry to be added in each of the paths
+				for (int i=0; i < blpaths.getPaths().size(); i++) {
+					
+					// Recursively perform the add-to-list, so if
+					// another non-strict scope construct gets added
+					// then subsequent activities will be contained
+					// within it, rather than the outer one
+					blpaths.getPaths().get(i).addToList(behaviour);
+					
+					f_added = true;
+				}
+			}
+		}
+		
+		if (f_added == false) {
+			m_list.add(behaviour);
+		}
+	}
+	
+	/**
+	 * This method returns the name map associated with the supplied
+	 * binding information. The returned name map links the bound name
+	 * back to the original declaration name.
+	 * 
+	 * @param bindings The bindings
+	 * @return The name map
+	 */
+	protected java.util.Map<String,String> getNameMap(java.util.List<DeclarationBinding> bindings) {
+		java.util.Map<String,String> ret=new java.util.Hashtable<String,String>();
+		
+		java.util.Iterator<DeclarationBinding> iter=bindings.iterator();
+		while (iter.hasNext()) {
+			DeclarationBinding db=iter.next();
+			
+			ret.put(db.getBoundName(), db.getDeclaration().getName());
+		}
+		
+		return(ret);
+	}
+	
+	public BehaviourListIterator getIterator() {
+		return(new BehaviourListIterator(this));
+	}
+
+	public java.util.List<Behaviour> getBehaviourList() {
+		return(m_list);
+	}
+	
+	/**
+	 * This method returns the optional model include
+	 * associated with the contained behaviour activities.
+	 * 
+	 * @return The optional model include
+	 */
+	public org.scribble.model.ModelInclude getModelInclude() {
+		return(m_include);
+	}
+	
+	/**
+	 * This method returns the model object associated with the
+	 * list.
+	 * 
+	 * @return The model object
+	 */
+	public Block getBlock() {
+		return(m_block);
+	}
+	
+	/**
+	 * This method helps to locate the relevant top level behaviour
+	 * list, where comparison should start from.
+	 * 
+	 * @param bl The proposed behaviour list
+	 * @return The actual top level behaviour list of interest
+	 */
+	protected static BehaviourList getTopLevelBehaviourList(BehaviourList bl) {
+		BehaviourList ret=bl;
+		
+		if (ret.getBehaviourList().size() == 1) {
+			
+			if (ret.getBehaviourList().get(0) instanceof BehaviourList) {
+				ret = getTopLevelBehaviourList((BehaviourList)
+								ret.getBehaviourList().get(0));
+			} else if (ret.getBehaviourList().get(0) instanceof
+							BehaviourListPaths) {
+				BehaviourListPaths blps=(BehaviourListPaths)
+							ret.getBehaviourList().get(0);
+				
+				if (blps.getPaths().size() == 1) {
+					ret = getTopLevelBehaviourList(blps.getPaths().get(0));
+				}
+			}
+		}
+		
+		return(ret);
+	}
+
+	private Block m_block=null;
+	private org.scribble.model.ModelInclude m_include=null;
+	private java.util.Map<String,String> m_nameMap=null;
+	private java.util.List<Behaviour> m_list=new java.util.Vector<Behaviour>();
+}

Added: trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/BehaviourListIterator.java
===================================================================
--- trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/BehaviourListIterator.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/BehaviourListIterator.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,124 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 29 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.conformance.model;
+
+import org.scribble.model.*;
+
+/**
+ * This class provides an iterator implementation over a behaviour list.
+ */
+public class BehaviourListIterator implements java.util.Iterator<Behaviour> {
+
+	public BehaviourListIterator(BehaviourList list) {
+		m_list = list;
+	}
+	
+	protected BehaviourListIterator(BehaviourListIterator iter) {
+		m_list = iter.m_list;
+		m_index = iter.m_index;
+		if (iter.m_subList != null) {
+			m_subList = iter.m_subList.snapshot();
+		}
+	}
+	
+	public BehaviourListIterator snapshot() {
+		return(new BehaviourListIterator(this));
+	}
+	
+	public boolean hasNext() {
+		boolean ret=false;
+		
+		if (m_index < m_list.getBehaviourList().size() ||
+				(m_subList != null && m_subList.hasNext())) {
+			ret = true;
+		}
+		
+		return(ret);
+	}
+
+	public Behaviour next() {
+		Behaviour ret=null;
+		boolean f_end=false;
+		
+		do {
+			if (m_subList != null) {
+				
+				// Check if sublist has next
+				if (m_subList.hasNext()) {
+					ret = m_subList.next();
+				} else {
+					// Clear the list
+					m_subList = null;
+				}
+			} else if (m_index < m_list.getBehaviourList().size()) {
+				
+				ret = m_list.getBehaviourList().get(m_index++);
+				
+				if (ret instanceof BehaviourList) {
+					m_subList = ((BehaviourList)ret).getIterator();
+					ret = null;
+				}
+			} else {
+				f_end = true;
+			}
+		} while(ret == null && f_end == false);
+		
+		return(ret);
+	}
+
+	public void remove() {
+	}
+	
+	public ModelReference getComposedSource() {
+		ModelReference ret=null;
+		
+		if (m_subList != null) {
+			ret = m_subList.getComposedSource();
+		} else if (m_list.getModelInclude() != null) {
+			ret = m_list.getModelInclude().getReference();
+		}
+		
+		return(ret);
+	}
+	
+	public ModelInclude getModelInclude() {
+		ModelInclude ret=m_list.getModelInclude();
+		
+		if (ret == null && m_subList != null) {
+			ret = m_subList.getModelInclude();
+		}
+		
+		return(ret);
+	}
+	
+	public org.scribble.comparator.NameMap getNameMap() {
+		org.scribble.comparator.NameMap ret=m_list;
+		
+		if (m_subList != null) {
+			ret = m_subList.getNameMap();
+		}
+		
+		return(ret);
+	}
+
+	private BehaviourList m_list=null;
+	private int m_index=0;
+	private BehaviourListIterator m_subList=null;
+}

Added: trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/BehaviourListPaths.java
===================================================================
--- trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/BehaviourListPaths.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/BehaviourListPaths.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,214 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 29 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.conformance.model;
+
+import org.scribble.model.*;
+
+/**
+ * This class represents the group of behaviour list paths
+ * that need to be compared.
+ */
+public class BehaviourListPaths extends org.scribble.model.Behaviour {
+
+	/**
+	 * This constructor initializes the list of paths.
+	 * 
+	 * @param source The source behaviour
+	 * @param lists The list of BehaviourList objects
+	 */
+	public BehaviourListPaths(Behaviour source,
+					java.util.List<BehaviourList> lists) {
+		m_source = source;
+		m_lists = lists;
+		
+		derivedFrom(source);
+	}
+	
+	/**
+	 * This method returns the source behaviour associated
+	 * with the multiple paths.
+	 * 
+	 * @return The source behaviour
+	 */
+	public Behaviour getSourceBehaviour() {
+		return(m_source);
+	}
+	
+	/**
+	 * This method resets the index to the current path
+	 * to the beginning.
+	 */
+	public void reset() {
+		m_index = 0;
+	}
+	
+	/**
+	 * This method returns the next appropriate BehaviourList.
+	 * 
+	 * @return The BehaviourList
+	 */
+	public BehaviourList getNext() {
+		BehaviourList ret=null;
+		
+		if (m_index < m_lists.size()) {
+			ret = m_lists.get(m_index++);
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method determines whether there are more behaviour
+	 * lists to return.
+	 * 
+	 * @return Whether more behaviour lists to process
+	 */
+	public boolean hasNext() {
+		return(m_index < m_lists.size());
+	}
+	
+	/**
+	 * This method removes the handled behaviour list from
+	 * the list, to mark it as handled, and sets the
+	 * position to be the next list after the one that is
+	 * handled.
+	 * 
+	 * @param list The list that has been handled
+	 */
+	public void handled(BehaviourList list) {
+		if (m_lists.contains(list)) {
+			m_index = m_lists.indexOf(list);
+			m_lists.remove(list);
+		}
+	}
+	
+	/**
+	 * This method determines whether this multipath
+	 * construct is 'visible' in terms of conformance.
+	 * 
+	 * @return Whether the construct is visible (or
+	 * 				observable)
+	 */
+	public boolean isVisible() {
+		boolean ret=false;
+		
+		for (int i=0; ret == false && i < m_lists.size(); i++) {
+			if (m_lists.get(i).getBehaviourList().size() > 0) {
+				ret = true;
+			}
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns whether the behaviour is a grouping
+	 * construct.
+	 * 
+	 * @return Whether the behaviour is a grouping construct 
+	 */
+	@Override
+	public boolean isGroupingConstruct() {
+		return(m_source.isGroupingConstruct());
+	}
+	
+	/**
+	 * This method indicates whether the activity
+	 * is a conditional construct.
+	 * 
+	 * @return Whether the activity is conditional
+	 */
+	@Override
+	public boolean isConditional() {
+		return(m_source.isConditional());
+	}
+	
+	/**
+	 * This method returns whether the behaviour is a wait
+	 * state.
+	 * 
+	 * @return Whether the behaviour is a wait state
+	 */
+	@Override
+	public boolean isWaitState() {
+		return(m_source.isWaitState());
+	}
+	
+	/**
+	 * This method returns the behaviour lists representing the
+	 * paths associated with a single or multi-path construct.
+	 * 
+	 * @return The paths
+	 */
+	public java.util.List<BehaviourList> getPaths() {
+		return(m_lists);
+	}
+	
+	/**
+	 * This method determines if the underlying grouping construct
+	 * has strict scope.
+	 * 
+	 * @return Whether the behaviour represents a strict scope
+	 */
+	public boolean isStrictScope() {
+		boolean ret=true;
+		
+		// Default is to be strict scope. Only change if
+		// explicitly set to false by single or multiple path
+		// behaviour
+		if (m_source instanceof SinglePathBehaviour) {
+			ret = ((SinglePathBehaviour)m_source).isStrictScope();
+			
+		} else if (m_source instanceof MultiPathBehaviour) {
+			ret = ((MultiPathBehaviour)m_source).isStrictScope();
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the definition in which this
+	 * activity is contained.
+	 * 
+	 * @return The definition, or null if not found
+	 */
+	@Override
+	public Definition getEnclosingDefinition() {
+		return(m_source.getEnclosingDefinition());
+	}
+	
+	/**
+	 * This method returns the list of roles that are
+	 * responsible for initiating the activity. This can
+	 * be used to determine whether the model is
+	 * consistent in terms of decision makers subsequently
+	 * initiating actions.
+	 * 
+	 * @return The list of initiator roles
+	 */
+	@Override
+	public java.util.List<Role> getInitiatorRoles() {
+		return(m_source.getInitiatorRoles());
+	}
+
+	private Behaviour m_source=null;
+	private java.util.List<BehaviourList> m_lists=null;
+	private int m_index=0;
+}

Added: trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/AbstractDefinitionStatelessTransformationRule.java
===================================================================
--- trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/AbstractDefinitionStatelessTransformationRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/AbstractDefinitionStatelessTransformationRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,163 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 13 Dec 2008 : Initial version created by gary
+ */
+package org.scribble.conformance.model.transform;
+
+import org.scribble.conformance.model.BehaviourList;
+import org.scribble.extensions.RegistryFactory;
+import org.scribble.model.*;
+import org.scribble.model.admin.DefaultModelListener;
+
+/**
+ * This class represents an abstract definition stateless
+ * transformation rule. This class initialises the context
+ * with appropriate top level information which can be used
+ * when processing other transformations.
+ */
+public abstract class AbstractDefinitionStatelessTransformationRule
+						extends AbstractStatelessTransformationRule {
+
+	/**
+	 * This method returns a new definition of the appropriate
+	 * type.
+	 * 
+	 * @param context The context
+	 * @return The definition
+	 */
+	protected abstract Definition createDefinition(StatelessTransformationContext context);
+	
+	/**
+	 * This method returns a new multi-path behaviour, of the
+	 * appropriate type, to represent the mutually exclusive
+	 * choice construct at the top level of the stateless definition.
+	 * 
+	 * @param context The context
+	 * @return The multi-path behaviour
+	 */
+	protected abstract MultiPathBehaviour createMultiPathBehaviour(StatelessTransformationContext context);
+	
+	/**
+	 * This method transforms the supplied model object into
+	 * a stateless equivalent.
+	 * 
+	 * @param context The context
+	 * @param modelObject The model object to transform
+	 * @return The transformed object
+	 */
+	@Override
+	public ModelObject transform(StatelessTransformationContext context,
+							ModelObject modelObject) {
+		Definition ret=null;
+		Definition src=(Definition)modelObject;
+		
+		if (src.isStateless() == false) {
+			ret = createDefinition(context);
+			
+			ret.setStateless(true);
+			
+			LocatedName name=new LocatedName();
+			name.setName(src.getLocatedName().getName());
+			
+			if (src.getLocatedName().getRole() != null) {
+				Role role=new Role();
+				role.setName(src.getLocatedName().getRole().getName());
+				
+				name.setRole(role);
+			}
+			
+			name.derivedFrom(src.getLocatedName());
+			
+			ret.setLocatedName(name);
+			
+			// Convert conforms-to references
+			for (int i=0; i < src.getConformsTo().size(); i++) {
+				ConformanceReference ref=src.getConformsTo().get(i);
+				
+				ConformanceReference newref=new ConformanceReference(ref);
+				
+				ret.getConformsTo().add(newref);
+			}
+			
+			// Convert implements references
+			for (int i=0; i < src.getImplements().size(); i++) {
+				ImplementsReference ref=src.getImplements().get(i);
+				
+				ImplementsReference newref=new ImplementsReference(ref);
+				
+				ret.getImplements().add(newref);
+			}
+			
+			// Create role list
+			RoleList roleList=new RoleList();
+			
+			((DefaultStatelessTransformationContext)context).setRoleList(roleList);
+			
+			ret.getBlock().getContents().add(roleList);
+			
+			// Create the multi-path behaviour
+			MultiPathBehaviour mpb=createMultiPathBehaviour(context);
+			
+			if (mpb instanceof Activity) {
+				ret.getBlock().getContents().add((Activity)mpb);
+				
+				((DefaultStatelessTransformationContext)context).setMultiPathBehaviour(mpb);
+			}
+			
+			// Create initial path and process contents of the
+			// definition
+			Block newPath=context.createNewPath();
+			
+			context.transform(src.getBlock(), newPath);
+			
+			// Check for duplicate paths in multi-path behaviour
+			org.scribble.comparator.Comparator comparator=
+				(org.scribble.comparator.Comparator)
+				RegistryFactory.getRegistry().getExtension(
+						org.scribble.comparator.Comparator.class, null);
+
+			for (int i=mpb.getPaths().size()-1; i >= 0; i--) {
+				Block path=mpb.getPaths().get(i);
+				boolean f_duplicate=false;
+				
+				for (int j=0; f_duplicate == false &&
+									j < i; j++) {
+					Block path2=mpb.getPaths().get(j);
+					
+					DefaultModelListener l=new DefaultModelListener();
+					
+					BehaviourList mainBehaviourList=BehaviourList.createBehaviourList(path);
+					BehaviourList refBehaviourList=BehaviourList.createBehaviourList(path2);
+					
+					if (comparator.compare(mainBehaviourList,
+							context.getSource(), refBehaviourList,
+							context.getSource(), l)) {
+						f_duplicate = true;
+					}
+				}
+				
+				if (f_duplicate) {
+					mpb.removePath(path);
+				}
+			}
+		}
+		
+		return(ret);
+	}
+
+}

Added: trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/AbstractStatelessTransformationRule.java
===================================================================
--- trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/AbstractStatelessTransformationRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/AbstractStatelessTransformationRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 13 Dec 2008 : Initial version created by gary
+ */
+package org.scribble.conformance.model.transform;
+
+import org.scribble.model.*;
+
+/**
+ * This class represents an abstract stateless
+ * transformation rule.
+ */
+public abstract class AbstractStatelessTransformationRule
+						implements StatelessTransformationRule {
+
+	/**
+	 * This method transforms the supplied block activities into
+	 * a stateless equivalent.
+	 * 
+	 * @param context The context
+	 * @param src The source block
+	 * @param target The target block
+	 * @return Whether the block has been fully transformed
+	 */
+	public boolean transform(StatelessTransformationContext context,
+						Block src, Block target) {
+		return(true);
+	}
+	
+	/**
+	 * This method transforms the supplied model object into
+	 * a stateless equivalent.
+	 * 
+	 * @param context The context
+	 * @param modelObject The model object to transform
+	 * @return The transformed object
+	 */
+	public ModelObject transform(StatelessTransformationContext context,
+						ModelObject modelObject) {
+		return(null);
+	}
+}

Added: trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/BlockStatelessTransformationRule.java
===================================================================
--- trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/BlockStatelessTransformationRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/BlockStatelessTransformationRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,243 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 13 Dec 2008 : Initial version created by gary
+ */
+package org.scribble.conformance.model.transform;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+
+/**
+ * This class implements the stateless transformation
+ * rule for the Block component.
+ */
+ at RegistryInfo(extension=StatelessTransformationRule.class)
+public class BlockStatelessTransformationRule
+						extends AbstractStatelessTransformationRule {
+
+	/**
+	 * This method determines whether the stateless
+	 * transformation rule is applicable to the
+	 * supplied model object.
+	 * 
+	 * @param modelObject The model object
+	 * @return Whether the model object can be transformed
+	 */
+	public boolean isSupported(ModelObject modelObject) {
+		return(modelObject instanceof Block);
+	}
+	
+	/**
+	 * This method transforms the supplied model object into
+	 * a stateless equivalent.
+	 * 
+	 * @param context The context
+	 * @param modelObject The model object to transform
+	 * @return The transformed object
+	 */
+	public ModelObject transform(StatelessTransformationContext context,
+						ModelObject modelObject) {
+		return(null);
+	}
+	
+	/**
+	 * This method transforms the supplied block activities into
+	 * a stateless equivalent.
+	 * 
+	 * @param context The context
+	 * @param src The source block
+	 * @param target The target block
+	 * @return Whether the block has been fully transformed
+	 */
+	public boolean transform(StatelessTransformationContext context,
+						Block src, Block target) {
+		return(processBlock(context, src, target, 0, true));
+	}
+	
+	/**
+	 * This method processes the block of activities, to determine
+	 * whether some or all should be in a particular stateless
+	 * path.
+	 * 
+	 * @param context The context
+	 * @param block The target block associated with the stateless path
+	 * @param src The source block
+	 * @param pos The position to start in the source block
+	 * @return Whether the complete src block was processed
+	 */
+	public static boolean processBlock(StatelessTransformationContext context,
+						Block src, Block target, int pos, boolean full) {
+		boolean ret=true;
+		Block initialPath=context.getCurrentPath();
+		
+		for (int i=pos; src != null &&
+					i < src.getContents().size(); i++) {
+			Activity act=src.getContents().get(i);
+			
+			if (act instanceof Behaviour) {
+				if (((Behaviour)act).isWaitState()) {
+				
+					if (act instanceof MultiPathBehaviour) {
+						MultiPathBehaviour mpb=(MultiPathBehaviour)act;
+						
+						for (int j=0; j < mpb.getPaths().size(); j++) {
+							// Save return position
+							context.push(new TransformState((Behaviour)act,
+											src, i));
+							
+							Block p=context.createNewPath();
+							
+							if (p != null) {
+								context.transform(mpb.getPaths().get(j),
+										p);
+							}
+							
+							context.pop();
+						}
+						
+						if (((MultiPathBehaviour)act).isConditional() == false) {
+							src = null;
+						}
+						
+					} else if (act instanceof SinglePathBehaviour) {
+						SinglePathBehaviour spb=(SinglePathBehaviour)act;
+						
+						context.push(new TransformState((Behaviour)act,
+											src, i));
+			
+						Block p=context.createNewPath();
+						
+						if (p != null) {
+							context.transform(spb.getBlock(), p);
+						}
+						
+						context.pop();
+	
+						if (((SinglePathBehaviour)act).isConditional() == false) {
+							src = null;
+						}
+	
+					} else {
+						target = context.createNewPath();
+						
+						if (target != null) {
+							ModelObject newact=context.transform(act);
+							
+							if (newact instanceof Block) {
+								target.getContents().addAll(((Block)newact).getContents());
+							} else if (newact instanceof Activity) {
+								target.getContents().add((Activity)newact);
+							}
+						} else {
+							src = null;
+						}
+					}
+					
+					ret = false;
+				} else {
+					if (act instanceof SinglePathBehaviour ||
+							act instanceof MultiPathBehaviour ||
+							(act instanceof ModelInclude &&
+									!((ModelInclude)act).isAsynchronous())) {
+						context.push(new TransformState((Behaviour)act,
+											src, i));
+					}
+					
+					Block localPath=context.getCurrentPath();
+					
+					ModelObject newact=context.transform(act);
+					
+					if (newact instanceof Block) {
+						target.getContents().addAll(((Block)newact).getContents());
+					} else if (newact instanceof Activity) {
+						target.getContents().add((Activity)newact);
+					}
+					
+					if (localPath != context.getCurrentPath()) {
+						ret = false;
+					}
+					
+					if (act instanceof SinglePathBehaviour ||
+							act instanceof MultiPathBehaviour ||
+							(act instanceof ModelInclude &&
+									!((ModelInclude)act).isAsynchronous())) {
+						context.pop();
+						
+						src = null;
+					}
+				}
+			}
+		}
+		
+		if (src != null && full) {
+			// Came to end of block, so check if state from
+			// parent construct has been stored to enable
+			// further processing
+			//java.util.List<TransformState> stack=
+			//				context.getStack();
+			boolean f_continue=true;
+			
+			java.util.List<TransformState> tmpstack=
+					new java.util.Vector<TransformState>();
+			TransformState bp=null;
+			
+			//for (int i=0; f_continue && i < stack.size(); i++) {
+				//TransformState bp=stack.get(i);
+				
+			while (f_continue && (bp=context.pop()) != null) {
+				
+				tmpstack.add(bp);
+				
+				if (bp.getParent() instanceof SinglePathBehaviour &&
+						bp.getParent().isWaitState() == false &&
+						((SinglePathBehaviour)bp.getParent()).isRepetition()) {
+					
+					// Only process if the path has changed
+					if (initialPath != context.getCurrentPath()) {
+						context.disallowNewPaths();
+						
+						context.push(bp);
+						
+						ModelObject newact=context.transform(bp.getParent());
+						
+						context.pop();
+						
+						if (newact instanceof Block) {
+							target.getContents().addAll(((Block)newact).getContents());
+						} else if (newact instanceof Activity) {
+							target.getContents().add((Activity)newact);
+						}
+						
+						context.allowNewPaths();
+					}
+					
+					f_continue = false;
+				} else {
+					f_continue = processBlock(context, bp.getBlock(),
+									target, bp.getPosition()+1, false);
+				}
+			}
+			
+			for (int i=tmpstack.size()-1; i >= 0; i--) {
+				context.push(tmpstack.get(i));
+			}
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/DefaultStatelessTransformationContext.java
===================================================================
--- trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/DefaultStatelessTransformationContext.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/DefaultStatelessTransformationContext.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,236 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 13 Dec 2008 : Initial version created by gary
+ */
+package org.scribble.conformance.model.transform;
+
+import org.scribble.model.*;
+
+/**
+ * This class provides the default implementation of the
+ * stateless transformation context.
+ */
+public class DefaultStatelessTransformationContext 
+					implements StatelessTransformationContext {
+
+	/**
+	 * This is the constructor for the default context.
+	 * 
+	 * @param ref The model reference for the definition being
+	 * 				transformed
+	 */
+	public DefaultStatelessTransformationContext(ModelReference ref) {
+		
+		m_source = ref;
+		
+		java.util.List<Object> rules=
+			org.scribble.extensions.RegistryFactory.getRegistry().
+						getExtensions(StatelessTransformationRule.class,
+									ref.getNotation());
+		
+		// Transfer to typed list
+		for (int i=0; i < rules.size(); i++) {
+			if (rules.get(i) instanceof StatelessTransformationRule) {
+				m_rules.add((StatelessTransformationRule)rules.get(i));
+			}
+		}
+	}
+	
+	/**
+	 * This method returns the model reference associated with
+	 * the definition being transformed.
+	 * 
+	 * @return The model reference for the definition being
+	 * 					transformed
+	 */
+	public ModelReference getSource() {
+		return(m_source);
+	}
+	
+	/**
+	 * This method transforms the supplied model object.
+	 * 
+	 * @param src The source block
+	 * @param target The target block
+	 * @return Whether the block was fully transformed
+	 */
+	public boolean transform(Block src, Block target) {
+		boolean ret=false;
+		boolean f_processed=false;
+		
+		for (int i=0; f_processed == false &&
+						i < m_rules.size(); i++) {
+			if (m_rules.get(i).isSupported(src)) {
+				ret = m_rules.get(i).transform(this, src, target);
+				f_processed = true;
+			}
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method transforms the supplied model object.
+	 * 
+	 * @param modelObject The model object
+	 * @return The transformed model object
+	 */
+	public ModelObject transform(ModelObject modelObject) {
+		ModelObject ret=null;
+		
+		for (int i=0; ret == null &&
+							i < m_rules.size(); i++) {
+			if (m_rules.get(i).isSupported(modelObject)) {
+				ret = m_rules.get(i).transform(this, modelObject);
+			}
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns a new path from the top
+	 * level stateless choice construct, or null if 
+	 * new stateless paths should not be processed at
+	 * this time.
+	 * 
+	 * @return The new path, or null if new  paths
+	 * 				should not be processed
+	 */
+	public org.scribble.model.Block createNewPath() {
+		org.scribble.model.Block ret=null;
+		
+		if (m_multiPathBehaviour != null && m_allowNewPaths) {
+			if (m_lastPath != null && m_lastPath.getContents().size() == 0) {
+				ret = m_lastPath;
+			} else {
+				ret = m_multiPathBehaviour.createNewPath();
+				
+				m_lastPath = ret;
+			}
+		} else {
+			// Clear the last path
+			m_lastPath = null;
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the current stateless path. If
+	 * no path is returned, then it is not currently possible
+	 * to record the stateless behaviour.
+	 * 
+	 * @return The current path, or null if no path associated
+	 */
+	public Block getCurrentPath() {
+		return(m_lastPath);
+	}
+	
+	/**
+	 * This method indicates that new paths are allowed.
+	 */
+	public void allowNewPaths() {
+		m_allowNewPaths = true;
+	}
+	
+	/**
+	 * This method indicates that new paths should not be
+	 * created.
+	 */
+	public void disallowNewPaths() {
+		m_allowNewPaths = false;
+	}
+	
+	/**
+	 * This method sets the multipath behaviour representing
+	 * the top level mutually exclusive construct used to
+	 * model the different stateless paths.
+	 * 
+	 * @param mpb The multi-path beheaviour
+	 */
+	protected void setMultiPathBehaviour(org.scribble.model.MultiPathBehaviour mpb) {
+		m_multiPathBehaviour = mpb;
+	}
+	
+	/**
+	 * This method returns the list of roles that
+	 * are defined at the top level, associated
+	 * with the stateless definition.
+	 * 
+	 * @return The role list
+	 */
+	public org.scribble.model.RoleList getRoleList() {
+		return(m_roleList);
+	}
+
+	/**
+	 * This method sets the role list.
+	 * 
+	 * @param roleList The role list
+	 */
+	protected void setRoleList(org.scribble.model.RoleList roleList) {
+		m_roleList = roleList;
+	}
+	
+	/**
+	 * This method pushes the supplied state on to
+	 * the top of the stack.
+	 * 
+	 *@param state The state
+	 */
+	public void push(TransformState state) {
+		m_stack.add(0, state);
+	}
+	
+	/**
+	 * This method returns the state at the top of the
+	 * stack.
+	 * 
+	 * @return The state on top of the stack, or null
+	 * 				if the stack is empty
+	 */
+	public TransformState pop() {
+		TransformState ret=null;
+		
+		if (m_stack.size() > 0) {
+			ret = m_stack.remove(0);
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the stack, with the first
+	 * element being the top of the stack.
+	 * 
+	 * @return The stack
+	 */
+	public java.util.List<TransformState> getStack() {
+		return(m_stack);
+	}
+	
+	private ModelReference m_source=null;
+	private org.scribble.model.MultiPathBehaviour m_multiPathBehaviour=null;
+	private boolean m_allowNewPaths=true;
+	private Block m_lastPath=null;
+	private java.util.List<TransformState> m_stack=new java.util.Vector<TransformState>();
+	private org.scribble.model.RoleList m_roleList=null;
+	private java.util.List<StatelessTransformationRule> m_rules=
+				new java.util.Vector<StatelessTransformationRule>();
+}

Added: trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/DefaultStatelessTransformer.java
===================================================================
--- trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/DefaultStatelessTransformer.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/DefaultStatelessTransformer.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 7 Dec 2008 : Initial version created by gary
+ */
+package org.scribble.conformance.model.transform;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.Definition;
+import org.scribble.model.ModelReference;
+
+/**
+ * This class provides a tool for transforming a stateful
+ * local definition into a stateless definition. 
+ */
+ at RegistryInfo(extension=StatelessTransformer.class)
+public class DefaultStatelessTransformer
+						implements StatelessTransformer {
+
+	/**
+	 * The constructor for the stateful to stateless
+	 * model transformation tool.
+	 */
+	public DefaultStatelessTransformer() {
+	}
+	
+	/**
+	 * This method transforms the supplied definition.
+	 * 
+	 * @param stateful The stateful definition
+	 * @param ref The model reference associated with the
+	 * 						definition
+	 * @return The stateless definition
+	 */
+	public Definition transform(Definition stateful,
+						ModelReference ref) {
+		Definition ret=null;
+		
+		DefaultStatelessTransformationContext context=
+				new DefaultStatelessTransformationContext(ref);
+		
+		ret = (Definition)context.transform(stateful);
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/InteractionStatelessTransformationRule.java
===================================================================
--- trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/InteractionStatelessTransformationRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/InteractionStatelessTransformationRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 13 Dec 2008 : Initial version created by gary
+ */
+package org.scribble.conformance.model.transform;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+
+/**
+ * This class implements the stateless transformation
+ * rule for the Interaction component.
+ */
+ at RegistryInfo(extension=StatelessTransformationRule.class) //,category=Interaction.class)
+public class InteractionStatelessTransformationRule
+						extends AbstractStatelessTransformationRule {
+
+	/**
+	 * This method determines whether the stateless
+	 * transformation rule is applicable to the
+	 * supplied model object.
+	 * 
+	 * @param modelObject The model object
+	 * @return
+	 */
+	public boolean isSupported(ModelObject modelObject) {
+		return(modelObject instanceof Interaction);
+	}
+	
+	/**
+	 * This method returns the new interaction.
+	 * 
+	 * @return The new interaction
+	 */
+	protected Interaction createInteraction() {
+		return(new Interaction());
+	}
+	
+	/**
+	 * This method transforms the supplied model object into
+	 * a stateless equivalent.
+	 * 
+	 * @param context The context
+	 * @param modelObject The model object to transform
+	 * @return The transformed object
+	 */
+	public ModelObject transform(StatelessTransformationContext context,
+						ModelObject modelObject) {
+		Interaction ret=null;
+		Interaction src=(Interaction)modelObject;
+		
+		ret = createInteraction();
+		
+		ret.derivedFrom(src);
+		
+		// Configure the interaction
+		if (src.getMessageSignature() != null) {
+			ret.setMessageSignature((MessageSignature)
+					context.transform(src.getMessageSignature()));
+		}
+		
+		if (src.getFromRole() != null) {
+			ret.setFromRole((Role)context.transform(src.getFromRole()));
+		}
+		
+		if (src.getToRole() != null) {
+			ret.setToRole((Role)context.transform(src.getToRole()));
+		}
+		
+		ret.setRequestLabel(src.getRequestLabel());
+		ret.setReplyToLabel(src.getReplyToLabel());
+
+		// TODO: Transform channel??
+		
+		return(ret);
+	}
+	
+}

Added: trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/MessageSignatureStatelessTransformationRule.java
===================================================================
--- trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/MessageSignatureStatelessTransformationRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/MessageSignatureStatelessTransformationRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 13 Dec 2008 : Initial version created by gary
+ */
+package org.scribble.conformance.model.transform;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+
+/**
+ * This class implements the stateless transformation
+ * rule for the MessageSignature component.
+ */
+ at RegistryInfo(extension=StatelessTransformationRule.class)
+public class MessageSignatureStatelessTransformationRule
+				extends AbstractStatelessTransformationRule {
+
+	/**
+	 * This method determines whether the stateless
+	 * transformation rule is applicable to the
+	 * supplied model object.
+	 * 
+	 * @param modelObject The model object
+	 * @return Whether the model object can be transformed
+	 */
+	public boolean isSupported(ModelObject modelObject) {
+		return(modelObject instanceof MessageSignature);
+	}
+	
+	/**
+	 * This method transforms the supplied model object into
+	 * a stateless equivalent.
+	 * 
+	 * @param context The context
+	 * @param modelObject The model object to transform
+	 * @return The transformed object
+	 */
+	public ModelObject transform(StatelessTransformationContext context,
+							ModelObject modelObject) {
+		MessageSignature ret=null;
+		MessageSignature src=(MessageSignature)modelObject;
+		
+		ret = new MessageSignature();
+		
+		ret.derivedFrom(src);
+		
+		ret.setOperation(src.getOperation());
+		
+		for (int i=0; i < src.getTypes().size(); i++) {
+			TypeReference ref=(TypeReference)
+					context.transform(src.getTypes().get(i));
+			
+			if (ref != null) {
+				ret.getTypes().add(ref);
+			}
+		}
+		
+		return(ret);
+	}
+	
+}

Added: trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/RoleStatelessTransformationRule.java
===================================================================
--- trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/RoleStatelessTransformationRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/RoleStatelessTransformationRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 13 Dec 2008 : Initial version created by gary
+ */
+package org.scribble.conformance.model.transform;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+
+/**
+ * This class implements the stateless transformation
+ * rule for the Role component.
+ */
+ at RegistryInfo(extension=StatelessTransformationRule.class)
+public class RoleStatelessTransformationRule
+						extends AbstractStatelessTransformationRule {
+
+	/**
+	 * This method determines whether the stateless
+	 * transformation rule is applicable to the
+	 * supplied model object.
+	 * 
+	 * @param modelObject The model object
+	 * @return Whether the model object can be transformed
+	 */
+	public boolean isSupported(ModelObject modelObject) {
+		return(modelObject instanceof Role);
+	}
+	
+	/**
+	 * This method transforms the supplied model object into
+	 * a stateless equivalent.
+	 * 
+	 * @param context The context
+	 * @param modelObject The model object to transform
+	 * @return The transformed object
+	 */
+	public ModelObject transform(StatelessTransformationContext context,
+						ModelObject modelObject) {
+		Role ret=null;
+		Role src=(Role)modelObject;
+		
+		// Check if already defined in role list associated with
+		// the context
+		ret = context.getRoleList().getRole(src.getName());
+		
+		if (ret == null) {
+			ret = new Role();
+			ret.setName(src.getName());
+			
+			ret.derivedFrom(src);
+			
+			context.getRoleList().getRoles().add(ret);
+		}
+		
+		return(ret);
+	}
+	
+}

Added: trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/StatelessTransformationContext.java
===================================================================
--- trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/StatelessTransformationContext.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/StatelessTransformationContext.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,126 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 13 Dec 2008 : Initial version created by gary
+ */
+package org.scribble.conformance.model.transform;
+
+import org.scribble.model.*;
+
+/**
+ * This interface provides the context for the stateless
+ * transformation rules.
+ */
+public interface StatelessTransformationContext {
+
+	/**
+	 * This method returns the model reference associated with
+	 * the definition being transformed.
+	 * 
+	 * @return The model reference for the definition being
+	 * 					transformed
+	 */
+	public ModelReference getSource();
+	
+	/**
+	 * This method transforms the supplied block.
+	 * 
+	 * @param src The source block
+	 * @param target The target block
+	 * @return Whether the block was fully transformed
+	 */
+	public boolean transform(Block src, Block target);
+	
+	/**
+	 * This method transforms the supplied model object.
+	 * 
+	 * @param modelObject The model object
+	 * @return The transformed model object
+	 */
+	public ModelObject transform(ModelObject modelObject);
+	
+	/**
+	 * This method returns a new path from the top
+	 * level stateless choice construct, or null if 
+	 * new stateless paths should not be processed at
+	 * this time.
+	 * 
+	 * @return The new path, or null if new  paths
+	 * 				should not be processed
+	 */
+	public Block createNewPath();
+	
+	/**
+	 * This method returns the current stateless path. If
+	 * no path is returned, then it is not currently possible
+	 * to record the stateless behaviour.
+	 * 
+	 * @return The current path, or null if no path associated
+	 */
+	public Block getCurrentPath();
+	
+	/**
+	 * This method indicates that new paths are allowed.
+	 */
+	public void allowNewPaths();
+	
+	/**
+	 * This method indicates that new paths should not be
+	 * created.
+	 */
+	public void disallowNewPaths();
+
+	/**
+	 * This method returns the list of roles that
+	 * are defined at the top level, associated
+	 * with the stateless definition.
+	 * 
+	 * @return The role list
+	 */
+	public RoleList getRoleList();
+	
+	/**
+	 * This method pushes the supplied state on to
+	 * the top of the stack.
+	 * 
+	 *@param state The state
+	 */
+	public void push(TransformState state);
+	
+	/**
+	 * This method returns the state at the top of the
+	 * stack.
+	 * 
+	 * @return The state on top of the stack, or null
+	 * 				if the stack is empty
+	 */
+	public TransformState pop();
+	
+	/**
+	 * This method returns the stack, with the first
+	 * element being the top of the stack.
+	 * 
+	 * @return The stack
+	 */
+	public java.util.List<TransformState> getStack();
+	
+	// TODO: Will need support for name mapping, as
+	// (for example) roles in a sub-conversation,
+	// when moved to be accessible at the top level
+	// in a path, will need to use the role names
+	// defined at the top level.
+}

Added: trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/StatelessTransformationRule.java
===================================================================
--- trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/StatelessTransformationRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/StatelessTransformationRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 13 Dec 2008 : Initial version created by gary
+ */
+package org.scribble.conformance.model.transform;
+
+import org.scribble.model.*;
+
+/**
+ * This interface represents a rule that is responsible
+ * for transforming a supplied model element into
+ * a stateless model element.
+ */
+public interface StatelessTransformationRule {
+
+	/**
+	 * This method determines whether the stateless
+	 * transformation rule is applicable to the
+	 * supplied model object.
+	 * 
+	 * @param modelObject The model object
+	 * @return Whether the model object can be transformed
+	 */
+	public boolean isSupported(ModelObject modelObject);
+	
+	/**
+	 * This method transforms the supplied block activities into
+	 * a stateless equivalent.
+	 * 
+	 * @param context The context
+	 * @param src The source block
+	 * @param target The target block
+	 * @return Whether the block has been fully transformed
+	 */
+	public boolean transform(StatelessTransformationContext context,
+						Block src, Block target);
+	
+	/**
+	 * This method transforms the supplied model object into
+	 * a stateless equivalent.
+	 * 
+	 * @param context The context
+	 * @param modelObject The model object to transform
+	 * @return The transformed object
+	 */
+	public ModelObject transform(StatelessTransformationContext context,
+						ModelObject modelObject);
+	
+}

Added: trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/StatelessTransformer.java
===================================================================
--- trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/StatelessTransformer.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/StatelessTransformer.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 7 Dec 2008 : Initial version created by gary
+ */
+package org.scribble.conformance.model.transform;
+
+import org.scribble.model.*;
+
+/**
+ * This class provides a tool for transforming a stateful
+ * local definition into a stateless definition. 
+ */
+public interface StatelessTransformer {
+
+	/**
+	 * This method transforms the supplied definition.
+	 * 
+	 * @param stateful The stateful definition
+	 * @param ref The model reference associated with the
+	 * 						definition
+	 * @return The stateless definition
+	 */
+	public Definition transform(Definition stateful,
+						ModelReference ref);
+	
+}

Added: trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/TransformState.java
===================================================================
--- trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/TransformState.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/TransformState.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 22 Dec 2008 : Initial version created by gary
+ */
+package org.scribble.conformance.model.transform;
+
+import org.scribble.model.Behaviour;
+import org.scribble.model.Block;
+
+/**
+ * This class provides the state for the transformation
+ * of a stateless model object.
+ */
+public class TransformState {
+
+	public TransformState(Behaviour parent,
+					Block block, int pos) {
+		m_parent = parent;
+		m_block = block;
+		m_position = pos;
+	}
+
+	public Behaviour getParent() {
+		return(m_parent);
+	}
+	
+	public Block getBlock() {
+		return(m_block);
+	}
+	
+	public int getPosition() {
+		return(m_position);
+	}
+	
+	private Behaviour m_parent=null;
+	private Block m_block=null;
+	private int m_position=0;
+}

Added: trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/TypeReferenceStatelessTransformationRule.java
===================================================================
--- trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/TypeReferenceStatelessTransformationRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/model/transform/TypeReferenceStatelessTransformationRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 13 Dec 2008 : Initial version created by gary
+ */
+package org.scribble.conformance.model.transform;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+
+/**
+ * This class implements the stateless transformation
+ * rule for the TypeReference component.
+ */
+ at RegistryInfo(extension=StatelessTransformationRule.class)
+public class TypeReferenceStatelessTransformationRule
+						extends AbstractStatelessTransformationRule {
+
+	/**
+	 * This method determines whether the stateless
+	 * transformation rule is applicable to the
+	 * supplied model object.
+	 * 
+	 * @param modelObject The model object
+	 * @return Whether the model object can be transformed
+	 */
+	public boolean isSupported(ModelObject modelObject) {
+		return(modelObject instanceof TypeReference);
+	}
+	
+	/**
+	 * This method transforms the supplied model object into
+	 * a stateless equivalent.
+	 * 
+	 * @param context The context
+	 * @param modelObject The model object to transform
+	 * @return The transformed object
+	 */
+	public ModelObject transform(StatelessTransformationContext context,
+					ModelObject modelObject) {
+		TypeReference ret=null;
+		TypeReference src=(TypeReference)modelObject;
+		
+		ret = new TypeReference();
+		
+		ret.derivedFrom(src);
+		
+		ret.setAlias(src.getAlias());
+		ret.setLocalpart(src.getLocalpart());
+		ret.setLocatedRole(src.getLocatedRole());
+		ret.setNamespace(src.getNamespace());		
+		ret.setNotation(src.getNotation());
+		
+		return(ret);
+	}
+	
+}

Added: trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/osgi/Activator.java
===================================================================
--- trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/osgi/Activator.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conformance/src/main/java/org/scribble/conformance/osgi/Activator.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,48 @@
+package org.scribble.conformance.osgi;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator implements BundleActivator {
+
+	// The plug-in ID
+	public static final String PLUGIN_ID = "org.scribble.experimental.comparator";
+
+	// The shared instance
+	private static Activator plugin;
+	
+	/**
+	 * The constructor
+	 */
+	public Activator() {
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
+	 */
+	public void start(BundleContext context) throws Exception {
+		plugin = this;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
+	 */
+	public void stop(BundleContext context) throws Exception {
+		plugin = null;
+	}
+
+	/**
+	 * Returns the shared instance
+	 *
+	 * @return the shared instance
+	 */
+	public static Activator getDefault() {
+		return plugin;
+	}
+
+}

Added: trunk/bundles/org.scribble.conformance/src/plugintest/org/scribble/conformance/model/transform/TransformTest.java
===================================================================
--- trunk/bundles/org.scribble.conformance/src/plugintest/org/scribble/conformance/model/transform/TransformTest.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conformance/src/plugintest/org/scribble/conformance/model/transform/TransformTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,279 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.scribble.conformance.model.transform;
+
+import junit.framework.TestCase;
+import junit.framework.TestResult;
+import junit.framework.TestSuite;
+
+import org.scribble.extensions.RegistryFactory;
+import org.scribble.model.Definition;
+
+public class TransformTest extends TestCase {
+
+    public static TestSuite suite() {
+        TestSuite suite = new TestSuite("Stateful -> Stateless Transform Tests");
+        
+        suite.addTest(new StatefulToStatelessTest("Interaction1", "R1", "scv"));
+        suite.addTest(new StatefulToStatelessTest("Interaction1", "R2", "scv"));
+        
+        // TODO: Need to handle common start with diverging behaviour
+        //suite.addTest(new StatefulToStatelessTest("Interaction2", "R2", "scv"));
+        
+        return suite;
+    }
+    
+    /**
+     * The test case for running the stateful to stateless test.
+     */
+	protected static class StatefulToStatelessTest extends TestCase {
+
+		/**
+		 * This constructor is initialized with the test
+		 * name.
+		 * 
+		 * @param name The test name
+		 * @param role The role
+		 * @param notation The notation
+		 */
+		public StatefulToStatelessTest(String name,
+							String role, String notation) {
+			super(name+"@"+role+"."+notation);
+			
+			m_name = name+"@"+role+"."+notation;
+			m_role = role;
+			m_notation = notation;
+		}
+		
+		/**
+		 * This method runs the test.
+		 * 
+		 * @param result The test result
+		 */
+		public void run(TestResult result) {
+			result.startTest(this);
+			
+			String filename="testmodels/"+m_name;
+			
+			java.io.InputStream is=
+				TransformTest.class.getResourceAsStream(filename);
+			
+			if (is == null) {
+				result.addError(this,
+						new Throwable("Unable to locate resource: "+filename));
+			} else {			
+				org.scribble.parser.Parser p=new org.scribble.parser.DefaultParser();
+				org.scribble.model.ModelReference ref=
+						new org.scribble.model.ModelReference(m_notation);
+				org.scribble.model.admin.ModelListener l=
+						new org.scribble.model.admin.DefaultModelListener();
+				
+				org.scribble.model.Model model=p.parse(ref, is, l, null);
+				
+				if (model == null) {
+					result.addError(this, new Throwable("Model is null"));
+				} else {
+					
+					/*
+					org.scribble.projector.Projector projector=
+						new org.scribble.projector.DefaultProjector();
+					*/
+					
+					//org.scribble.model.Role role=null;
+					
+					// Obtain role from definition
+					java.util.List<Definition> defns=model.getDefinitions();
+					Definition defn=null;
+					
+					if (defns.size() == 1) {
+						defn = defns.get(0);
+					}
+					
+					/*
+					java.util.List<org.scribble.model.Role> roles=defn.getRoles();
+					
+					for (int i=0; role == null && i < roles.size(); i++) {
+						if (roles.get(i).getName().equals(m_role)) {
+							role = roles.get(i);
+						}
+					}
+					
+					if (role == null) {
+						result.addError(this,
+								new Throwable("Role '"+m_role+"' not found"));						
+					} else {
+					*/
+						//org.scribble.model.Model projected=
+						//		projector.project(ref, model,role, l);
+						
+						StatelessTransformer transformer=(StatelessTransformer)
+								RegistryFactory.getRegistry().getExtension(
+										StatelessTransformer.class, null);
+					
+						defns = model.getDefinitions();
+						defn = null;
+						
+						if (defns.size() == 1) {
+							defn = defns.get(0);
+						}
+						
+						if (transformer != null && defn != null) {
+							
+							org.scribble.model.Definition transformed=
+										transformer.transform(defn, ref);
+							
+							org.scribble.export.Exporter exporter=
+								(org.scribble.export.Exporter)
+								RegistryFactory.getRegistry().getExtension(
+										org.scribble.export.Exporter.class, null);
+
+							org.scribble.export.text.TextFormatter formatter=
+								new org.scribble.export.text.TextFormatter();
+							
+							java.io.ByteArrayOutputStream os=
+								new java.io.ByteArrayOutputStream();
+							
+							formatter.setOutputStream(os);
+								
+							try {
+								exporter.export(ref, transformed, formatter);
+								
+								String text=new String(os.toByteArray());
+
+								checkResults(result, text);
+							} catch(Exception e) {
+								result.addError(this, e);
+							}
+							
+						} else {
+							result.addError(this,
+									new Throwable("Unable to find Model Generator"));						
+						}
+					//}
+				}
+			}
+			
+			result.endTest(this);
+		}
+		
+		/**
+		 * This method checks the generated stateless against a
+		 * previously stored correct version.
+		 * 
+		 * @param result The test result
+		 * @param text The stateless definition
+		 */
+		protected void checkResults(TestResult result, String text) {
+			boolean f_valid=false;
+
+			String filename="results/"+m_name;
+			
+			java.io.InputStream is=
+				TransformTest.class.getResourceAsStream(filename);
+			
+			if (is != null) {
+				
+				try {
+					byte[] b=new byte[is.available()];
+				
+					is.read(b);
+					
+					is.close();
+					
+					String orig=new String(b);
+					
+					if (orig.equals(text) == false) {
+						result.addError(this,
+								new Throwable("Transformed stateless definition does not match stored version"));
+					} else {
+						f_valid = true;
+					}
+				} catch(Exception e) {
+					result.addError(this, e);
+				}
+			} else {
+				result.addError(this,
+						new Throwable("Resulting stateless definition '"+filename+
+								"' not found for comparison"));
+			}
+			
+			if (f_valid == false) {
+				String modelfile="testmodels/"+m_name;
+				
+				java.net.URL url=TransformTest.class.getResource(modelfile);
+				
+				try {
+					url = org.eclipse.core.runtime.FileLocator.toFileURL(url);
+				} catch(Exception e) {
+					e.printStackTrace();
+				}
+				
+				if (url != null) {
+					// URL will point to copy of test models in the classes folder, so need
+					// to obtain reference back to source version
+					java.io.File f=null;
+					
+					if (url.getFile().indexOf("classes") != -1) {
+						f = new java.io.File(url.getFile().replaceFirst("classes","src/plugintest"));
+					} else if (url.getFile().indexOf("bin") != -1) {						
+						f = new java.io.File(url.getFile().replaceFirst("bin","src/plugintest"));
+					} else {
+						result.addError(this, new Exception("Could not locate results folder to record expected result"));
+					}
+					
+					if (f != null && f.exists()) {
+						f = f.getParentFile().getParentFile();
+						
+						java.io.File resultsDir=new java.io.File(f, "results");
+						
+						if (resultsDir.exists() == false) {
+							resultsDir.mkdirs();
+						}
+						
+						java.io.File resultFile=new java.io.File(resultsDir,
+											m_name+".expected");
+						
+						if (resultFile.exists() == false) {
+							try {
+								java.io.FileOutputStream fos=new java.io.FileOutputStream(resultFile);
+								
+								fos.write(text.getBytes());
+								
+								fos.flush();
+								fos.close();
+								
+							} catch(Exception e){
+								result.addError(this, e);
+							}
+						} else {
+							System.err.println("NOTE: Expected output '"+resultFile+
+										"' already exists - not being overwritten");
+						}
+					} else {
+						result.addError(this, new Throwable("Unable to obtain URL for stateful model source '"+
+								m_name+"': "+url));
+					}
+				}
+			}
+		}
+
+		private String m_name=null;
+		private String m_role=null;
+		private String m_notation=null;
+	}
+}

Added: trunk/bundles/org.scribble.conformance/src/plugintest/org/scribble/conformance/model/transform/results/Interaction1 at R1.scv
===================================================================
--- trunk/bundles/org.scribble.conformance/src/plugintest/org/scribble/conformance/model/transform/results/Interaction1 at R1.scv	                        (rev 0)
+++ trunk/bundles/org.scribble.conformance/src/plugintest/org/scribble/conformance/model/transform/results/Interaction1 at R1.scv	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,11 @@
+stateless conversation Interaction1 at R1 {
+	role	R2;
+	if {
+		M1 to R2;
+	} else if {
+		M2 from R2;
+		M3 to R2;
+	} else if {
+		M4 from R2;
+	}
+}
\ No newline at end of file

Added: trunk/bundles/org.scribble.conformance/src/plugintest/org/scribble/conformance/model/transform/results/Interaction1 at R2.scv
===================================================================
--- trunk/bundles/org.scribble.conformance/src/plugintest/org/scribble/conformance/model/transform/results/Interaction1 at R2.scv	                        (rev 0)
+++ trunk/bundles/org.scribble.conformance/src/plugintest/org/scribble/conformance/model/transform/results/Interaction1 at R2.scv	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,10 @@
+stateless conversation Interaction1 at R2 {
+	role	R1;
+	if {
+		M1 from R1;
+		M2 to R1;
+	} else if {
+		M3 from R1;
+		M4 to R1;
+	}
+}
\ No newline at end of file

Added: trunk/bundles/org.scribble.conformance/src/plugintest/org/scribble/conformance/model/transform/results/Interaction2 at R2.scv
===================================================================
--- trunk/bundles/org.scribble.conformance/src/plugintest/org/scribble/conformance/model/transform/results/Interaction2 at R2.scv	                        (rev 0)
+++ trunk/bundles/org.scribble.conformance/src/plugintest/org/scribble/conformance/model/transform/results/Interaction2 at R2.scv	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,11 @@
+stateless conversation Interaction1 at R2 {
+	role	R1;
+	if {
+		M1 from R1;
+		if {
+			M2 to R1;
+		} else if {
+			M3 to R1;
+		}
+	}
+}
\ No newline at end of file

Added: trunk/bundles/org.scribble.conformance/src/plugintest/org/scribble/conformance/model/transform/testmodels/Interaction1 at R1.scv
===================================================================
--- trunk/bundles/org.scribble.conformance/src/plugintest/org/scribble/conformance/model/transform/testmodels/Interaction1 at R1.scv	                        (rev 0)
+++ trunk/bundles/org.scribble.conformance/src/plugintest/org/scribble/conformance/model/transform/testmodels/Interaction1 at R1.scv	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,11 @@
+namespace test;
+
+conversation Interaction1 at R1 {
+	role	R2;
+	
+	M1 to R2;
+	M2 from R2;
+	
+	M3 to R2;
+	M4 from R2;
+}

Added: trunk/bundles/org.scribble.conformance/src/plugintest/org/scribble/conformance/model/transform/testmodels/Interaction1 at R2.scv
===================================================================
--- trunk/bundles/org.scribble.conformance/src/plugintest/org/scribble/conformance/model/transform/testmodels/Interaction1 at R2.scv	                        (rev 0)
+++ trunk/bundles/org.scribble.conformance/src/plugintest/org/scribble/conformance/model/transform/testmodels/Interaction1 at R2.scv	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,11 @@
+namespace test;
+
+conversation Interaction1 at R2 {
+	role	R1;
+	
+	M1 from R1;
+	M2 to R1;
+	
+	M3 from R1;
+	M4 to R1;
+}

Added: trunk/bundles/org.scribble.conformance/src/plugintest/org/scribble/conformance/model/transform/testmodels/Interaction2 at R2.scv
===================================================================
--- trunk/bundles/org.scribble.conformance/src/plugintest/org/scribble/conformance/model/transform/testmodels/Interaction2 at R2.scv	                        (rev 0)
+++ trunk/bundles/org.scribble.conformance/src/plugintest/org/scribble/conformance/model/transform/testmodels/Interaction2 at R2.scv	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,11 @@
+namespace test;
+
+conversation Interaction1 at R2 {
+	role	R1;
+	
+	M1 from R1;
+	M2 to R1;
+	
+	M1 from R1;
+	M3 to R1;
+}

Added: trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/comparator/BehaviourListComparatorRuleTest.java
===================================================================
--- trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/comparator/BehaviourListComparatorRuleTest.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/comparator/BehaviourListComparatorRuleTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,1877 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 14 Jul 2008 : Initial version created by gary
+ */
+package org.scribble.conformance.comparator;
+
+import junit.framework.TestCase;
+
+import org.scribble.conformance.model.*;
+import org.scribble.comparator.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ErrorRecorder;
+
+public class BehaviourListComparatorRuleTest extends TestCase {
+	
+	protected java.util.List<ComparatorRule> getRules() {
+		java.util.List<ComparatorRule> ret=new java.util.Vector<ComparatorRule>();
+		ret.add(new BehaviourListComparatorRule());
+		ret.add(new TestBehaviour1ComparatorRule());
+		ret.add(new TestSinglePathComparatorRule());
+		ret.add(new TestMultiPathComparatorRule());
+		ret.add(new org.scribble.comparator.BlockComparatorRule());
+		return(ret);
+	}
+	
+	public void testCompareSimpleBehaviour() {
+		
+		ModelReference ref=new ModelReference((String)null);
+		
+		DefaultComparatorContext context=
+					new DefaultComparatorContext(ref, ref, getRules());
+		
+		BehaviourList mainList=new TestBehaviourList();
+		BehaviourList refList=new TestBehaviourList();
+		
+		TestBehaviour1 mtb=new TestBehaviour1();
+		TestBehaviour1 rtb=new TestBehaviour1();
+		
+		mtb.setMatchWith(rtb);
+		
+		mainList.getBehaviourList().add(mtb);
+		refList.getBehaviourList().add(rtb);
+		
+		ErrorRecorder l=new ErrorRecorder();
+		
+		BehaviourListComparatorRule rule=new BehaviourListComparatorRule();
+		
+		if (rule.compare(context, mainList, refList, l, true) == false) {
+			fail("Comparison failed");
+		}
+		
+		if (l.isValid() == false) {
+			fail(l.invalidMessage());
+		}
+	}
+	
+	public void testCompareSimpleSequence() {
+		
+		ModelReference ref=new ModelReference((String)null);
+		
+		DefaultComparatorContext context=
+					new DefaultComparatorContext(ref, ref, getRules());
+		
+		BehaviourList mainList=new TestBehaviourList();
+		BehaviourList refList=new TestBehaviourList();
+		
+		TestBehaviour1 mtb1=new TestBehaviour1();
+		TestBehaviour1 rtb1=new TestBehaviour1();
+		
+		mtb1.setMatchWith(rtb1);
+		
+		mainList.getBehaviourList().add(mtb1);
+		refList.getBehaviourList().add(rtb1);
+		
+		TestBehaviour1 mtb2=new TestBehaviour1();
+		TestBehaviour1 rtb2=new TestBehaviour1();
+		
+		mtb2.setMatchWith(rtb2);
+		
+		mainList.getBehaviourList().add(mtb2);
+		refList.getBehaviourList().add(rtb2);
+		
+		TestBehaviour1 mtb3=new TestBehaviour1();
+		TestBehaviour1 rtb3=new TestBehaviour1();
+		
+		mtb3.setMatchWith(rtb3);
+		
+		mainList.getBehaviourList().add(mtb3);
+		refList.getBehaviourList().add(rtb3);
+		
+		ErrorRecorder l=new ErrorRecorder();
+		
+		BehaviourListComparatorRule rule=new BehaviourListComparatorRule();
+		
+		if (rule.compare(context, mainList, refList, l, true) == false) {
+			fail("Comparison failed");
+		}
+		
+		if (l.isValid() == false) {
+			fail(l.invalidMessage());
+		}
+	}
+	
+	public void testCompareSimpleComposedSyncSequence() {
+		
+		ModelReference ref=new ModelReference((String)null);
+		
+		DefaultComparatorContext context=
+					new DefaultComparatorContext(ref, ref, getRules());
+		
+		BehaviourList mainList=new TestBehaviourList();
+		BehaviourList refList=new TestBehaviourList();
+		
+		TestBehaviour1 mtb1=new TestBehaviour1();
+		TestBehaviour1 rtb1=new TestBehaviour1();
+		
+		mtb1.setMatchWith(rtb1);
+		
+		mainList.getBehaviourList().add(mtb1);
+		refList.getBehaviourList().add(rtb1);
+		
+		BehaviourList subMainList=new TestBehaviourList();
+		BehaviourList subRefList=new TestBehaviourList();
+		
+		TestBehaviour1 mtb2=new TestBehaviour1();
+		TestBehaviour1 rtb2=new TestBehaviour1();
+		
+		mtb2.setMatchWith(rtb2);
+		
+		subMainList.getBehaviourList().add(mtb2);
+		subRefList.getBehaviourList().add(rtb2);
+		
+		mainList.getBehaviourList().add(subMainList);
+		refList.getBehaviourList().add(subRefList);
+		
+		TestBehaviour1 mtb3=new TestBehaviour1();
+		TestBehaviour1 rtb3=new TestBehaviour1();
+		
+		mtb3.setMatchWith(rtb3);
+		
+		mainList.getBehaviourList().add(mtb3);
+		refList.getBehaviourList().add(rtb3);
+		
+		ErrorRecorder l=new ErrorRecorder();
+		
+		BehaviourListComparatorRule rule=new BehaviourListComparatorRule();
+		
+		if (rule.compare(context, mainList, refList, l, true) == false) {
+			fail("Comparison failed");
+		}
+		
+		if (l.isValid() == false) {
+			fail(l.invalidMessage());
+		}
+	}
+	
+	public void testCompareSimpleComposedSyncSequenceMain() {
+		
+		ModelReference ref=new ModelReference((String)null);
+		
+		DefaultComparatorContext context=
+					new DefaultComparatorContext(ref, ref, getRules());
+		
+		BehaviourList mainList=new TestBehaviourList();
+		BehaviourList refList=new TestBehaviourList();
+		
+		TestBehaviour1 mtb1=new TestBehaviour1();
+		TestBehaviour1 rtb1=new TestBehaviour1();
+		
+		mtb1.setMatchWith(rtb1);
+		
+		mainList.getBehaviourList().add(mtb1);
+		refList.getBehaviourList().add(rtb1);
+		
+		BehaviourList subMainList=new TestBehaviourList();
+		
+		TestBehaviour1 mtb2=new TestBehaviour1();
+		TestBehaviour1 rtb2=new TestBehaviour1();
+		
+		mtb2.setMatchWith(rtb2);
+		
+		subMainList.getBehaviourList().add(mtb2);
+		refList.getBehaviourList().add(rtb2);
+		
+		mainList.getBehaviourList().add(subMainList);
+		
+		TestBehaviour1 mtb3=new TestBehaviour1();
+		TestBehaviour1 rtb3=new TestBehaviour1();
+		
+		mtb3.setMatchWith(rtb3);
+		
+		mainList.getBehaviourList().add(mtb3);
+		refList.getBehaviourList().add(rtb3);
+		
+		ErrorRecorder l=new ErrorRecorder();
+		
+		BehaviourListComparatorRule rule=new BehaviourListComparatorRule();
+		
+		if (rule.compare(context, mainList, refList, l, true) == false) {
+			fail("Comparison failed");
+		}
+		
+		if (l.isValid() == false) {
+			fail(l.invalidMessage());
+		}
+	}
+
+	public void testCompareSimpleComposedSyncSequenceRef() {
+		
+		ModelReference ref=new ModelReference((String)null);
+		
+		DefaultComparatorContext context=
+					new DefaultComparatorContext(ref, ref, getRules());
+		
+		BehaviourList mainList=new TestBehaviourList();
+		BehaviourList refList=new TestBehaviourList();
+		
+		TestBehaviour1 mtb1=new TestBehaviour1();
+		TestBehaviour1 rtb1=new TestBehaviour1();
+		
+		mtb1.setMatchWith(rtb1);
+		
+		mainList.getBehaviourList().add(mtb1);
+		refList.getBehaviourList().add(rtb1);
+		
+		BehaviourList subRefList=new TestBehaviourList();
+		
+		TestBehaviour1 mtb2=new TestBehaviour1();
+		TestBehaviour1 rtb2=new TestBehaviour1();
+		
+		mtb2.setMatchWith(rtb2);
+		
+		mainList.getBehaviourList().add(mtb2);
+		subRefList.getBehaviourList().add(rtb2);
+		
+		refList.getBehaviourList().add(subRefList);
+		
+		TestBehaviour1 mtb3=new TestBehaviour1();
+		TestBehaviour1 rtb3=new TestBehaviour1();
+		
+		mtb3.setMatchWith(rtb3);
+		
+		mainList.getBehaviourList().add(mtb3);
+		refList.getBehaviourList().add(rtb3);
+		
+		ErrorRecorder l=new ErrorRecorder();
+		
+		BehaviourListComparatorRule rule=new BehaviourListComparatorRule();
+		
+		if (rule.compare(context, mainList, refList, l, true) == false) {
+			fail("Comparison failed");
+		}
+		
+		if (l.isValid() == false) {
+			fail(l.invalidMessage());
+		}
+	}
+	
+	public void testCompareMissingMidRef() {
+		
+		Definition maindefn=new Definition() {};
+		Definition refdefn=new Definition() {};
+		
+		Role role=new Role();
+		role.setName("role");
+		
+		LocatedName mn=new LocatedName();
+		mn.setRole(role);
+		
+		maindefn.setLocatedName(mn);
+		refdefn.setLocatedName(mn);
+		
+		ModelReference ref=new ModelReference((String)null);
+		
+		DefaultComparatorContext context=
+					new DefaultComparatorContext(ref, ref, getRules());
+		
+		BehaviourList mainList=new TestBehaviourList();
+		BehaviourList refList=new TestBehaviourList();
+		
+		TestBehaviour1 mtb1=new TestBehaviour1();
+		maindefn.getBlock().getContents().add(mtb1);
+
+		TestBehaviour1 rtb1=new TestBehaviour1();
+		refdefn.getBlock().getContents().add(rtb1);
+
+		mtb1.setMatchWith(rtb1);
+		
+		mainList.getBehaviourList().add(mtb1);
+		refList.getBehaviourList().add(rtb1);
+		
+		TestBehaviour1 mtb2=new TestBehaviour1();
+		maindefn.getBlock().getContents().add(mtb2);
+		
+		mainList.getBehaviourList().add(mtb2);
+		
+		TestBehaviour1 mtb3=new TestBehaviour1();
+		maindefn.getBlock().getContents().add(mtb3);
+		TestBehaviour1 rtb3=new TestBehaviour1();
+		refdefn.getBlock().getContents().add(rtb3);
+		
+		mtb3.setMatchWith(rtb3);
+		
+		mainList.getBehaviourList().add(mtb3);
+		refList.getBehaviourList().add(rtb3);
+		
+		ErrorRecorder l=new ErrorRecorder();
+
+		//l.addExpectedError(TestBehaviourComparatorRule.TEST_BEHAVIOUR_COMPARE_FAILED);
+		
+		l.addExpectedError(org.scribble.util.MessageUtil.format(
+				java.util.PropertyResourceBundle.getBundle(
+						"org.scribble.comparator.Messages").
+						getString("_UNEXPECTED_BEHAVIOUR"), null));
+		
+		BehaviourListComparatorRule rule=new BehaviourListComparatorRule();
+		
+		if (rule.compare(context, mainList, refList, l, true) == true) {
+			fail("Comparison should have failed");
+		}
+		
+		if (l.isValid() == false) {
+			fail(l.invalidMessage());
+		}
+	}
+	
+	public void testCompareMissingConditionalMidRef() {
+		
+		Definition maindefn=new Definition() {};
+		Definition refdefn=new Definition() {};
+		
+		Role role=new Role();
+		role.setName("role");
+		
+		LocatedName mn=new LocatedName();
+		mn.setRole(role);
+		
+		maindefn.setLocatedName(mn);
+		refdefn.setLocatedName(mn);
+		
+		ModelReference ref=new ModelReference((String)null);
+		
+		DefaultComparatorContext context=
+					new DefaultComparatorContext(ref, ref, getRules());
+		
+		BehaviourList mainList=new TestBehaviourList();
+		BehaviourList refList=new TestBehaviourList();
+		
+		TestBehaviour1 mtb1=new TestBehaviour1();
+		maindefn.getBlock().getContents().add(mtb1);
+
+		TestBehaviour1 rtb1=new TestBehaviour1();
+		refdefn.getBlock().getContents().add(rtb1);
+
+		mtb1.setMatchWith(rtb1);
+		
+		mainList.getBehaviourList().add(mtb1);
+		refList.getBehaviourList().add(rtb1);
+		
+		TestSinglePath mtb2=new TestSinglePath();
+		mtb2.setConditional(true);
+		
+		maindefn.getBlock().getContents().add(mtb2);
+		
+		mainList.getBehaviourList().add(mtb2);
+		
+		TestBehaviour1 mtb3=new TestBehaviour1();
+		maindefn.getBlock().getContents().add(mtb3);
+		TestBehaviour1 rtb3=new TestBehaviour1();
+		refdefn.getBlock().getContents().add(rtb3);
+		
+		mtb3.setMatchWith(rtb3);
+		
+		mainList.getBehaviourList().add(mtb3);
+		refList.getBehaviourList().add(rtb3);
+		
+		ErrorRecorder l=new ErrorRecorder();
+
+		//l.addExpectedError(TestBehaviourComparatorRule.TEST_BEHAVIOUR_COMPARE_FAILED);
+		
+		l.addExpectedError(org.scribble.util.MessageUtil.format(
+				java.util.PropertyResourceBundle.getBundle(
+						"org.scribble.comparator.Messages").
+						getString("_UNEXPECTED_BEHAVIOUR"), null));
+		
+		BehaviourListComparatorRule rule=new BehaviourListComparatorRule();
+		
+		if (rule.compare(context, mainList, refList, l, true) == true) {
+			fail("Comparison should have failed");
+		}
+		
+		if (l.isValid() == false) {
+			fail(l.invalidMessage());
+		}
+	}
+	
+	public void testCompareDiffMidBehaviour() {
+		
+		ModelReference ref=new ModelReference((String)null);
+		
+		DefaultComparatorContext context=
+					new DefaultComparatorContext(ref, ref, getRules());
+		
+		BehaviourList mainList=new TestBehaviourList();
+		BehaviourList refList=new TestBehaviourList();
+		
+		TestBehaviour1 mtb1=new TestBehaviour1();
+		TestBehaviour1 rtb1=new TestBehaviour1();
+		
+		mtb1.setMatchWith(rtb1);
+		
+		mainList.getBehaviourList().add(mtb1);
+		refList.getBehaviourList().add(rtb1);
+		
+		TestBehaviour1 mtb2=new TestBehaviour1();
+		TestBehaviour2 rtb2=new TestBehaviour2();
+		
+		mainList.getBehaviourList().add(mtb2);
+		refList.getBehaviourList().add(rtb2);
+		
+		TestBehaviour1 mtb3=new TestBehaviour1();
+		TestBehaviour1 rtb3=new TestBehaviour1();
+		
+		mtb3.setMatchWith(rtb3);
+		
+		mainList.getBehaviourList().add(mtb3);
+		refList.getBehaviourList().add(rtb3);
+		
+		ErrorRecorder l=new ErrorRecorder();
+
+		//l.addExpectedError(TestBehaviourComparatorRule.TEST_BEHAVIOUR_COMPARE_FAILED);
+		
+		l.addExpectedError(org.scribble.util.MessageUtil.format(
+				java.util.PropertyResourceBundle.getBundle(
+						"org.scribble.comparator.Messages").
+						getString("_UNEXPECTED_BEHAVIOUR"), null));
+		l.addExpectedError(org.scribble.util.MessageUtil.format(
+				java.util.PropertyResourceBundle.getBundle(
+				"org.scribble.conformance.comparator.Messages").
+				getString("_EXPECTING_ACTIVITY"), null));
+		
+		BehaviourListComparatorRule rule=new BehaviourListComparatorRule();
+		
+		if (rule.compare(context, mainList, refList, l, true) == true) {
+			fail("Comparison should have failed");
+		}
+		
+		if (l.isValid() == false) {
+			fail(l.invalidMessage());
+		}
+	}
+	
+	public void testCompareMissingMidMain() {
+		
+		Definition maindefn=new Definition() {};
+		Definition refdefn=new Definition() {};
+		
+		Role role=new Role();
+		role.setName("role");
+		
+		LocatedName mn=new LocatedName();
+		mn.setRole(role);
+		
+		maindefn.setLocatedName(mn);
+		refdefn.setLocatedName(mn);
+		
+		ModelReference ref=new ModelReference((String)null);
+		
+		DefaultComparatorContext context=
+					new DefaultComparatorContext(ref, ref, getRules());
+		
+		BehaviourList mainList=new TestBehaviourList();
+		BehaviourList refList=new TestBehaviourList();
+		
+		TestBehaviour1 mtb1=new TestBehaviour1();
+		maindefn.getBlock().getContents().add(mtb1);
+
+		TestBehaviour1 rtb1=new TestBehaviour1();
+		refdefn.getBlock().getContents().add(rtb1);
+
+		mtb1.setMatchWith(rtb1);
+		
+		mainList.getBehaviourList().add(mtb1);
+		refList.getBehaviourList().add(rtb1);
+		
+		TestBehaviour1 rtb2=new TestBehaviour1();
+		refdefn.getBlock().getContents().add(rtb2);
+		
+		refList.getBehaviourList().add(rtb2);
+		
+		TestBehaviour1 mtb3=new TestBehaviour1();
+		maindefn.getBlock().getContents().add(mtb3);
+		TestBehaviour1 rtb3=new TestBehaviour1();
+		refdefn.getBlock().getContents().add(rtb3);
+		
+		mtb3.setMatchWith(rtb3);
+		
+		mainList.getBehaviourList().add(mtb3);
+		refList.getBehaviourList().add(rtb3);
+		
+		ErrorRecorder l=new ErrorRecorder();
+		
+		//l.addExpectedError(TestBehaviourComparatorRule.TEST_BEHAVIOUR_COMPARE_FAILED);
+		
+		l.addExpectedError(org.scribble.util.MessageUtil.format(
+							java.util.PropertyResourceBundle.getBundle(
+							"org.scribble.conformance.comparator.Messages").
+							getString("_EXPECTING_ACTIVITY"), null));
+		
+		BehaviourListComparatorRule rule=new BehaviourListComparatorRule();
+		
+		if (rule.compare(context, mainList, refList, l, true) == true) {
+			fail("Comparison should have failed");
+		}
+		
+		if (l.isValid() == false) {
+			fail(l.invalidMessage());
+		}
+	}
+	
+	public void testCompareMissingConditionalMidMain() {
+		
+		Definition maindefn=new Definition() {};
+		Definition refdefn=new Definition() {};
+		
+		Role role=new Role();
+		role.setName("role");
+		
+		LocatedName mn=new LocatedName();
+		mn.setRole(role);
+		
+		maindefn.setLocatedName(mn);
+		refdefn.setLocatedName(mn);
+		
+		ModelReference ref=new ModelReference((String)null);
+		
+		DefaultComparatorContext context=
+					new DefaultComparatorContext(ref, ref, getRules());
+		
+		BehaviourList mainList=new TestBehaviourList();
+		BehaviourList refList=new TestBehaviourList();
+		
+		TestBehaviour1 mtb1=new TestBehaviour1();
+		maindefn.getBlock().getContents().add(mtb1);
+
+		TestBehaviour1 rtb1=new TestBehaviour1();
+		refdefn.getBlock().getContents().add(rtb1);
+
+		mtb1.setMatchWith(rtb1);
+		
+		mainList.getBehaviourList().add(mtb1);
+		refList.getBehaviourList().add(rtb1);
+		
+		TestSinglePath rtb2=new TestSinglePath();
+		rtb2.setConditional(true);
+		refdefn.getBlock().getContents().add(rtb2);
+		
+		refList.getBehaviourList().add(rtb2);
+		
+		TestBehaviour1 mtb3=new TestBehaviour1();
+		maindefn.getBlock().getContents().add(mtb3);
+		TestBehaviour1 rtb3=new TestBehaviour1();
+		refdefn.getBlock().getContents().add(rtb3);
+		
+		mtb3.setMatchWith(rtb3);
+		
+		mainList.getBehaviourList().add(mtb3);
+		refList.getBehaviourList().add(rtb3);
+		
+		ErrorRecorder l=new ErrorRecorder();
+		
+		//l.addExpectedError(TestBehaviourComparatorRule.TEST_BEHAVIOUR_COMPARE_FAILED);
+		
+		l.addExpectedError(org.scribble.util.MessageUtil.format(
+							java.util.PropertyResourceBundle.getBundle(
+							"org.scribble.conformance.comparator.Messages").
+							getString("_EXPECTING_ACTIVITY"), null));
+		
+		BehaviourListComparatorRule rule=new BehaviourListComparatorRule();
+		
+		if (rule.compare(context, mainList, refList, l, true) == true) {
+			fail("Comparison should have failed");
+		}
+		
+		if (l.isValid() == false) {
+			fail(l.invalidMessage());
+		}
+	}
+	
+	public void testCompareMissingEndRef() {
+		
+		ModelReference ref=new ModelReference((String)null);
+		
+		DefaultComparatorContext context=
+					new DefaultComparatorContext(ref, ref, getRules());
+		
+		BehaviourList mainList=new TestBehaviourList();
+		BehaviourList refList=new TestBehaviourList();
+		
+		TestBehaviour1 mtb1=new TestBehaviour1();
+		TestBehaviour1 rtb1=new TestBehaviour1();
+		
+		mtb1.setMatchWith(rtb1);
+		
+		mainList.getBehaviourList().add(mtb1);
+		refList.getBehaviourList().add(rtb1);
+		
+		TestBehaviour1 mtb2=new TestBehaviour1();
+		TestBehaviour1 rtb2=new TestBehaviour1();
+		
+		mtb2.setMatchWith(rtb2);
+		
+		mainList.getBehaviourList().add(mtb2);
+		refList.getBehaviourList().add(rtb2);
+				
+		TestBehaviour1 mtb3=new TestBehaviour1();
+		
+		mainList.getBehaviourList().add(mtb3);
+		
+		ErrorRecorder l=new ErrorRecorder();
+
+		//l.addExpectedError(TestBehaviourComparatorRule.TEST_BEHAVIOUR_COMPARE_FAILED);
+		
+		l.addExpectedError(org.scribble.util.MessageUtil.format(
+				java.util.PropertyResourceBundle.getBundle(
+						"org.scribble.comparator.Messages").
+						getString("_UNEXPECTED_BEHAVIOUR"), null));
+		
+		BehaviourListComparatorRule rule=new BehaviourListComparatorRule();
+		
+		if (rule.compare(context, mainList, refList, l, true) == true) {
+			fail("Comparison should have failed");
+		}
+		
+		if (l.isValid() == false) {
+			fail(l.invalidMessage());
+		}
+	}
+	
+	public void testCompareMissingEndMain() {
+		
+		ModelReference ref=new ModelReference((String)null);
+		
+		DefaultComparatorContext context=
+					new DefaultComparatorContext(ref, ref, getRules());
+
+		BehaviourList mainList=new TestBehaviourList();
+		BehaviourList refList=new TestBehaviourList();
+		
+		TestBehaviour1 mtb1=new TestBehaviour1();
+		TestBehaviour1 rtb1=new TestBehaviour1();
+		
+		mtb1.setMatchWith(rtb1);
+		
+		mainList.getBehaviourList().add(mtb1);
+		refList.getBehaviourList().add(rtb1);
+		
+		TestBehaviour1 mtb2=new TestBehaviour1();
+		TestBehaviour1 rtb2=new TestBehaviour1();
+		
+		mtb2.setMatchWith(rtb2);
+		
+		mainList.getBehaviourList().add(mtb2);
+		refList.getBehaviourList().add(rtb2);
+				
+		TestBehaviour1 rtb3=new TestBehaviour1();
+		
+		refList.getBehaviourList().add(rtb3);
+		
+		ErrorRecorder l=new ErrorRecorder();
+
+		//l.addExpectedError(TestBehaviourComparatorRule.TEST_BEHAVIOUR_COMPARE_FAILED);
+		
+		l.addExpectedError(org.scribble.util.MessageUtil.format(
+				java.util.PropertyResourceBundle.getBundle(
+				"org.scribble.conformance.comparator.Messages").
+				getString("_EXPECTING_ACTIVITY"), null));
+		
+		BehaviourListComparatorRule rule=new BehaviourListComparatorRule();
+		
+		if (rule.compare(context, mainList, refList, l, true) == true) {
+			fail("Comparison should have failed");
+		}
+		
+		if (l.isValid() == false) {
+			fail(l.invalidMessage());
+		}
+	}
+	
+	public void testCompareMismatchMidBehaviour() {
+		
+		ModelReference ref=new ModelReference((String)null);
+		
+		DefaultComparatorContext context=
+					new DefaultComparatorContext(ref, ref, getRules());
+		
+		BehaviourList mainList=new TestBehaviourList();
+		BehaviourList refList=new TestBehaviourList();
+		
+		TestBehaviour1 mtb1=new TestBehaviour1();
+		TestBehaviour1 rtb1=new TestBehaviour1();
+		
+		mtb1.setMatchWith(rtb1);
+		
+		mainList.getBehaviourList().add(mtb1);
+		refList.getBehaviourList().add(rtb1);
+		
+		TestBehaviour1 mtb2=new TestBehaviour1();
+		TestBehaviour1 rtb2=new TestBehaviour1();
+		
+		//mtb2.setMatchWith(rtb2);
+		
+		mainList.getBehaviourList().add(mtb2);
+		refList.getBehaviourList().add(rtb2);
+		
+		TestBehaviour1 mtb3=new TestBehaviour1();
+		TestBehaviour1 rtb3=new TestBehaviour1();
+		
+		mtb3.setMatchWith(rtb3);
+		
+		mainList.getBehaviourList().add(mtb3);
+		refList.getBehaviourList().add(rtb3);
+		
+		ErrorRecorder l=new ErrorRecorder();
+		
+		l.addExpectedError(TestBehaviour1ComparatorRule.TEST_BEHAVIOUR_COMPARE_FAILED);
+		
+		BehaviourListComparatorRule rule=new BehaviourListComparatorRule();
+		
+		if (rule.compare(context, mainList, refList, l, true) == true) {
+			fail("Comparison should have failed");
+		}
+		
+		if (l.isValid() == false) {
+			fail(l.invalidMessage());
+		}
+	}
+	
+	public void testCompareMismatchStartBehaviour() {
+		
+		ModelReference ref=new ModelReference((String)null);
+		
+		DefaultComparatorContext context=
+					new DefaultComparatorContext(ref, ref, getRules());
+		
+		BehaviourList mainList=new TestBehaviourList();
+		BehaviourList refList=new TestBehaviourList();
+		
+		TestBehaviour1 mtb1=new TestBehaviour1();
+		TestBehaviour1 rtb1=new TestBehaviour1();
+		
+		//mtb1.setMatchWith(rtb1);
+		
+		mainList.getBehaviourList().add(mtb1);
+		refList.getBehaviourList().add(rtb1);
+		
+		TestBehaviour1 mtb2=new TestBehaviour1();
+		TestBehaviour1 rtb2=new TestBehaviour1();
+		
+		//mtb2.setMatchWith(rtb2);
+		
+		mainList.getBehaviourList().add(mtb2);
+		refList.getBehaviourList().add(rtb2);
+		
+		TestBehaviour1 mtb3=new TestBehaviour1();
+		TestBehaviour1 rtb3=new TestBehaviour1();
+		
+		mtb3.setMatchWith(rtb3);
+		
+		mainList.getBehaviourList().add(mtb3);
+		refList.getBehaviourList().add(rtb3);
+		
+		ErrorRecorder l=new ErrorRecorder();
+		
+		l.addExpectedError(TestBehaviour1ComparatorRule.TEST_BEHAVIOUR_COMPARE_FAILED);
+		l.addExpectedError(TestBehaviour1ComparatorRule.TEST_BEHAVIOUR_COMPARE_FAILED);
+		
+		BehaviourListComparatorRule rule=new BehaviourListComparatorRule();
+		
+		if (rule.compare(context, mainList, refList, l, true) == true) {
+			fail("Comparison should have failed");
+		}
+		
+		if (l.isValid() == false) {
+			fail(l.invalidMessage());
+		}
+	}
+	
+	public void testCompareSameMidNonStrictSinglePath() {
+		
+		ModelReference ref=new ModelReference((String)null);
+		
+		DefaultComparatorContext context=
+					new DefaultComparatorContext(ref, ref, getRules());
+		
+		BehaviourList mainList=new TestBehaviourList();
+		BehaviourList refList=new TestBehaviourList();
+		
+		TestBehaviour1 mtb1=new TestBehaviour1();
+		TestBehaviour1 rtb1=new TestBehaviour1();
+		
+		mtb1.setMatchWith(rtb1);
+		
+		mainList.getBehaviourList().add(mtb1);
+		refList.getBehaviourList().add(rtb1);
+		
+		TestSinglePath mtsp=new TestSinglePath();
+		TestSinglePath rtsp=new TestSinglePath();
+		
+		//mainList.getBehaviourList().add(mtsp);
+		//refList.getBehaviourList().add(rtsp);
+
+		TestBehaviour1 mtb2=new TestBehaviour1();
+		TestBehaviour1 rtb2=new TestBehaviour1();
+		
+		mtb2.setMatchWith(rtb2);
+		
+		mtsp.getBlock().getContents().add(mtb2);
+		rtsp.getBlock().getContents().add(rtb2);
+
+		mainList.visit(mtsp);
+		refList.visit(rtsp);
+		
+		TestBehaviour1 mtb3=new TestBehaviour1();
+		TestBehaviour1 rtb3=new TestBehaviour1();
+		
+		mtb3.setMatchWith(rtb3);
+		
+		mainList.getBehaviourList().add(mtb3);
+		refList.getBehaviourList().add(rtb3);
+		
+		ErrorRecorder l=new ErrorRecorder();
+		
+		BehaviourListComparatorRule rule=new BehaviourListComparatorRule();
+		
+		if (rule.compare(context, mainList, refList, l, true) == false) {
+			fail("Comparison should NOT have failed");
+		}
+		
+		if (l.isValid() == false) {
+			fail(l.invalidMessage());
+		}
+	}
+
+	public void testCompareSameMidStrictSinglePath() {
+		
+		ModelReference ref=new ModelReference((String)null);
+		
+		DefaultComparatorContext context=
+					new DefaultComparatorContext(ref, ref, getRules());
+		
+		BehaviourList mainList=new TestBehaviourList();
+		BehaviourList refList=new TestBehaviourList();
+		
+		TestBehaviour1 mtb1=new TestBehaviour1();
+		TestBehaviour1 rtb1=new TestBehaviour1();
+		
+		mtb1.setMatchWith(rtb1);
+		
+		mainList.getBehaviourList().add(mtb1);
+		refList.getBehaviourList().add(rtb1);
+		
+		TestSinglePath mtsp=new TestSinglePath();
+		mtsp.setStrictScope(true);
+		TestSinglePath rtsp=new TestSinglePath();
+		rtsp.setStrictScope(true);
+		
+		//mainList.getBehaviourList().add(mtsp);
+		//refList.getBehaviourList().add(rtsp);
+
+		TestBehaviour1 mtb2=new TestBehaviour1();
+		TestBehaviour1 rtb2=new TestBehaviour1();
+		
+		mtb2.setMatchWith(rtb2);
+		
+		mtsp.getBlock().getContents().add(mtb2);
+		rtsp.getBlock().getContents().add(rtb2);
+		
+		mainList.visit(mtsp);
+		refList.visit(rtsp);
+
+		TestBehaviour1 mtb3=new TestBehaviour1();
+		TestBehaviour1 rtb3=new TestBehaviour1();
+		
+		mtb3.setMatchWith(rtb3);
+		
+		mainList.getBehaviourList().add(mtb3);
+		refList.getBehaviourList().add(rtb3);
+		
+		ErrorRecorder l=new ErrorRecorder();
+		
+		BehaviourListComparatorRule rule=new BehaviourListComparatorRule();
+		
+		if (rule.compare(context, mainList, refList, l, true) == false) {
+			fail("Comparison should NOT have failed");
+		}
+		
+		if (l.isValid() == false) {
+			fail(l.invalidMessage());
+		}
+	}
+
+	public void testCompareDiffMidNonStrictSinglePath() {
+		
+		ModelReference ref=new ModelReference((String)null);
+		
+		DefaultComparatorContext context=
+					new DefaultComparatorContext(ref, ref, getRules());
+		
+		BehaviourList mainList=new TestBehaviourList();
+		BehaviourList refList=new TestBehaviourList();
+		
+		TestBehaviour1 mtb1=new TestBehaviour1();
+		TestBehaviour1 rtb1=new TestBehaviour1();
+		
+		mtb1.setMatchWith(rtb1);
+		
+		mainList.getBehaviourList().add(mtb1);
+		refList.getBehaviourList().add(rtb1);
+		
+		TestSinglePath mtsp=new TestSinglePath();
+		TestSinglePath rtsp=new TestSinglePath();
+		
+		//mainList.getBehaviourList().add(mtsp);
+		//refList.getBehaviourList().add(rtsp);
+
+		TestBehaviour1 mtb2=new TestBehaviour1();
+		TestBehaviour1 rtb2=new TestBehaviour1();
+		
+		//mtb2.setMatchWith(rtb2);
+		
+		mtsp.getBlock().getContents().add(mtb2);
+		rtsp.getBlock().getContents().add(rtb2);
+		
+		mainList.visit(mtsp);
+		refList.visit(rtsp);
+
+		TestBehaviour1 mtb3=new TestBehaviour1();
+		TestBehaviour1 rtb3=new TestBehaviour1();
+		
+		mtb3.setMatchWith(rtb3);
+		
+		mainList.getBehaviourList().add(mtb3);
+		refList.getBehaviourList().add(rtb3);
+		
+		ErrorRecorder l=new ErrorRecorder();
+		
+		l.addExpectedError(TestBehaviour1ComparatorRule.TEST_BEHAVIOUR_COMPARE_FAILED);
+		
+		BehaviourListComparatorRule rule=new BehaviourListComparatorRule();
+		
+		if (rule.compare(context, mainList, refList, l, true) == true) {
+			fail("Comparison should have failed");
+		}
+		
+		if (l.isValid() == false) {
+			fail(l.invalidMessage());
+		}
+	}
+
+	public void testCompareDiffMidStrictSinglePath() {
+		
+		ModelReference ref=new ModelReference((String)null);
+		
+		DefaultComparatorContext context=
+					new DefaultComparatorContext(ref, ref, getRules());
+		
+		BehaviourList mainList=new TestBehaviourList();
+		BehaviourList refList=new TestBehaviourList();
+		
+		TestBehaviour1 mtb1=new TestBehaviour1();
+		TestBehaviour1 rtb1=new TestBehaviour1();
+		
+		mtb1.setMatchWith(rtb1);
+		
+		mainList.getBehaviourList().add(mtb1);
+		refList.getBehaviourList().add(rtb1);
+		
+		TestSinglePath mtsp=new TestSinglePath();
+		mtsp.setStrictScope(true);
+		TestSinglePath rtsp=new TestSinglePath();
+		rtsp.setStrictScope(true);
+		
+		//mainList.getBehaviourList().add(mtsp);
+		//refList.getBehaviourList().add(rtsp);
+
+		TestBehaviour1 mtb2=new TestBehaviour1();
+		TestBehaviour1 rtb2=new TestBehaviour1();
+		
+		//mtb2.setMatchWith(rtb2);
+		
+		mtsp.getBlock().getContents().add(mtb2);
+		rtsp.getBlock().getContents().add(rtb2);
+		
+		mainList.visit(mtsp);
+		refList.visit(rtsp);
+
+		TestBehaviour1 mtb3=new TestBehaviour1();
+		TestBehaviour1 rtb3=new TestBehaviour1();
+		
+		mtb3.setMatchWith(rtb3);
+		
+		mainList.getBehaviourList().add(mtb3);
+		refList.getBehaviourList().add(rtb3);
+		
+		ErrorRecorder l=new ErrorRecorder();
+		
+		l.addExpectedError(TestBehaviour1ComparatorRule.TEST_BEHAVIOUR_COMPARE_FAILED);
+		
+		BehaviourListComparatorRule rule=new BehaviourListComparatorRule();
+		
+		if (rule.compare(context, mainList, refList, l, true) == true) {
+			fail("Comparison should have failed");
+		}
+		
+		if (l.isValid() == false) {
+			fail(l.invalidMessage());
+		}
+	}
+
+	public void testCompareMultipleDiffMidEndWithSinglePath() {
+		
+		ModelReference ref=new ModelReference((String)null);
+		
+		DefaultComparatorContext context=
+					new DefaultComparatorContext(ref, ref, getRules());
+		
+		BehaviourList mainList=new TestBehaviourList();
+		BehaviourList refList=new TestBehaviourList();
+		
+		TestBehaviour1 mtb1=new TestBehaviour1();
+		TestBehaviour1 rtb1=new TestBehaviour1();
+		
+		mtb1.setMatchWith(rtb1);
+		
+		mainList.getBehaviourList().add(mtb1);
+		refList.getBehaviourList().add(rtb1);
+		
+		TestBehaviour1 mtb1_1=new TestBehaviour1();
+		TestBehaviour1 rtb1_1=new TestBehaviour1();
+		
+		mainList.getBehaviourList().add(mtb1_1);
+		refList.getBehaviourList().add(rtb1_1);
+
+		TestBehaviour1 mtb1_2=new TestBehaviour1();
+		TestBehaviour1 rtb1_2=new TestBehaviour1();
+		
+		mainList.getBehaviourList().add(mtb1_2);
+		refList.getBehaviourList().add(rtb1_2);
+
+		TestSinglePath mtsp=new TestSinglePath();
+		mtsp.setStrictScope(true);
+		TestSinglePath rtsp=new TestSinglePath();
+		rtsp.setStrictScope(true);
+		
+		//mainList.getBehaviourList().add(mtsp);
+		//refList.getBehaviourList().add(rtsp);
+
+		TestBehaviour1 mtb2=new TestBehaviour1();
+		TestBehaviour1 rtb2=new TestBehaviour1();
+		
+		mtb2.setMatchWith(rtb2);
+		
+		mtsp.getBlock().getContents().add(mtb2);
+		rtsp.getBlock().getContents().add(rtb2);
+		
+		mainList.visit(mtsp);
+		refList.visit(rtsp);
+
+		TestBehaviour1 mtb3=new TestBehaviour1();
+		TestBehaviour1 rtb3=new TestBehaviour1();
+		
+		mtb3.setMatchWith(rtb3);
+		
+		mainList.getBehaviourList().add(mtb3);
+		refList.getBehaviourList().add(rtb3);
+		
+		ErrorRecorder l=new ErrorRecorder();
+		
+		l.addExpectedError(TestBehaviour1ComparatorRule.TEST_BEHAVIOUR_COMPARE_FAILED);
+		l.addExpectedError(TestBehaviour1ComparatorRule.TEST_BEHAVIOUR_COMPARE_FAILED);
+		
+		BehaviourListComparatorRule rule=new BehaviourListComparatorRule();
+		
+		if (rule.compare(context, mainList, refList, l, true) == true) {
+			fail("Comparison should have failed");
+		}
+		
+		if (l.isValid() == false) {
+			fail(l.invalidMessage());
+		}
+	}
+
+	public void testCompareMultipleSameMidEndWithMultiPath() {
+		
+		ModelReference ref=new ModelReference((String)null);
+		
+		DefaultComparatorContext context=
+					new DefaultComparatorContext(ref, ref, getRules());
+		
+		BehaviourList mainList=new TestBehaviourList();
+		BehaviourList refList=new TestBehaviourList();
+		
+		TestBehaviour1 mtb1=new TestBehaviour1();
+		TestBehaviour1 rtb1=new TestBehaviour1();
+		
+		mtb1.setMatchWith(rtb1);
+		
+		mainList.getBehaviourList().add(mtb1);
+		refList.getBehaviourList().add(rtb1);
+		
+		TestMultiPath mtmp=new TestMultiPath();
+		mtmp.setStrictScope(true);
+		TestMultiPath rtmp=new TestMultiPath();
+		rtmp.setStrictScope(true);
+		
+		//mainList.getBehaviourList().add(mtsp);
+		//refList.getBehaviourList().add(rtsp);
+
+		TestBehaviour1 mtb2_1=new TestBehaviour1();
+		TestBehaviour1 rtb2_1=new TestBehaviour1();
+		
+		mtb2_1.setMatchWith(rtb2_1);
+		
+		Block bmtb2_1=new Block();
+		bmtb2_1.getContents().add(mtb2_1);
+		
+		Block brtb2_1=new Block();
+		brtb2_1.getContents().add(rtb2_1);
+		
+		mtmp.getPaths().add(bmtb2_1);
+		rtmp.getPaths().add(brtb2_1);
+		
+		TestBehaviour1 mtb2_2=new TestBehaviour1();
+		TestBehaviour1 rtb2_2=new TestBehaviour1();
+		
+		mtb2_2.setMatchWith(rtb2_2);
+		
+		Block bmtb2_2=new Block();
+		bmtb2_2.getContents().add(mtb2_2);
+		
+		Block brtb2_2=new Block();
+		brtb2_2.getContents().add(rtb2_2);
+		
+		mtmp.getPaths().add(bmtb2_2);
+		rtmp.getPaths().add(brtb2_2);
+		
+		mainList.visit(mtmp);
+		refList.visit(rtmp);
+
+		TestBehaviour1 mtb3=new TestBehaviour1();
+		TestBehaviour1 rtb3=new TestBehaviour1();
+		
+		mtb3.setMatchWith(rtb3);
+		
+		mainList.getBehaviourList().add(mtb3);
+		refList.getBehaviourList().add(rtb3);
+		
+		ErrorRecorder l=new ErrorRecorder();
+		
+		//l.addExpectedError(TestBehaviourComparatorRule.TEST_BEHAVIOUR_COMPARE_FAILED);
+		//l.addExpectedError(TestBehaviourComparatorRule.TEST_BEHAVIOUR_COMPARE_FAILED);
+		
+		BehaviourListComparatorRule rule=new BehaviourListComparatorRule();
+		
+		if (rule.compare(context, mainList, refList, l, true) == false) {
+			fail("Comparison should NOT have failed");
+		}
+		
+		if (l.isValid() == false) {
+			fail(l.invalidMessage());
+		}
+	}
+
+	public void testCompareMultipleDiffMidEndWithMultiPath() {
+		
+		ModelReference ref=new ModelReference((String)null);
+		
+		DefaultComparatorContext context=
+					new DefaultComparatorContext(ref, ref, getRules());
+		
+		BehaviourList mainList=new TestBehaviourList();
+		BehaviourList refList=new TestBehaviourList();
+		
+		TestBehaviour1 mtb1=new TestBehaviour1();
+		TestBehaviour1 rtb1=new TestBehaviour1();
+		
+		mtb1.setMatchWith(rtb1);
+		
+		mainList.getBehaviourList().add(mtb1);
+		refList.getBehaviourList().add(rtb1);
+		
+		TestBehaviour1 mtb1_1=new TestBehaviour1();
+		TestBehaviour1 rtb1_1=new TestBehaviour1();
+		
+		mainList.getBehaviourList().add(mtb1_1);
+		refList.getBehaviourList().add(rtb1_1);
+
+		TestBehaviour1 mtb1_2=new TestBehaviour1();
+		TestBehaviour1 rtb1_2=new TestBehaviour1();
+		
+		mainList.getBehaviourList().add(mtb1_2);
+		refList.getBehaviourList().add(rtb1_2);
+		
+		TestMultiPath mtmp=new TestMultiPath();
+		mtmp.setStrictScope(true);
+		TestMultiPath rtmp=new TestMultiPath();
+		rtmp.setStrictScope(true);
+		
+		//mainList.getBehaviourList().add(mtsp);
+		//refList.getBehaviourList().add(rtsp);
+
+		TestBehaviour1 mtb2_1=new TestBehaviour1();
+		TestBehaviour1 rtb2_1=new TestBehaviour1();
+		
+		mtb2_1.setMatchWith(rtb2_1);
+		
+		Block bmtb2_1=new Block();
+		bmtb2_1.getContents().add(mtb2_1);
+		
+		Block brtb2_1=new Block();
+		brtb2_1.getContents().add(rtb2_1);
+		
+		mtmp.getPaths().add(bmtb2_1);
+		rtmp.getPaths().add(brtb2_1);
+		
+		TestBehaviour1 mtb2_2=new TestBehaviour1();
+		TestBehaviour1 rtb2_2=new TestBehaviour1();
+		
+		mtb2_2.setMatchWith(rtb2_2);
+		
+		Block bmtb2_2=new Block();
+		bmtb2_2.getContents().add(mtb2_2);
+		
+		Block brtb2_2=new Block();
+		brtb2_2.getContents().add(rtb2_2);
+		
+		mtmp.getPaths().add(bmtb2_2);
+		rtmp.getPaths().add(brtb2_2);
+		
+		mainList.visit(mtmp);
+		refList.visit(rtmp);
+
+		TestBehaviour1 mtb3=new TestBehaviour1();
+		TestBehaviour1 rtb3=new TestBehaviour1();
+		
+		mtb3.setMatchWith(rtb3);
+		
+		mainList.getBehaviourList().add(mtb3);
+		refList.getBehaviourList().add(rtb3);
+		
+		ErrorRecorder l=new ErrorRecorder();
+		
+		l.addExpectedError(TestBehaviour1ComparatorRule.TEST_BEHAVIOUR_COMPARE_FAILED);
+		l.addExpectedError(TestBehaviour1ComparatorRule.TEST_BEHAVIOUR_COMPARE_FAILED);
+		
+		BehaviourListComparatorRule rule=new BehaviourListComparatorRule();
+		
+		if (rule.compare(context, mainList, refList, l, true) == true) {
+			fail("Comparison should have failed");
+		}
+		
+		if (l.isValid() == false) {
+			fail(l.invalidMessage());
+		}
+	}
+
+	public void testCompareMultipleDiffInMultiPath() {
+		
+		ModelReference ref=new ModelReference((String)null);
+		
+		DefaultComparatorContext context=
+					new DefaultComparatorContext(ref, ref, getRules());
+		
+		BehaviourList mainList=new TestBehaviourList();
+		BehaviourList refList=new TestBehaviourList();
+		
+		TestBehaviour1 mtb1=new TestBehaviour1();
+		TestBehaviour1 rtb1=new TestBehaviour1();
+		
+		mtb1.setMatchWith(rtb1);
+		
+		mainList.getBehaviourList().add(mtb1);
+		refList.getBehaviourList().add(rtb1);
+		
+		TestMultiPath mtmp=new TestMultiPath();
+		mtmp.setStrictScope(true);
+		TestMultiPath rtmp=new TestMultiPath();
+		rtmp.setStrictScope(true);
+		
+		//mainList.getBehaviourList().add(mtsp);
+		//refList.getBehaviourList().add(rtsp);
+
+		TestBehaviour1 mtb2_1=new TestBehaviour1();
+		TestBehaviour1 rtb2_1=new TestBehaviour1();
+		
+		mtb2_1.setMatchWith(rtb2_1);
+		
+		Block bmtb2_1=new Block();
+		bmtb2_1.getContents().add(mtb2_1);
+		
+		Block brtb2_1=new Block();
+		brtb2_1.getContents().add(rtb2_1);
+		
+		mtmp.getPaths().add(bmtb2_1);
+		rtmp.getPaths().add(brtb2_1);
+		
+		TestBehaviour1 mtb2_2=new TestBehaviour1();
+		TestBehaviour1 rtb2_2=new TestBehaviour1();
+		
+		//mtb2_2.setMatchWith(rtb2_2);
+		
+		Block bmtb2_2=new Block();
+		bmtb2_2.getContents().add(mtb2_2);
+		
+		Block brtb2_2=new Block();
+		brtb2_2.getContents().add(rtb2_2);
+		
+		mtmp.getPaths().add(bmtb2_2);
+		rtmp.getPaths().add(brtb2_2);
+		
+		mainList.visit(mtmp);
+		refList.visit(rtmp);
+
+		TestBehaviour1 mtb3=new TestBehaviour1();
+		TestBehaviour1 rtb3=new TestBehaviour1();
+		
+		mtb3.setMatchWith(rtb3);
+		
+		mainList.getBehaviourList().add(mtb3);
+		refList.getBehaviourList().add(rtb3);
+		
+		ErrorRecorder l=new ErrorRecorder();
+		
+		l.addExpectedError(TestBehaviour1ComparatorRule.TEST_BEHAVIOUR_COMPARE_FAILED);
+		
+		BehaviourListComparatorRule rule=new BehaviourListComparatorRule();
+		
+		if (rule.compare(context, mainList, refList, l, true) == true) {
+			fail("Comparison should have failed");
+		}
+		
+		if (l.isValid() == false) {
+			fail(l.invalidMessage());
+		}
+	}
+
+	public void testCompareAdditionalMainPathInMultiPath() {
+		
+		Definition maindefn=new Definition() {};
+		Definition refdefn=new Definition() {};
+		
+		Role role=new Role();
+		role.setName("role");
+		
+		LocatedName mn=new LocatedName();
+		mn.setRole(role);
+		
+		maindefn.setLocatedName(mn);
+		refdefn.setLocatedName(mn);
+		
+		ModelReference ref=new ModelReference((String)null);
+		
+		DefaultComparatorContext context=
+					new DefaultComparatorContext(ref, ref, getRules());
+		
+		BehaviourList mainList=new TestBehaviourList();
+		BehaviourList refList=new TestBehaviourList();
+		
+		TestMultiPath mtmp=new TestMultiPath();
+		mtmp.setStrictScope(true);
+		mtmp.setMutuallyExclusivePaths(true);
+		maindefn.getBlock().getContents().add(mtmp);
+
+		TestMultiPath rtmp=new TestMultiPath();
+		rtmp.setStrictScope(true);
+		rtmp.setMutuallyExclusivePaths(true);
+		refdefn.getBlock().getContents().add(rtmp);
+		
+		TestBehaviour1 mtb2_1=new TestBehaviour1();
+		TestBehaviour1 rtb2_1=new TestBehaviour1();
+		
+		mtb2_1.setMatchWith(rtb2_1);
+		
+		Block bmtb2_1=new Block();
+		bmtb2_1.getContents().add(mtb2_1);
+		
+		Block brtb2_1=new Block();
+		brtb2_1.getContents().add(rtb2_1);
+		
+		mtmp.getPaths().add(bmtb2_1);
+		rtmp.getPaths().add(brtb2_1);
+		
+		TestBehaviour1 mtb2_2=new TestBehaviour1();
+		//TestBehaviour1 rtb2_2=new TestBehaviour1();
+		
+		//mtb2_2.setMatchWith(rtb2_2);
+		
+		Block bmtb2_2=new Block();
+		bmtb2_2.getContents().add(mtb2_2);
+		
+		//Block brtb2_2=new Block();
+		//brtb2_2.getContents().add(rtb2_2);
+		
+		mtmp.getPaths().add(bmtb2_2);
+		//rtmp.getPaths().add(brtb2_2);
+		
+		TestBehaviour1 mtb2_3=new TestBehaviour1();
+		TestBehaviour1 rtb2_3=new TestBehaviour1();
+		
+		mtb2_3.setMatchWith(rtb2_3);
+		
+		Block bmtb2_3=new Block();
+		bmtb2_3.getContents().add(mtb2_3);
+		
+		Block brtb2_3=new Block();
+		brtb2_3.getContents().add(rtb2_3);
+		
+		mtmp.getPaths().add(bmtb2_3);
+		rtmp.getPaths().add(brtb2_3);
+		
+		mainList.visit(mtmp);
+		refList.visit(rtmp);
+
+		ErrorRecorder l=new ErrorRecorder();
+		
+		l.addExpectedError(java.util.PropertyResourceBundle.getBundle(
+		"org.scribble.conformance.comparator.Messages").
+		getString("_ADDITIONAL_UNMATCHED_PATHS"));
+		
+		BehaviourListComparatorRule rule=new BehaviourListComparatorRule();
+		
+		if (rule.compare(context, mainList, refList, l, true) == true) {
+			fail("Comparison should have failed");
+		}
+		
+		if (l.isValid() == false) {
+			fail(l.invalidMessage());
+		}
+	}
+
+	public void testCompareAdditionalRefPathInMultiPath() {
+		
+		Definition maindefn=new Definition() {};
+		Definition refdefn=new Definition() {};
+		
+		Role role=new Role();
+		role.setName("role");
+		
+		LocatedName mn=new LocatedName();
+		mn.setRole(role);
+		
+		maindefn.setLocatedName(mn);
+		refdefn.setLocatedName(mn);
+		
+		ModelReference ref=new ModelReference((String)null);
+		
+		DefaultComparatorContext context=
+					new DefaultComparatorContext(ref, ref, getRules());
+		
+		BehaviourList mainList=new TestBehaviourList();
+		BehaviourList refList=new TestBehaviourList();
+		
+		TestMultiPath mtmp=new TestMultiPath();
+		mtmp.setStrictScope(true);
+		mtmp.setMutuallyExclusivePaths(true);
+		maindefn.getBlock().getContents().add(mtmp);
+
+		TestMultiPath rtmp=new TestMultiPath();
+		rtmp.setStrictScope(true);
+		rtmp.setMutuallyExclusivePaths(true);
+		refdefn.getBlock().getContents().add(rtmp);
+		
+		TestBehaviour1 mtb2_1=new TestBehaviour1();
+		TestBehaviour1 rtb2_1=new TestBehaviour1();
+		
+		mtb2_1.setMatchWith(rtb2_1);
+		
+		Block bmtb2_1=new Block();
+		bmtb2_1.getContents().add(mtb2_1);
+		
+		Block brtb2_1=new Block();
+		brtb2_1.getContents().add(rtb2_1);
+		
+		mtmp.getPaths().add(bmtb2_1);
+		rtmp.getPaths().add(brtb2_1);
+		
+		//TestBehaviour1 mtb2_2=new TestBehaviour1();
+		TestBehaviour1 rtb2_2=new TestBehaviour1();
+		
+		//mtb2_2.setMatchWith(rtb2_2);
+		
+		//Block bmtb2_2=new Block();
+		//bmtb2_2.getContents().add(mtb2_2);
+		
+		Block brtb2_2=new Block();
+		brtb2_2.getContents().add(rtb2_2);
+		
+		//mtmp.getPaths().add(bmtb2_2);
+		rtmp.getPaths().add(brtb2_2);
+		
+		TestBehaviour1 mtb2_3=new TestBehaviour1();
+		TestBehaviour1 rtb2_3=new TestBehaviour1();
+		
+		mtb2_3.setMatchWith(rtb2_3);
+		
+		Block bmtb2_3=new Block();
+		bmtb2_3.getContents().add(mtb2_3);
+		
+		Block brtb2_3=new Block();
+		brtb2_3.getContents().add(rtb2_3);
+		
+		mtmp.getPaths().add(bmtb2_3);
+		rtmp.getPaths().add(brtb2_3);
+		
+		mainList.visit(mtmp);
+		refList.visit(rtmp);
+
+		ErrorRecorder l=new ErrorRecorder();
+		
+		l.addExpectedError(java.util.PropertyResourceBundle.getBundle(
+				"org.scribble.conformance.comparator.Messages").
+					getString("_ADDITIONAL_UNMATCHED_REF_PATHS"));
+		
+		BehaviourListComparatorRule rule=new BehaviourListComparatorRule();
+		
+		if (rule.compare(context, mainList, refList, l, true) == true) {
+			fail("Comparison should have failed");
+		}
+		
+		if (l.isValid() == false) {
+			fail(l.invalidMessage());
+		}
+	}
+	
+	public void testCompareMissingConditionalDecisionMidRef() {
+		
+		Definition maindefn=new Definition() {};
+		Definition refdefn=new Definition() {};
+		
+		Role role=new Role();
+		role.setName("role");
+		
+		LocatedName mn=new LocatedName();
+		mn.setRole(role);
+		
+		maindefn.setLocatedName(mn);
+		refdefn.setLocatedName(mn);
+		
+		ModelReference ref=new ModelReference((String)null);
+		
+		DefaultComparatorContext context=
+					new DefaultComparatorContext(ref, ref, getRules());
+		
+		BehaviourList mainList=new TestBehaviourList();
+		BehaviourList refList=new TestBehaviourList();
+		
+		TestBehaviour1 mtb1=new TestBehaviour1();
+		maindefn.getBlock().getContents().add(mtb1);
+		
+		TestBehaviour1 rtb1=new TestBehaviour1();
+		refdefn.getBlock().getContents().add(rtb1);
+		
+		mtb1.setMatchWith(rtb1);
+		
+		mainList.getBehaviourList().add(mtb1);
+		refList.getBehaviourList().add(rtb1);
+		
+		TestSinglePath rtb2=new TestSinglePath();
+		rtb2.getInitiatorRoles().add(role);
+		rtb2.setConditional(true);
+		refdefn.getBlock().getContents().add(rtb2);
+
+		refList.getBehaviourList().add(rtb2);
+		
+		TestBehaviour1 mtb3=new TestBehaviour1();
+		maindefn.getBlock().getContents().add(mtb3);
+
+		TestBehaviour1 rtb3=new TestBehaviour1();
+		refdefn.getBlock().getContents().add(rtb3);
+		
+		mtb3.setMatchWith(rtb3);
+		
+		mainList.getBehaviourList().add(mtb3);
+		refList.getBehaviourList().add(rtb3);
+		
+		ErrorRecorder l=new ErrorRecorder();
+		
+		BehaviourListComparatorRule rule=new BehaviourListComparatorRule();
+		
+		if (rule.compare(context, mainList, refList, l, true) == false) {
+			fail("Comparison should NOT have failed");
+		}
+		
+		if (l.isValid() == false) {
+			fail(l.invalidMessage());
+		}
+	}
+	
+	public void testCompareMissingConditionalDecisionMidMain() {
+		
+		Definition maindefn=new Definition() {};
+		Definition refdefn=new Definition() {};
+		
+		Role role=new Role();
+		role.setName("role");
+		
+		LocatedName mn=new LocatedName();
+		mn.setRole(role);
+		
+		maindefn.setLocatedName(mn);
+		refdefn.setLocatedName(mn);
+		
+		ModelReference ref=new ModelReference((String)null);
+		
+		DefaultComparatorContext context=
+					new DefaultComparatorContext(ref, ref, getRules());
+		
+		BehaviourList mainList=new TestBehaviourList();
+		BehaviourList refList=new TestBehaviourList();
+		
+		TestBehaviour1 mtb1=new TestBehaviour1();
+		maindefn.getBlock().getContents().add(mtb1);
+		
+		TestBehaviour1 rtb1=new TestBehaviour1();
+		refdefn.getBlock().getContents().add(rtb1);
+		
+		mtb1.setMatchWith(rtb1);
+		
+		mainList.getBehaviourList().add(mtb1);
+		refList.getBehaviourList().add(rtb1);
+		
+		TestSinglePath mtb2=new TestSinglePath();
+		mtb2.getInitiatorRoles().add(role);
+		mtb2.setConditional(true);
+		maindefn.getBlock().getContents().add(mtb2);
+
+		mainList.getBehaviourList().add(mtb2);
+		
+		TestBehaviour1 mtb3=new TestBehaviour1();
+		maindefn.getBlock().getContents().add(mtb3);
+
+		TestBehaviour1 rtb3=new TestBehaviour1();
+		refdefn.getBlock().getContents().add(rtb3);
+		
+		mtb3.setMatchWith(rtb3);
+		
+		mainList.getBehaviourList().add(mtb3);
+		refList.getBehaviourList().add(rtb3);
+		
+		ErrorRecorder l=new ErrorRecorder();
+		
+		BehaviourListComparatorRule rule=new BehaviourListComparatorRule();
+		
+		if (rule.compare(context, mainList, refList, l, true) == false) {
+			fail("Comparison should NOT have failed");
+		}
+		
+		if (l.isValid() == false) {
+			fail(l.invalidMessage());
+		}
+	}
+	
+	public void testCompareAdditionalMainDecisionPathInMultiPath() {
+		
+		Definition maindefn=new Definition() {};
+		Definition refdefn=new Definition() {};
+		
+		Role role=new Role();
+		role.setName("role");
+		
+		LocatedName mn=new LocatedName();
+		mn.setRole(role);
+		
+		maindefn.setLocatedName(mn);
+		refdefn.setLocatedName(mn);
+		
+		ModelReference ref=new ModelReference((String)null);
+		
+		DefaultComparatorContext context=
+					new DefaultComparatorContext(ref, ref, getRules());
+		
+		BehaviourList mainList=new TestBehaviourList();
+		BehaviourList refList=new TestBehaviourList();
+		
+		TestMultiPath mtmp=new TestMultiPath();
+		mtmp.getInitiatorRoles().add(role);
+		mtmp.setStrictScope(true);
+		mtmp.setMutuallyExclusivePaths(true);
+		
+		maindefn.getBlock().getContents().add(mtmp);
+		
+		TestMultiPath rtmp=new TestMultiPath();
+		rtmp.getInitiatorRoles().add(role);
+		rtmp.setStrictScope(true);
+		rtmp.setMutuallyExclusivePaths(true);
+		refdefn.getBlock().getContents().add(rtmp);
+		
+		TestBehaviour1 mtb2_1=new TestBehaviour1();
+		TestBehaviour1 rtb2_1=new TestBehaviour1();
+		
+		mtb2_1.setMatchWith(rtb2_1);
+		
+		Block bmtb2_1=new Block();
+		bmtb2_1.getContents().add(mtb2_1);
+		
+		Block brtb2_1=new Block();
+		brtb2_1.getContents().add(rtb2_1);
+		
+		mtmp.getPaths().add(bmtb2_1);
+		rtmp.getPaths().add(brtb2_1);
+		
+		TestBehaviour1 mtb2_2=new TestBehaviour1();
+		//TestBehaviour1 rtb2_2=new TestBehaviour1();
+		
+		//mtb2_2.setMatchWith(rtb2_2);
+		
+		Block bmtb2_2=new Block();
+		bmtb2_2.getContents().add(mtb2_2);
+		
+		//Block brtb2_2=new Block();
+		//brtb2_2.getContents().add(rtb2_2);
+		
+		mtmp.getPaths().add(bmtb2_2);
+		//rtmp.getPaths().add(brtb2_2);
+		
+		TestBehaviour1 mtb2_3=new TestBehaviour1();
+		TestBehaviour1 rtb2_3=new TestBehaviour1();
+		
+		mtb2_3.setMatchWith(rtb2_3);
+		
+		Block bmtb2_3=new Block();
+		bmtb2_3.getContents().add(mtb2_3);
+		
+		Block brtb2_3=new Block();
+		brtb2_3.getContents().add(rtb2_3);
+		
+		mtmp.getPaths().add(bmtb2_3);
+		rtmp.getPaths().add(brtb2_3);
+		
+		mainList.visit(mtmp);
+		refList.visit(rtmp);
+
+		ErrorRecorder l=new ErrorRecorder();
+		
+		/*
+		l.addExpectedError(java.util.PropertyResourceBundle.getBundle(
+					"org.scribble.conformance.comparator.Messages").
+						getString("_ADDITIONAL_UNMATCHED_PATHS"));
+		*/
+		
+		BehaviourListComparatorRule rule=new BehaviourListComparatorRule();
+		
+		if (rule.compare(context, mainList, refList, l, true) == false) {
+			fail("Comparison should NOT have failed");
+		}
+		
+		if (l.isValid() == false) {
+			fail(l.invalidMessage());
+		}
+	}
+	
+	public void testCompareAdditionalRefDecisionPathInMultiPath() {
+		
+		Definition maindefn=new Definition() {};
+		Definition refdefn=new Definition() {};
+		
+		Role role=new Role();
+		role.setName("role");
+		
+		LocatedName mn=new LocatedName();
+		mn.setRole(role);
+		
+		maindefn.setLocatedName(mn);
+		refdefn.setLocatedName(mn);
+		
+		ModelReference ref=new ModelReference((String)null);
+		
+		DefaultComparatorContext context=
+					new DefaultComparatorContext(ref, ref, getRules());
+		
+		BehaviourList mainList=new TestBehaviourList();
+		BehaviourList refList=new TestBehaviourList();
+		
+		TestMultiPath mtmp=new TestMultiPath();
+		mtmp.getInitiatorRoles().add(role);
+		mtmp.setStrictScope(true);
+		mtmp.setMutuallyExclusivePaths(true);
+		maindefn.getBlock().getContents().add(mtmp);
+
+		TestMultiPath rtmp=new TestMultiPath();
+		rtmp.getInitiatorRoles().add(role);
+		rtmp.setStrictScope(true);
+		rtmp.setMutuallyExclusivePaths(true);
+		refdefn.getBlock().getContents().add(rtmp);
+		
+		TestBehaviour1 mtb2_1=new TestBehaviour1();
+		TestBehaviour1 rtb2_1=new TestBehaviour1();
+		
+		mtb2_1.setMatchWith(rtb2_1);
+		
+		Block bmtb2_1=new Block();
+		bmtb2_1.getContents().add(mtb2_1);
+		
+		Block brtb2_1=new Block();
+		brtb2_1.getContents().add(rtb2_1);
+		
+		mtmp.getPaths().add(bmtb2_1);
+		rtmp.getPaths().add(brtb2_1);
+		
+		//TestBehaviour1 mtb2_2=new TestBehaviour1();
+		TestBehaviour1 rtb2_2=new TestBehaviour1();
+		
+		//mtb2_2.setMatchWith(rtb2_2);
+		
+		//Block bmtb2_2=new Block();
+		//bmtb2_2.getContents().add(mtb2_2);
+		
+		Block brtb2_2=new Block();
+		brtb2_2.getContents().add(rtb2_2);
+		
+		//mtmp.getPaths().add(bmtb2_2);
+		rtmp.getPaths().add(brtb2_2);
+		
+		TestBehaviour1 mtb2_3=new TestBehaviour1();
+		TestBehaviour1 rtb2_3=new TestBehaviour1();
+		
+		mtb2_3.setMatchWith(rtb2_3);
+		
+		Block bmtb2_3=new Block();
+		bmtb2_3.getContents().add(mtb2_3);
+		
+		Block brtb2_3=new Block();
+		brtb2_3.getContents().add(rtb2_3);
+		
+		mtmp.getPaths().add(bmtb2_3);
+		rtmp.getPaths().add(brtb2_3);
+		
+		mainList.visit(mtmp);
+		refList.visit(rtmp);
+
+		ErrorRecorder l=new ErrorRecorder();
+		
+		/*
+		l.addExpectedError(java.util.PropertyResourceBundle.getBundle(
+				"org.scribble.conformance.comparator.Messages").
+					getString("_ADDITIONAL_UNMATCHED_REF_PATHS"));
+		*/
+		
+		BehaviourListComparatorRule rule=new BehaviourListComparatorRule();
+		
+		if (rule.compare(context, mainList, refList, l, true) == false) {
+			fail("Comparison should NOT have failed");
+		}
+		
+		if (l.isValid() == false) {
+			fail(l.invalidMessage());
+		}
+	}
+
+	// TODO: Test insertion/deletion numbers
+}

Added: trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/comparator/TestBehaviour1ComparatorRule.java
===================================================================
--- trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/comparator/TestBehaviour1ComparatorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/comparator/TestBehaviour1ComparatorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 14 Jul 2008 : Initial version created by gary
+ */
+package org.scribble.conformance.comparator;
+
+import org.scribble.comparator.ComparatorContext;
+import org.scribble.conformance.model.TestBehaviour1;
+import org.scribble.model.ModelObject;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+
+public class TestBehaviour1ComparatorRule implements org.scribble.comparator.ComparatorRule {
+
+	public static final String TEST_BEHAVIOUR_COMPARE_FAILED = "Test behaviour compare failed";
+	public static final String TEST_REF = "TEST_REF";
+
+	public boolean compare(ComparatorContext context, ModelObject main,
+			ModelObject reference, ModelListener l, boolean deep) {
+		boolean ret=false;
+		
+		TestBehaviour1 maintb=(TestBehaviour1)main;
+		TestBehaviour1 reftb=(TestBehaviour1)reference;
+		
+		ret = maintb.matchWith(reftb);
+		
+		if (ret == false) {
+			java.util.Map<String,Object> props=new java.util.HashMap<String,Object>();
+			props.put(TEST_REF, reftb);
+			l.error(new ModelIssue(main, TEST_BEHAVIOUR_COMPARE_FAILED, props));
+		}
+		
+		return(ret);
+	}
+
+	public boolean isComparisonSupported(ModelObject main, ModelObject ref) {
+		return(main instanceof TestBehaviour1 &&
+				ref instanceof TestBehaviour1);
+	}
+
+	public boolean isTypeSupported(ModelObject obj) {
+		return(obj instanceof TestBehaviour1);
+	}
+}

Added: trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/comparator/TestBehaviour2ComparatorRule.java
===================================================================
--- trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/comparator/TestBehaviour2ComparatorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/comparator/TestBehaviour2ComparatorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 14 Jul 2008 : Initial version created by gary
+ */
+package org.scribble.conformance.comparator;
+
+import org.scribble.comparator.ComparatorContext;
+import org.scribble.conformance.model.TestBehaviour2;
+import org.scribble.model.ModelObject;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+
+public class TestBehaviour2ComparatorRule implements org.scribble.comparator.ComparatorRule {
+
+	public static final String TEST_BEHAVIOUR_COMPARE_FAILED = "Test behaviour compare failed";
+	public static final String TEST_REF = "TEST_REF";
+
+	public boolean compare(ComparatorContext context, ModelObject main,
+			ModelObject reference, ModelListener l, boolean deep) {
+		boolean ret=false;
+		
+		TestBehaviour2 maintb=(TestBehaviour2)main;
+		TestBehaviour2 reftb=(TestBehaviour2)reference;
+		
+		ret = maintb.matchWith(reftb);
+		
+		if (ret == false) {
+			java.util.Map<String,Object> props=new java.util.HashMap<String,Object>();
+			props.put(TEST_REF, reftb);
+			l.error(new ModelIssue(main, TEST_BEHAVIOUR_COMPARE_FAILED, props));
+		}
+		
+		return(ret);
+	}
+
+	public boolean isComparisonSupported(ModelObject main, ModelObject ref) {
+		return(main instanceof TestBehaviour2 &&
+				ref instanceof TestBehaviour2);
+	}
+
+	public boolean isTypeSupported(ModelObject obj) {
+		return(obj instanceof TestBehaviour2);
+	}
+}

Added: trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/comparator/TestMultiPathComparatorRule.java
===================================================================
--- trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/comparator/TestMultiPathComparatorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/comparator/TestMultiPathComparatorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 19 Jul 2008 : Initial version created by gary
+ */
+package org.scribble.conformance.comparator;
+
+import org.scribble.comparator.ComparatorContext;
+import org.scribble.conformance.model.TestMultiPath;
+import org.scribble.model.ModelObject;
+import org.scribble.model.admin.ModelListener;
+
+public class TestMultiPathComparatorRule implements org.scribble.comparator.ComparatorRule {
+
+	public boolean compare(ComparatorContext context, ModelObject main,
+			ModelObject reference, ModelListener l, boolean deep) {
+		boolean ret=true;
+		return(ret);
+	}
+
+	public boolean isComparisonSupported(ModelObject main, ModelObject ref) {
+		return(main instanceof TestMultiPath &&
+				ref instanceof TestMultiPath);
+	}
+
+	public boolean isTypeSupported(ModelObject obj) {
+		return(obj instanceof TestMultiPath);
+	}
+}

Added: trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/comparator/TestSinglePathComparatorRule.java
===================================================================
--- trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/comparator/TestSinglePathComparatorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/comparator/TestSinglePathComparatorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 19 Jul 2008 : Initial version created by gary
+ */
+package org.scribble.conformance.comparator;
+
+import org.scribble.comparator.ComparatorContext;
+import org.scribble.conformance.model.TestSinglePath;
+import org.scribble.model.ModelObject;
+import org.scribble.model.admin.ModelListener;
+
+public class TestSinglePathComparatorRule implements org.scribble.comparator.ComparatorRule {
+
+	public boolean compare(ComparatorContext context, ModelObject main,
+			ModelObject reference, ModelListener l, boolean deep) {
+		boolean ret=true;
+		return(ret);
+	}
+
+	public boolean isComparisonSupported(ModelObject main, ModelObject ref) {
+		return(main instanceof TestSinglePath &&
+				ref instanceof TestSinglePath);
+	}
+
+	public boolean isTypeSupported(ModelObject obj) {
+		return(obj instanceof TestSinglePath);
+	}
+}

Added: trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/model/BehaviourListTest.java
===================================================================
--- trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/model/BehaviourListTest.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/model/BehaviourListTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,189 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 20 Aug 2008 : Initial version created by gary
+ */
+package org.scribble.conformance.model;
+
+import junit.framework.TestCase;
+
+public class BehaviourListTest extends TestCase {
+
+	public void testBehaviourListSingleBehaviour() {
+		
+		TestBehaviour1 b1=new TestBehaviour1();
+		
+		org.scribble.model.Block group=new org.scribble.model.Block();
+		group.getContents().add(b1);
+		
+		BehaviourList bl=new BehaviourList(group);
+		
+		if (bl.getBehaviourList().size() != 1) {
+			fail("Expecting 1 behaviour, but got: "+bl.getBehaviourList().size());
+		}
+		
+		if (bl.getBehaviourList().get(0) != b1) {
+			fail("Behaviour not expected");
+		}
+	}
+
+	public void testBehaviourListMultipleBehaviours() {
+		
+		TestBehaviour1 b1=new TestBehaviour1();
+		TestBehaviour1 b2=new TestBehaviour1();
+		TestBehaviour1 b3=new TestBehaviour1();
+		TestBehaviour1 b4=new TestBehaviour1();
+		
+		org.scribble.model.Block group=new org.scribble.model.Block();
+		group.getContents().add(b1);
+		group.getContents().add(b2);
+		group.getContents().add(b3);
+		group.getContents().add(b4);
+		
+		BehaviourList bl=new BehaviourList(group);
+		
+		if (bl.getBehaviourList().size() != 4) {
+			fail("Expecting 4 behaviours, but got: "+bl.getBehaviourList().size());
+		}
+		
+		if (bl.getBehaviourList().get(0) != b1) {
+			fail("Behaviour 1 not expected");
+		}
+		
+		if (bl.getBehaviourList().get(1) != b2) {
+			fail("Behaviour 2 not expected");
+		}
+		
+		if (bl.getBehaviourList().get(2) != b3) {
+			fail("Behaviour 3 not expected");
+		}
+		
+		if (bl.getBehaviourList().get(3) != b4) {
+			fail("Behaviour 4 not expected");
+		}
+	}
+
+	public void testBehaviourListSyncComposition() {
+		
+		TestBehaviour1 b1=new TestBehaviour1();
+		TestBehaviour1 b2=new TestBehaviour1();
+		TestBehaviour1 b3=new TestBehaviour1();
+		TestBehaviour1 b4=new TestBehaviour1();
+		
+		org.scribble.model.Block group=new org.scribble.model.Block();
+		group.getContents().add(b1);
+		
+		TestModelInclude mi=new TestModelInclude(false);
+		
+		mi.getDefinition().getBlock().getContents().add(b2);
+		mi.getDefinition().getBlock().getContents().add(b3);
+		
+		group.getContents().add(mi);
+		
+		group.getContents().add(b4);
+		
+		BehaviourList bl=new BehaviourList(group);
+		
+		if (bl.getBehaviourList().size() != 3) {
+			fail("Expecting 3 behaviours, but got: "+bl.getBehaviourList().size());
+		}
+		
+		if (bl.getBehaviourList().get(0) != b1) {
+			fail("Behaviour 1 not expected");
+		}
+		
+		if ((bl.getBehaviourList().get(1) instanceof BehaviourList) == false) {
+			fail("Second element not a behaviour list");
+		}
+		
+		BehaviourList sublist=(BehaviourList)bl.getBehaviourList().get(1);
+	
+		if (sublist.getBehaviourList().size() != 2) {
+			fail("Expecting 2 sub behaviours, but got: "+sublist.getBehaviourList().size());
+		}
+		
+		if (sublist.getBehaviourList().get(0) != b2) {
+			fail("Behaviour 2 not expected");
+		}
+		
+		if (sublist.getBehaviourList().get(1) != b3) {
+			fail("Behaviour 3 not expected");
+		}
+		
+		if (bl.getBehaviourList().get(2) != b4) {
+			fail("Behaviour 4 not expected");
+		}
+	}
+
+	public void testBehaviourListAsyncComposition() {
+		
+		TestBehaviour1 b1=new TestBehaviour1();
+		TestBehaviour1 b2=new TestBehaviour1();
+		TestBehaviour1 b3=new TestBehaviour1();
+		TestBehaviour1 b4=new TestBehaviour1();
+		
+		org.scribble.model.Block group=new org.scribble.model.Block();
+		group.getContents().add(b1);
+		
+		TestModelInclude mi=new TestModelInclude(true);
+		
+		mi.getDefinition().getBlock().getContents().add(b2);
+		mi.getDefinition().getBlock().getContents().add(b3);
+		
+		group.getContents().add(mi);
+		
+		group.getContents().add(b4);
+		
+		BehaviourList bl=new BehaviourList(group);
+		
+		if (bl.getBehaviourList().size() != 3) {
+			fail("Expecting 3 behaviours, but got: "+bl.getBehaviourList().size());
+		}
+		
+		if (bl.getBehaviourList().get(0) != b1) {
+			fail("Behaviour 1 not expected");
+		}
+		
+		if ((bl.getBehaviourList().get(1) instanceof BehaviourListPaths) == false) {
+			fail("Second element not a BehaviourListPaths");
+		}
+		
+		BehaviourListPaths blp=(BehaviourListPaths)bl.getBehaviourList().get(1);
+	
+		if (blp.getPaths().size() != 1) {
+			fail("Only 1 path expected, but got: "+blp.getPaths().size());
+		}
+		
+		BehaviourList sublist=blp.getPaths().get(0);
+		
+		if (sublist.getBehaviourList().size() != 2) {
+			fail("Expecting 2 sub behaviours, but got: "+sublist.getBehaviourList().size());
+		}
+		
+		if (sublist.getBehaviourList().get(0) != b2) {
+			fail("Behaviour 2 not expected");
+		}
+		
+		if (sublist.getBehaviourList().get(1) != b3) {
+			fail("Behaviour 3 not expected");
+		}
+		
+		if (bl.getBehaviourList().get(2) != b4) {
+			fail("Behaviour 4 not expected");
+		}
+	}
+}

Added: trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/model/TestBehaviour1.java
===================================================================
--- trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/model/TestBehaviour1.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/model/TestBehaviour1.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 14 Jul 2008 : Initial version created by gary
+ */
+package org.scribble.conformance.model;
+
+import org.scribble.model.ModelObject;
+
+public class TestBehaviour1 extends org.scribble.model.Behaviour {
+
+	public boolean matchWith(ModelObject obj) {
+		return(obj == m_matchWith);
+	}
+	
+	public void setMatchWith(ModelObject obj) {
+		m_matchWith = obj;
+	}
+	
+	private ModelObject m_matchWith=null;
+}

Added: trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/model/TestBehaviour2.java
===================================================================
--- trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/model/TestBehaviour2.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/model/TestBehaviour2.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 19 Jul 2008 : Initial version created by gary
+ */
+package org.scribble.conformance.model;
+
+import org.scribble.model.ModelObject;
+
+public class TestBehaviour2 extends org.scribble.model.Behaviour {
+
+	public boolean matchWith(ModelObject obj) {
+		return(obj == m_matchWith);
+	}
+	
+	public void setMatchWith(ModelObject obj) {
+		m_matchWith = obj;
+	}
+	
+	private ModelObject m_matchWith=null;
+}

Added: trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/model/TestBehaviourList.java
===================================================================
--- trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/model/TestBehaviourList.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/model/TestBehaviourList.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 20 Aug 2008 : Initial version created by gary
+ */
+package org.scribble.conformance.model;
+
+public class TestBehaviourList extends BehaviourList {
+
+}

Added: trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/model/TestDefinition.java
===================================================================
--- trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/model/TestDefinition.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/model/TestDefinition.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 20 Aug 2008 : Initial version created by gary
+ */
+package org.scribble.conformance.model;
+
+import org.scribble.model.Declaration;
+
+public class TestDefinition extends org.scribble.model.Definition {
+
+	/**
+	 * This method return the top level declarations associated
+	 * with the definition.
+	 * 
+	 * @return The declarations
+	 */
+	public java.util.Set<Declaration> getDeclarations() {
+		java.util.Set<Declaration> ret=new java.util.HashSet<Declaration>();
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/model/TestModelInclude.java
===================================================================
--- trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/model/TestModelInclude.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/model/TestModelInclude.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 20 Aug 2008 : Initial version created by gary
+ */
+package org.scribble.conformance.model;
+
+import org.scribble.model.*;
+
+public class TestModelInclude extends ModelInclude {
+
+	public TestModelInclude(boolean async) {
+		m_async = async;
+	}
+	
+	@Override
+	public Definition getDefinition() {
+		return(m_definition);
+	}
+
+	@Override
+	public ModelReference getReference() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public boolean isAsynchronous() {
+		return(m_async);
+	}
+
+	private boolean m_async=false;
+	private Definition m_definition=new TestDefinition();
+}

Added: trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/model/TestMultiPath.java
===================================================================
--- trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/model/TestMultiPath.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/model/TestMultiPath.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 19 Jul 2008 : Initial version created by gary
+ */
+package org.scribble.conformance.model;
+
+import java.util.List;
+
+import org.scribble.model.Block;
+import org.scribble.model.OrderingConstraint;
+import org.scribble.model.Role;
+
+public class TestMultiPath extends org.scribble.model.MultiPathBehaviour {
+
+	@Override
+	public java.util.List<Role> getInitiatorRoles() {
+		return(m_initiatorRoles);
+	}
+	
+	public List<Block> getPaths() {
+		return(m_paths);
+	}
+
+	public Block createNewPath() {
+		Block ret=null;
+		
+		return(ret);
+	}
+	
+	public boolean removePath(Block path) {
+		boolean ret=false;
+		
+		return(ret);
+	}
+	
+	public boolean isStrictScope() {
+		return(m_strictScope);
+	}
+	
+	public void setStrictScope(boolean strict) {
+		m_strictScope = strict;
+	}
+
+	public boolean isMutuallyExclusivePaths() {
+		return(m_mutuallyExclusivePaths);
+	}
+	
+	public void setMutuallyExclusivePaths(boolean me) {
+		m_mutuallyExclusivePaths = me;
+	}
+	
+	public OrderingConstraint getOrdering() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	private boolean m_strictScope=false;
+	private boolean m_mutuallyExclusivePaths=false;
+	private List<Block> m_paths=new java.util.Vector<Block>();
+	private java.util.List<Role> m_initiatorRoles=
+		new java.util.Vector<Role>();
+}

Added: trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/model/TestSinglePath.java
===================================================================
--- trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/model/TestSinglePath.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conformance/src/test/org/scribble/conformance/model/TestSinglePath.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 19 Jul 2008 : Initial version created by gary
+ */
+package org.scribble.conformance.model;
+
+import org.scribble.model.Block;
+import org.scribble.model.Role;
+
+public class TestSinglePath extends org.scribble.model.SinglePathBehaviour {
+
+	@Override
+	public java.util.List<Role> getInitiatorRoles() {
+		return(m_initiatorRoles);
+	}
+	
+	public Block getBlock() {
+		return(m_block);
+	}
+
+	public boolean isStrictScope() {
+		return(m_strictScope);
+	}
+	
+	public void setStrictScope(boolean strict) {
+		m_strictScope = strict;
+	}
+
+	public void setConditional(boolean conditional) {
+		m_conditional = conditional;
+	}
+	
+	public boolean isConditional() {
+		return(m_conditional);
+	}
+	
+	public boolean isGroupingConstruct() {
+		return(m_groupingConstruct);
+	}
+	
+	public void setGroupingConstruct(boolean b) {
+		m_groupingConstruct = b; 
+	}
+
+	public boolean isRepetition() {
+		return(m_repetition);
+	}
+	
+	public void setRepetition(boolean b) {
+		m_repetition = b; 
+	}
+
+	private boolean m_conditional=false;
+	private boolean m_repetition=false;
+	private boolean m_strictScope=false;
+	private boolean m_groupingConstruct=true;
+	private Block m_block=new Block();
+	private java.util.List<Role> m_initiatorRoles=
+					new java.util.Vector<Role>();
+}

Added: trunk/bundles/org.scribble.conversation.comparator/.classpath
===================================================================
--- trunk/bundles/org.scribble.conversation.comparator/.classpath	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.comparator/.classpath	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src/test"/>
+	<classpathentry kind="src" path="src/plugintest"/>
+	<classpathentry kind="src" path="src/main/java"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
+	<classpathentry kind="output" path="classes"/>
+</classpath>

Added: trunk/bundles/org.scribble.conversation.comparator/.project
===================================================================
--- trunk/bundles/org.scribble.conversation.comparator/.project	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.comparator/.project	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.scribble.conversation.comparator</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.ManifestBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.SchemaBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.pde.PluginNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

Added: trunk/bundles/org.scribble.conversation.comparator/LICENSE.txt
===================================================================
--- trunk/bundles/org.scribble.conversation.comparator/LICENSE.txt	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.comparator/LICENSE.txt	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,201 @@
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   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.

Added: trunk/bundles/org.scribble.conversation.comparator/META-INF/MANIFEST.MF
===================================================================
--- trunk/bundles/org.scribble.conversation.comparator/META-INF/MANIFEST.MF	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.comparator/META-INF/MANIFEST.MF	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,33 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Scribble Conversation Comparator Plug-in
+Bundle-SymbolicName: org.scribble.conversation.comparator;singleton:=true
+Bundle-Version: 1.2.0.qualifier
+Bundle-Activator: org.scribble.conversation.comparator.osgi.Activator
+Bundle-Vendor: www.scribble.org
+Import-Package: org.osgi.framework;version="1.3.0"
+Require-Bundle: org.scribble.core;bundle-version="[1.0.0,2.0.0)",
+ org.scribble.conversation.model;bundle-version="[1.0.0,2.0.0)",
+ org.scribble.conformance;bundle-version="[1.0.0,2.0.0)",
+ org.eclipse.core.runtime;resolution:=optional,
+ org.junit;resolution:=optional
+Bundle-ActivationPolicy: lazy
+Scribble-Extensions: org.scribble.conversation.comparator.ConversationComparatorRule,
+  org.scribble.conversation.comparator.IfComparatorRule,
+  org.scribble.conversation.comparator.ConditionalBlockComparatorRule,
+  org.scribble.conversation.comparator.ParallelComparatorRule,
+  org.scribble.conversation.comparator.SpawnComparatorRule,
+  org.scribble.conversation.comparator.TryEscapeComparatorRule,
+  org.scribble.conversation.comparator.InterruptBlockComparatorRule,
+  org.scribble.conversation.comparator.CatchBlockComparatorRule,
+  org.scribble.conversation.comparator.RaiseComparatorRule,
+  org.scribble.conversation.comparator.WhenComparatorRule,
+  org.scribble.conversation.comparator.WhileComparatorRule,
+  org.scribble.conversation.comparator.model.transform.ConversationStatelessTransformationRule,
+  org.scribble.conversation.comparator.model.transform.ConversationInteractionStatelessTransformationRule,
+  org.scribble.conversation.comparator.model.transform.WhileStatelessTransformationRule,
+  org.scribble.conversation.comparator.model.transform.ParallelStatelessTransformationRule,
+  org.scribble.conversation.comparator.model.transform.RunStatelessTransformationRule,
+  org.scribble.conversation.comparator.model.transform.SpawnStatelessTransformationRule,
+  org.scribble.conversation.comparator.model.transform.IfStatelessTransformationRule
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6

Added: trunk/bundles/org.scribble.conversation.comparator/build.properties
===================================================================
--- trunk/bundles/org.scribble.conversation.comparator/build.properties	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.comparator/build.properties	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,5 @@
+source.. = src/main/java/
+output.. = classes/
+bin.includes = META-INF/,\
+               .,\
+               plugin.xml

Added: trunk/bundles/org.scribble.conversation.comparator/pom.xml
===================================================================
--- trunk/bundles/org.scribble.conversation.comparator/pom.xml	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.comparator/pom.xml	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,38 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  	<modelVersion>4.0.0</modelVersion>
+	<groupId>org.savara.bundles</groupId>
+	<artifactId>org.scribble.conversation.comparator</artifactId> 
+	<version>1.2.0-SNAPSHOT</version>
+	<packaging>jar</packaging>
+	<name>Savara::Bundles::ScribbleConversationComparator</name>
+
+	<parent>
+		<groupId>org.savara</groupId>
+		<artifactId>bundles</artifactId>
+		<version>1.2.0-SNAPSHOT</version>
+	</parent>
+  
+	<dependencies>
+		<dependency>
+			<groupId>org.savara.bundles</groupId>
+			<artifactId>org.scribble.core</artifactId>
+			<version>1.2.0-SNAPSHOT</version>
+		</dependency>
+		<dependency>
+			<groupId>org.savara.bundles</groupId>
+			<artifactId>org.scribble.conformance</artifactId>
+			<version>1.2.0-SNAPSHOT</version>
+		</dependency>
+		<dependency>
+			<groupId>org.savara.bundles</groupId>
+			<artifactId>org.scribble.conversation.model</artifactId>
+			<version>1.2.0-SNAPSHOT</version>
+		</dependency>
+	    <dependency>
+	      <groupId>org.apache.felix</groupId>
+	      <artifactId>org.osgi.core</artifactId>
+	      <version>${osgi.version}</version>
+	    </dependency>
+	</dependencies>
+</project>

Added: trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/CatchBlockComparatorRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/CatchBlockComparatorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/CatchBlockComparatorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 10 Nov 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.comparator;
+
+import org.scribble.comparator.*;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This class provides the CatchBlock comparator rule.
+ */
+ at RegistryInfo(extension=ComparatorRule.class)
+public class CatchBlockComparatorRule implements ComparatorRule {
+
+	/**
+	 * This method determines whether the comparison rule is
+	 * associated with the supplied type.
+	 * 
+	 * @param obj The object to check
+	 * @return Whether the object is of a type supported by the
+	 * 					comparison rule
+	 */
+	public boolean isTypeSupported(ModelObject obj) {
+		return(obj instanceof CatchBlock);
+	}
+	
+	/**
+	 * This method determines whether the comparison rule is
+	 * appropriate for the supplied model objects.
+	 * 
+	 * @param main The main model object to be compared
+	 * @param ref The reference model object to be compared against
+	 * @return Whether the rule is relevant for the
+	 * 				model objects
+	 */
+	public boolean isComparisonSupported(ModelObject main, ModelObject ref) {
+		return(main instanceof CatchBlock &&
+				ref instanceof CatchBlock);
+	}
+	
+	/**
+	 * This method compares a model object against a reference
+	 * component to determine if they are equal.
+	 * 
+	 * @param context The context
+	 * @param main The main model object
+	 * @param reference The reference model object
+	 * @param l The model listener
+	 * @param deep Perform a deep compare
+	 * @return Whether the model objects are comparable
+	 */
+	public boolean compare(ComparatorContext context, ModelObject main,
+					ModelObject reference, ModelListener l, boolean deep) {
+		boolean ret=false;
+		CatchBlock maincb=(CatchBlock)main;
+		CatchBlock refcb=(CatchBlock)reference;
+
+		if (deep == false) {
+			
+			if (maincb.getType() != null &&
+					refcb.getType() != null) {
+				ret = context.compare(maincb.getType(),
+						refcb.getType(), l, deep);
+				
+				// TODO: Check role is appropriate
+				// May depend whether global or local models
+				// If local models, then only matters whether
+				// projected role is either present or absent
+				// in both lists - if global, then may need
+				// to be matched lists
+			} else {
+				ret = true;
+			}
+		}
+		
+		return(ret);
+	}
+	
+}

Added: trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/ConditionalBlockComparatorRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/ConditionalBlockComparatorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/ConditionalBlockComparatorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 11 Nov 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.comparator;
+
+import org.scribble.comparator.*;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This class provides the ConditionalBlock comparator rule.
+ */
+ at RegistryInfo(extension=ComparatorRule.class)
+public class ConditionalBlockComparatorRule implements ComparatorRule {
+
+	/**
+	 * This method determines whether the comparison rule is
+	 * associated with the supplied type.
+	 * 
+	 * @param obj The object to check
+	 * @return Whether the object is of a type supported by the
+	 * 					comparison rule
+	 */
+	public boolean isTypeSupported(ModelObject obj) {
+		return(obj.getClass().isAssignableFrom(ConditionalBlock.class) ||
+				ConditionalBlock.class.isAssignableFrom(obj.getClass()));
+	}
+	
+	/**
+	 * This method determines whether the comparison rule is
+	 * appropriate for the supplied model objects.
+	 * 
+	 * @param main The main model object to be compared
+	 * @param ref The reference model object to be compared against
+	 * @return Whether the rule is relevant for the
+	 * 				model objects
+	 */
+	public boolean isComparisonSupported(ModelObject main, ModelObject ref) {
+		// Atleast one must be a conditional block
+		return(main instanceof ConditionalBlock ||
+				ref instanceof ConditionalBlock);
+	}
+	
+	/**
+	 * This method compares a model object against a reference
+	 * component to determine if they are equal.
+	 * 
+	 * @param context The context
+	 * @param main The main model object
+	 * @param reference The reference model object
+	 * @param l The model listener
+	 * @param deep Perform a deep compare
+	 * @return Whether the model objects are comparable
+	 */
+	public boolean compare(ComparatorContext context, ModelObject main,
+					ModelObject reference, ModelListener l, boolean deep) {
+		boolean ret=false;
+		//ConditionalBlock maincb=(ConditionalBlock)main;
+		//ConditionalBlock refcb=(ConditionalBlock)reference;
+
+		if (deep == false) {
+			ret = true;
+		}
+		
+		return(ret);
+	}
+	
+}

Added: trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/ConversationComparatorRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/ConversationComparatorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/ConversationComparatorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,161 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 10 Jan 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.comparator;
+
+import java.util.Collections;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.comparator.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.conformance.model.BehaviourList;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class provides the Conversation comparator rule,
+ * for comparing a local Conversation for conformance.
+ */
+ at RegistryInfo(extension=ComparatorRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class ConversationComparatorRule implements ComparatorRule {
+
+	/**
+	 * This method determines whether the comparison rule is
+	 * associated with the supplied type.
+	 * 
+	 * @param obj The object to check
+	 * @return Whether the object is of a type supported by the
+	 * 					comparison rule
+	 */
+	public boolean isTypeSupported(ModelObject obj) {
+		return(obj instanceof Conversation);
+	}
+	
+	/**
+	 * This method determines whether the comparison rule is
+	 * appropriate for the supplied model objects.
+	 * 
+	 * @param main The main model object to be compared
+	 * @param ref The reference model object to be compared against
+	 * @return Whether the rule is relevant for the
+	 * 				model objects
+	 */
+	public boolean isComparisonSupported(ModelObject main, ModelObject ref) {
+		// Check both Conversation's and located
+		return(main instanceof Conversation &&
+				ref instanceof Conversation &&
+				((Conversation)main).isStateless() ==
+					((Conversation)ref).isStateless() &&
+				((Conversation)main).getLocatedName() != null &&
+				((Conversation)main).getLocatedName().getName() != null &&
+				((Conversation)main).getLocatedName().getRole() != null &&
+				((Conversation)ref).getLocatedName() != null &&
+				((Conversation)ref).getLocatedName().getName() != null &&
+				((Conversation)ref).getLocatedName().getRole() != null);
+	}
+	
+	/**
+	 * This method compares a model object against a reference
+	 * component to determine if they are equal.
+	 * 
+	 * @param context The context
+	 * @param main The main model object
+	 * @param reference The reference model object
+	 * @param l The model listener
+	 * @param deep Perform a deep compare
+	 * @return Whether the model objects are comparable
+	 */
+	public boolean compare(ComparatorContext context, ModelObject main,
+					ModelObject reference, ModelListener l, boolean deep) {
+		boolean ret=false;
+		Conversation mainp=(Conversation)main;
+		Conversation refp=(Conversation)reference;
+		
+		// Check if model names are comparable, taking into account
+		// mapping information provided by the context
+		// TODO: Use context information for mapping conversation name and
+		// roles
+		
+		if (deep && (context.getMainSource().isPlaceholder() ||
+					shouldCompare(context, mainp, refp))) {
+			ret = true;
+			
+			// TODO:
+			// Analysing comparison between conversations will need to collect
+			// information on the roles and channels to determine mapping
+			// for use with remaining activities
+			
+			// TODO:
+			// Possibly change conversation to use Block instead of list of Act
+			// and then visit the block - so next time the protocol is
+			// visited it can be ignored - but then this may be problem
+			
+			
+			// Check activities
+			
+			// Build list of behaviours
+			BehaviourList mainBehaviourList=BehaviourList.createBehaviourList(mainp.getBlock());
+			BehaviourList refBehaviourList=BehaviourList.createBehaviourList(refp.getBlock());
+			
+			context.compare(mainBehaviourList, refBehaviourList, l, true);
+		}
+		
+		return(ret);
+	}	
+	
+	protected boolean shouldCompare(ComparatorContext context,
+					Conversation mainp, Conversation refp) {
+		boolean ret=mainp.getLocatedName().getName().equals(refp.getLocatedName().getName()) &&
+				mainp.getLocatedName().getRole().getName().equals(
+						refp.getLocatedName().getRole().getName());
+		
+		if (ret == false) {
+			ret = mainp.getImplements().contains(context.getReferenceSource());
+			
+			if (ret == false) {
+				ret = mainp.getConformsTo().contains(context.getReferenceSource());
+			}
+			
+			// TODO: Need to also check main reference against refp - but not
+			// available in context at present
+			
+			if (ret == false) {
+				ret = !Collections.disjoint(refp.getConformsTo(),
+						mainp.getImplements());
+			}
+			
+			if (ret == false) {
+				ret = !Collections.disjoint(refp.getImplements(),
+						mainp.getConformsTo());
+			}
+			
+			if (ret == false) {
+				ret = !Collections.disjoint(refp.getImplements(),
+						mainp.getImplements());
+			}
+			
+			if (ret == false) {
+				ret = !Collections.disjoint(refp.getConformsTo(),
+						mainp.getConformsTo());
+			}
+		}
+		
+		return(ret);
+	}	
+}

Added: trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/IfComparatorRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/IfComparatorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/IfComparatorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 20 Jun 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.comparator;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.comparator.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class provides the Conversation If to another
+ * If comparator rule.
+ */
+ at RegistryInfo(extension=ComparatorRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class IfComparatorRule implements ComparatorRule {
+
+	/**
+	 * This method determines whether the comparison rule is
+	 * associated with the supplied type.
+	 * 
+	 * @param obj The object to check
+	 * @return Whether the object is of a type supported by the
+	 * 					comparison rule
+	 */
+	public boolean isTypeSupported(ModelObject obj) {
+		return(obj instanceof If);
+	}
+	
+	/**
+	 * This method determines whether the comparison rule is
+	 * appropriate for the supplied model objects.
+	 * 
+	 * @param main The main model object to be compared
+	 * @param ref The reference model object to be compared against
+	 * @return Whether the rule is relevant for the
+	 * 				model objects
+	 */
+	public boolean isComparisonSupported(ModelObject main, ModelObject ref) {
+		return(main instanceof If &&
+				ref instanceof If);
+	}
+	
+	/**
+	 * This method compares a model object against a reference
+	 * component to determine if they are equal.
+	 * 
+	 * @param context The context
+	 * @param main The main model object
+	 * @param reference The reference model object
+	 * @param l The model listener
+	 * @param deep Perform a deep compare
+	 * @return Whether the model objects are comparable
+	 */
+	public boolean compare(ComparatorContext context, ModelObject main,
+					ModelObject reference, ModelListener l, boolean deep) {
+		boolean ret=false;
+
+		if (deep == false) {
+			// Shallow, so return true as both choice
+			ret = true;
+		} else {
+			
+			// TODO: Decide how children should be dealt with
+			
+			// Check children - however not defined how the comparison
+			// should be done between multi-path
+		}
+		
+		return(ret);
+	}	
+}

Added: trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/InterruptBlockComparatorRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/InterruptBlockComparatorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/InterruptBlockComparatorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 10 Nov 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.comparator;
+
+import org.scribble.comparator.*;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This class provides the InterruptBlock comparator rule.
+ */
+ at RegistryInfo(extension=ComparatorRule.class)
+public class InterruptBlockComparatorRule implements ComparatorRule {
+
+	/**
+	 * This method determines whether the comparison rule is
+	 * associated with the supplied type.
+	 * 
+	 * @param obj The object to check
+	 * @return Whether the object is of a type supported by the
+	 * 					comparison rule
+	 */
+	public boolean isTypeSupported(ModelObject obj) {
+		return(obj instanceof InterruptBlock);
+	}
+	
+	/**
+	 * This method determines whether the comparison rule is
+	 * appropriate for the supplied model objects.
+	 * 
+	 * @param main The main model object to be compared
+	 * @param ref The reference model object to be compared against
+	 * @return Whether the rule is relevant for the
+	 * 				model objects
+	 */
+	public boolean isComparisonSupported(ModelObject main, ModelObject ref) {
+		return(main instanceof InterruptBlock &&
+				ref instanceof InterruptBlock);
+	}
+	
+	/**
+	 * This method compares a model object against a reference
+	 * component to determine if they are equal.
+	 * 
+	 * @param context The context
+	 * @param main The main model object
+	 * @param reference The reference model object
+	 * @param l The model listener
+	 * @param deep Perform a deep compare
+	 * @return Whether the model objects are comparable
+	 */
+	public boolean compare(ComparatorContext context, ModelObject main,
+					ModelObject reference, ModelListener l, boolean deep) {
+		boolean ret=false;
+
+		if (deep == false) {
+			ret = true;
+		}
+		
+		return(ret);
+	}
+	
+}

Added: trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/ParallelComparatorRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/ParallelComparatorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/ParallelComparatorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 17 Jul 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.comparator;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.comparator.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class provides the Conversation Parallel to another
+ * Parallel comparator rule.
+ */
+ at RegistryInfo(extension=ComparatorRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class ParallelComparatorRule implements ComparatorRule {
+
+	/**
+	 * This method determines whether the comparison rule is
+	 * associated with the supplied type.
+	 * 
+	 * @param obj The object to check
+	 * @return Whether the object is of a type supported by the
+	 * 					comparison rule
+	 */
+	public boolean isTypeSupported(ModelObject obj) {
+		return(obj instanceof Parallel);
+	}
+	
+	/**
+	 * This method determines whether the comparison rule is
+	 * appropriate for the supplied model objects.
+	 * 
+	 * @param main The main model object to be compared
+	 * @param ref The reference model object to be compared against
+	 * @return Whether the rule is relevant for the
+	 * 				model objects
+	 */
+	public boolean isComparisonSupported(ModelObject main, ModelObject ref) {
+		return(main instanceof Parallel &&
+				ref instanceof Parallel);
+	}
+	
+	/**
+	 * This method compares a model object against a reference
+	 * component to determine if they are equal.
+	 * 
+	 * @param context The context
+	 * @param main The main model object
+	 * @param reference The reference model object
+	 * @param l The model listener
+	 * @param deep Perform a deep compare
+	 * @return Whether the model objects are comparable
+	 */
+	public boolean compare(ComparatorContext context, ModelObject main,
+					ModelObject reference, ModelListener l, boolean deep) {
+		boolean ret=false;
+
+		if (deep == false) {
+			// Shallow, so return true as both same type
+			ret = true;
+		} else {
+			
+			// TODO: Decide how children should be dealt with
+			
+			// Check children - however not defined how the comparison
+			// should be done between multi-path
+		}
+		
+		return(ret);
+	}	
+}

Added: trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/RaiseComparatorRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/RaiseComparatorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/RaiseComparatorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 10 Nov 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.comparator;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.comparator.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class provides the Conversation Raise to another
+ * Raise comparator rule.
+ */
+ at RegistryInfo(extension=ComparatorRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class RaiseComparatorRule implements ComparatorRule {
+
+	/**
+	 * This method determines whether the comparison rule is
+	 * associated with the supplied type.
+	 * 
+	 * @param obj The object to check
+	 * @return Whether the object is of a type supported by the
+	 * 					comparison rule
+	 */
+	public boolean isTypeSupported(ModelObject obj) {
+		return(obj instanceof Raise);
+	}
+	
+	/**
+	 * This method determines whether the comparison rule is
+	 * appropriate for the supplied model objects.
+	 * 
+	 * @param main The main model object to be compared
+	 * @param ref The reference model object to be compared against
+	 * @return Whether the rule is relevant for the
+	 * 				model objects
+	 */
+	public boolean isComparisonSupported(ModelObject main, ModelObject ref) {
+		return(main instanceof Raise &&
+				ref instanceof Raise);
+	}
+	
+	/**
+	 * This method compares a model object against a reference
+	 * component to determine if they are equal.
+	 * 
+	 * @param context The context
+	 * @param main The main model object
+	 * @param reference The reference model object
+	 * @param l The model listener
+	 * @param deep Perform a deep compare
+	 * @return Whether the model objects are comparable
+	 */
+	public boolean compare(ComparatorContext context, ModelObject main,
+					ModelObject reference, ModelListener l, boolean deep) {
+		boolean ret=false;
+		Raise raisem=(Raise)main;
+		Raise raiseref=(Raise)reference;
+		
+		if (deep == false) {
+			
+			if (raisem.getType() != null &&
+					raiseref.getType() != null) {
+				ret = context.compare(raisem.getType(),
+						raiseref.getType(), l, deep);
+				
+				// TODO: Check role is appropriate
+				// May depend whether global or local models
+				// If local models, then only matters whether
+				// projected role is either present or absent
+				// in both lists - if global, then may need
+				// to be matched lists
+			}
+		}
+
+		return(ret);
+	}	
+}

Added: trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/SpawnComparatorRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/SpawnComparatorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/SpawnComparatorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 20 Aug 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.comparator;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.comparator.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class provides the Conversation Spawn to another
+ * Spawn comparator rule.
+ */
+ at RegistryInfo(extension=ComparatorRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class SpawnComparatorRule implements ComparatorRule {
+
+	/**
+	 * This method determines whether the comparison rule is
+	 * associated with the supplied type.
+	 * 
+	 * @param obj The object to check
+	 * @return Whether the object is of a type supported by the
+	 * 					comparison rule
+	 */
+	public boolean isTypeSupported(ModelObject obj) {
+		return(obj instanceof Spawn);
+	}
+	
+	/**
+	 * This method determines whether the comparison rule is
+	 * appropriate for the supplied model objects.
+	 * 
+	 * @param main The main model object to be compared
+	 * @param ref The reference model object to be compared against
+	 * @return Whether the rule is relevant for the
+	 * 				model objects
+	 */
+	public boolean isComparisonSupported(ModelObject main, ModelObject ref) {
+		return(main instanceof Spawn &&
+				ref instanceof Spawn);
+	}
+	
+	/**
+	 * This method compares a model object against a reference
+	 * component to determine if they are equal.
+	 * 
+	 * @param context The context
+	 * @param main The main model object
+	 * @param reference The reference model object
+	 * @param l The model listener
+	 * @param deep Perform a deep compare
+	 * @return Whether the model objects are comparable
+	 */
+	public boolean compare(ComparatorContext context, ModelObject main,
+					ModelObject reference, ModelListener l, boolean deep) {
+		boolean ret=true;
+		
+		return(ret);
+	}	
+}

Added: trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/TryEscapeComparatorRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/TryEscapeComparatorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/TryEscapeComparatorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 10 Nov 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.comparator;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.comparator.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class provides the Conversation TryEscape to another
+ * TryEscape comparator rule.
+ */
+ at RegistryInfo(extension=ComparatorRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class TryEscapeComparatorRule implements ComparatorRule {
+
+	/**
+	 * This method determines whether the comparison rule is
+	 * associated with the supplied type.
+	 * 
+	 * @param obj The object to check
+	 * @return Whether the object is of a type supported by the
+	 * 					comparison rule
+	 */
+	public boolean isTypeSupported(ModelObject obj) {
+		return(obj instanceof TryEscape);
+	}
+	
+	/**
+	 * This method determines whether the comparison rule is
+	 * appropriate for the supplied model objects.
+	 * 
+	 * @param main The main model object to be compared
+	 * @param ref The reference model object to be compared against
+	 * @return Whether the rule is relevant for the
+	 * 				model objects
+	 */
+	public boolean isComparisonSupported(ModelObject main, ModelObject ref) {
+		return(main instanceof TryEscape &&
+				ref instanceof TryEscape);
+	}
+	
+	/**
+	 * This method compares a model object against a reference
+	 * component to determine if they are equal.
+	 * 
+	 * @param context The context
+	 * @param main The main model object
+	 * @param reference The reference model object
+	 * @param l The model listener
+	 * @param deep Perform a deep compare
+	 * @return Whether the model objects are comparable
+	 */
+	public boolean compare(ComparatorContext context, ModelObject main,
+					ModelObject reference, ModelListener l, boolean deep) {
+		boolean ret=false;
+
+		if (deep == false) {
+			// Shallow, so return true as both choice
+			ret = true;
+		} else {
+			
+			// TODO: Decide how children should be dealt with
+			
+			// Check children - however not defined how the comparison
+			// should be done between multi-path
+		}
+		
+		return(ret);
+	}	
+}

Added: trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/WhenComparatorRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/WhenComparatorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/WhenComparatorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 17 Jul 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.comparator;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.comparator.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class provides the Conversation When to another
+ * When comparator rule.
+ */
+ at RegistryInfo(extension=ComparatorRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class WhenComparatorRule implements ComparatorRule {
+
+	/**
+	 * This method determines whether the comparison rule is
+	 * associated with the supplied type.
+	 * 
+	 * @param obj The object to check
+	 * @return Whether the object is of a type supported by the
+	 * 					comparison rule
+	 */
+	public boolean isTypeSupported(ModelObject obj) {
+		return(obj instanceof When);
+	}
+	
+	/**
+	 * This method determines whether the comparison rule is
+	 * appropriate for the supplied model objects.
+	 * 
+	 * @param main The main model object to be compared
+	 * @param ref The reference model object to be compared against
+	 * @return Whether the rule is relevant for the
+	 * 				model objects
+	 */
+	public boolean isComparisonSupported(ModelObject main, ModelObject ref) {
+		return(main instanceof When &&
+				ref instanceof When);
+	}
+	
+	/**
+	 * This method compares a model object against a reference
+	 * component to determine if they are equal.
+	 * 
+	 * @param context The context
+	 * @param main The main model object
+	 * @param reference The reference model object
+	 * @param l The model listener
+	 * @param deep Perform a deep compare
+	 * @return Whether the model objects are comparable
+	 */
+	public boolean compare(ComparatorContext context, ModelObject main,
+					ModelObject reference, ModelListener l, boolean deep) {
+		boolean ret=false;
+
+		if (deep == false) {
+			// Shallow, so return true as both When
+			ret = true;
+		} else {
+			
+			// TODO: Decide how children should be dealt with
+			
+			// Check children - however not defined how the comparison
+			// should be done between multi-path
+		}
+		
+		return(ret);
+	}	
+}

Added: trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/WhileComparatorRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/WhileComparatorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/WhileComparatorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 17 Jul 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.comparator;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.comparator.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class provides the Conversation While to another
+ * While comparator rule.
+ */
+ at RegistryInfo(extension=ComparatorRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class WhileComparatorRule implements ComparatorRule {
+
+	/**
+	 * This method determines whether the comparison rule is
+	 * associated with the supplied type.
+	 * 
+	 * @param obj The object to check
+	 * @return Whether the object is of a type supported by the
+	 * 					comparison rule
+	 */
+	public boolean isTypeSupported(ModelObject obj) {
+		return(obj instanceof While);
+	}
+	
+	/**
+	 * This method determines whether the comparison rule is
+	 * appropriate for the supplied model objects.
+	 * 
+	 * @param main The main model object to be compared
+	 * @param ref The reference model object to be compared against
+	 * @return Whether the rule is relevant for the
+	 * 				model objects
+	 */
+	public boolean isComparisonSupported(ModelObject main, ModelObject ref) {
+		return(main instanceof While &&
+				ref instanceof While);
+	}
+	
+	/**
+	 * This method compares a model object against a reference
+	 * component to determine if they are equal.
+	 * 
+	 * @param context The context
+	 * @param main The main model object
+	 * @param reference The reference model object
+	 * @param l The model listener
+	 * @param deep Perform a deep compare
+	 * @return Whether the model objects are comparable
+	 */
+	public boolean compare(ComparatorContext context, ModelObject main,
+					ModelObject reference, ModelListener l, boolean deep) {
+		boolean ret=false;
+
+		if (deep == false) {
+			// Shallow, so return true as both while
+			ret = true;
+		} else {
+			
+			// TODO: Decide how children should be dealt with
+			
+			// Check children - however not defined how the comparison
+			// should be done between multi-path
+		}
+		
+		return(ret);
+	}	
+}

Added: trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/model/transform/ConversationInteractionStatelessTransformationRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/model/transform/ConversationInteractionStatelessTransformationRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/model/transform/ConversationInteractionStatelessTransformationRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 13 Jan 2009 : Initial version created by gary
+ */
+package org.scribble.conversation.comparator.model.transform;
+
+import org.scribble.conformance.model.transform.*;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This class provides the conversation specific
+ * stateless transformation rule for the Run construct.
+ */
+ at RegistryInfo(extension=StatelessTransformationRule.class,
+				notation=ConversationNotation.NOTATION_CODE)
+			//category=Interaction.class,preference=10)
+public class ConversationInteractionStatelessTransformationRule 
+					extends InteractionStatelessTransformationRule {
+
+	/**
+	 * This method determines whether the stateless
+	 * transformation rule is applicable to the
+	 * supplied model object.
+	 * 
+	 * @param modelObject The model object
+	 * @return Whether the model object can be transformed
+	 */
+	public boolean isSupported(ModelObject modelObject) {
+		return(modelObject instanceof ConversationInteraction);
+	}
+	
+	/**
+	 * This method returns the new interaction.
+	 * 
+	 * @return The new interaction
+	 */
+	@Override
+	protected Interaction createInteraction() {
+		return(new ConversationInteraction());
+	}
+	
+	/**
+	 * This method transforms the supplied model object into
+	 * a stateless equivalent.
+	 * 
+	 * @param context The context
+	 * @param modelObject The model object to transform
+	 * @return The transformed object
+	 */
+	public ModelObject transform(StatelessTransformationContext context,
+						ModelObject modelObject) {
+		ConversationInteraction ret=(ConversationInteraction)
+						super.transform(context, modelObject);
+		ConversationInteraction src=(ConversationInteraction)modelObject;
+
+		// TODO: Convert other aspects of interaction associated with
+		// derived conversation interaction class
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/model/transform/ConversationStatelessTransformationRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/model/transform/ConversationStatelessTransformationRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/model/transform/ConversationStatelessTransformationRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 7 Dec 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.comparator.model.transform;
+
+import org.scribble.conformance.model.transform.*;
+import org.scribble.model.Definition;
+import org.scribble.model.ModelObject;
+import org.scribble.model.MultiPathBehaviour;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This class provides the conversation specific
+ * stateless transformation rule.
+ */
+ at RegistryInfo(extension=StatelessTransformationRule.class)
+public class ConversationStatelessTransformationRule
+					extends AbstractDefinitionStatelessTransformationRule {
+
+	/**
+	 * This method returns a new definition of the appropriate
+	 * type.
+	 * 
+	 * @param context The context
+	 * @return The definition
+	 */
+	@Override
+	protected Definition createDefinition(StatelessTransformationContext context) {
+		return(new Conversation());
+	}
+	
+	/**
+	 * This method returns a new multi-path behaviour, of the
+	 * appropriate type, to represent the mutually exclusive
+	 * choice construct at the top level of the stateless definition.
+	 * 
+	 * @param context The context
+	 * @return The multi-path behaviour
+	 */
+	@Override
+	protected MultiPathBehaviour createMultiPathBehaviour(StatelessTransformationContext context) {
+		return(new If());
+	}
+	
+	/**
+	 * This method determines whether the stateless
+	 * transformation rule is applicable to the
+	 * supplied model object.
+	 * 
+	 * @param modelObject The model object
+	 * @return Whether the model object can be transformed
+	 */
+	public boolean isSupported(ModelObject modelObject) {
+		return(modelObject instanceof Conversation);
+	}
+	
+}

Added: trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/model/transform/IfStatelessTransformationRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/model/transform/IfStatelessTransformationRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/model/transform/IfStatelessTransformationRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 17 Dec 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.comparator.model.transform;
+
+import org.scribble.conformance.model.transform.*;
+import org.scribble.model.Block;
+import org.scribble.model.ModelObject;
+import org.scribble.model.Role;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This class provides the conversation specific
+ * stateless transformation rule for the If construct.
+ */
+ at RegistryInfo(extension=StatelessTransformationRule.class)
+public class IfStatelessTransformationRule
+				extends AbstractStatelessTransformationRule {
+
+	/**
+	 * This method determines whether the stateless
+	 * transformation rule is applicable to the
+	 * supplied model object.
+	 * 
+	 * @param modelObject The model object
+	 * @return Whether the model object can be transformed
+	 */
+	public boolean isSupported(ModelObject modelObject) {
+		return(modelObject instanceof If &&
+				((If)modelObject).isWaitState() == false);
+	}
+	
+	/**
+	 * This method transforms the supplied model object into
+	 * a stateless equivalent.
+	 * 
+	 * @param context The context
+	 * @param modelObject The model object to transform
+	 * @return The transformed object
+	 */
+	public ModelObject transform(StatelessTransformationContext context,
+							ModelObject modelObject) {
+		If ret=new If();
+		If src=(If)modelObject;
+		
+		for (int i=0; i < src.getRoles().size(); i++) {
+			Role r=(Role)context.transform(src.getRoles().get(i));
+			
+			if (r != null) {
+				((If)ret).getRoles().add(r);
+			}
+		}
+	
+		ret.derivedFrom(src);
+		
+		for (int i=0; i < src.getConditionalBlocks().size(); i++) {
+			Block path=ret.createNewPath();
+			
+			context.transform(src.getConditionalBlocks().get(i), path);
+		}
+		
+		if (src.getElseBlock() != null) {
+			Block path=new Block();
+			ret.setElseBlock(path);
+			
+			context.transform(src.getElseBlock(), path);
+		}
+		
+		return(ret);
+	}
+	
+}

Added: trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/model/transform/ParallelStatelessTransformationRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/model/transform/ParallelStatelessTransformationRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/model/transform/ParallelStatelessTransformationRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 6 Jan 2009 : Initial version created by gary
+ */
+package org.scribble.conversation.comparator.model.transform;
+
+import org.scribble.conformance.model.transform.*;
+import org.scribble.model.Block;
+import org.scribble.model.ModelObject;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This class provides the conversation specific
+ * stateless transformation rule for the Parallel construct.
+ */
+ at RegistryInfo(extension=StatelessTransformationRule.class)
+public class ParallelStatelessTransformationRule
+				extends AbstractStatelessTransformationRule {
+
+	/**
+	 * This method determines whether the stateless
+	 * transformation rule is applicable to the
+	 * supplied model object.
+	 * 
+	 * @param modelObject The model object
+	 * @return Whether the model object can be transformed
+	 */
+	public boolean isSupported(ModelObject modelObject) {
+		return(modelObject instanceof Parallel);
+	}
+	
+	/**
+	 * This method transforms the supplied model object into
+	 * a stateless equivalent.
+	 * 
+	 * @param context The context
+	 * @param modelObject The model object to transform
+	 * @return The transformed object
+	 */
+	public ModelObject transform(StatelessTransformationContext context,
+							ModelObject modelObject) {
+		Parallel ret=new Parallel();
+		Parallel src=(Parallel)modelObject;
+		
+		ret.derivedFrom(src);
+		
+		for (int i=0; i < src.getBlocks().size(); i++) {
+			Block path=ret.createNewPath();
+			
+			context.transform(src.getBlocks().get(i), path);
+		}
+		
+		return(ret);
+	}
+	
+}

Added: trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/model/transform/RunStatelessTransformationRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/model/transform/RunStatelessTransformationRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/model/transform/RunStatelessTransformationRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 13 Jan 2009 : Initial version created by gary
+ */
+package org.scribble.conversation.comparator.model.transform;
+
+import org.scribble.conformance.model.transform.*;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This class provides the conversation specific
+ * stateless transformation rule for the Run construct.
+ */
+ at RegistryInfo(extension=StatelessTransformationRule.class)
+public class RunStatelessTransformationRule 
+					extends AbstractStatelessTransformationRule {
+
+	/**
+	 * This method determines whether the stateless
+	 * transformation rule is applicable to the
+	 * supplied model object.
+	 * 
+	 * @param modelObject The model object
+	 * @return Whether the model object can be transformed
+	 */
+	public boolean isSupported(ModelObject modelObject) {
+		return(modelObject instanceof Run);
+	}
+	
+	/**
+	 * This method transforms the supplied model object into
+	 * a stateless equivalent.
+	 * 
+	 * @param context The context
+	 * @param modelObject The model object to transform
+	 * @return The transformed object
+	 */
+	public ModelObject transform(StatelessTransformationContext context,
+						ModelObject modelObject) {
+		Block ret=new Block();
+		Run src=(Run)modelObject;
+		
+		Definition defn=src.getDefinition();
+		
+		if (defn != null) {
+			context.transform(defn.getBlock(), ret);
+			
+			// TODO: Deal with full and partial processing
+			// of run block.
+		}
+	
+		ret.derivedFrom(src);
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/model/transform/SpawnStatelessTransformationRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/model/transform/SpawnStatelessTransformationRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/model/transform/SpawnStatelessTransformationRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 13 Jan 2009 : Initial version created by gary
+ */
+package org.scribble.conversation.comparator.model.transform;
+
+import org.scribble.conformance.model.transform.*;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This class provides the conversation specific
+ * stateless transformation rule for the Spawn construct.
+ */
+ at RegistryInfo(extension=StatelessTransformationRule.class)
+public class SpawnStatelessTransformationRule 
+					extends AbstractStatelessTransformationRule {
+
+	/**
+	 * This method determines whether the stateless
+	 * transformation rule is applicable to the
+	 * supplied model object.
+	 * 
+	 * @param modelObject The model object
+	 * @return Whether the model object can be transformed
+	 */
+	public boolean isSupported(ModelObject modelObject) {
+		return(modelObject instanceof Spawn);
+	}
+	
+	/**
+	 * This method transforms the supplied model object into
+	 * a stateless equivalent.
+	 * 
+	 * @param context The context
+	 * @param modelObject The model object to transform
+	 * @return The transformed object
+	 */
+	public ModelObject transform(StatelessTransformationContext context,
+						ModelObject modelObject) {
+		Block ret=new Block();
+		Spawn src=(Spawn)modelObject;
+		
+		Definition defn=src.getDefinition();
+		
+		// TODO: May need to create parallel construct,
+		// with one path for the spawned definition
+		// and another for the post-spawn activities. But
+		// this will require the sequence vs parallel
+		// conformance to be handled
+		
+		//if (defn != null) {
+		//	context.transform(defn.getBlock(), ret);
+		//}
+	
+		ret.derivedFrom(src);
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/model/transform/WhileStatelessTransformationRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/model/transform/WhileStatelessTransformationRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/model/transform/WhileStatelessTransformationRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,155 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 18 Dec 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.comparator.model.transform;
+
+import org.scribble.conformance.model.transform.*;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This class provides the conversation specific
+ * stateless transformation rule for the While construct.
+ */
+ at RegistryInfo(extension=StatelessTransformationRule.class)
+public class WhileStatelessTransformationRule 
+					extends AbstractStatelessTransformationRule {
+
+	/**
+	 * This method determines whether the stateless
+	 * transformation rule is applicable to the
+	 * supplied model object.
+	 * 
+	 * @param modelObject The model object
+	 * @return Whether the model object can be transformed
+	 */
+	public boolean isSupported(ModelObject modelObject) {
+		return(modelObject instanceof While &&
+				((While)modelObject).isWaitState() == false);
+	}
+	
+	/**
+	 * This method transforms the supplied model object into
+	 * a stateless equivalent.
+	 * 
+	 * @param context The context
+	 * @param modelObject The model object to transform
+	 * @return The transformed object
+	 */
+	public ModelObject transform(StatelessTransformationContext context,
+						ModelObject modelObject) {
+		Behaviour ret=null;
+		While src=(While)modelObject;
+		
+		// NOTE: Need to determine if should be 'while', if all
+		// contents are not wait states, and an 'if' if
+		// only translating part of the while loop contents.
+		// If using the 'if', then need to also place activities
+		// following the while into an 'else' path.
+		
+		ConditionalBlock cb=new ConditionalBlock();
+		
+		if (context.transform(src.getBlock(), cb)) {
+			ret = new While();
+			
+			for (int i=0; i < src.getRoles().size(); i++) {
+				Role r=(Role)context.transform(src.getRoles().get(i));
+				
+				if (r != null) {
+					((While)ret).getRoles().add(r);
+				}
+			}
+		
+			((While)ret).setBlock(cb);
+			
+			// TODO: Need to be able to cater for situation
+			// where while contents are fully processed
+			// and therefore the subsequent activities
+			// need to be further processed. Currently
+			// the assumption is that the subsequent
+			// activities will be processed as part of
+			// the block contents. Might need to return
+			// a block, and have a means of transferring
+			// into the block that would normally add
+			// the While.
+		} else {
+			ret = new If();
+			
+			for (int i=0; i < src.getRoles().size(); i++) {
+				Role r=(Role)context.transform(src.getRoles().get(i));
+				
+				if (r != null) {
+					((If)ret).getRoles().add(r);
+				}
+			}
+		
+			((If)ret).getConditionalBlocks().add(cb);
+			
+			Block elseBlock=new Block();
+			
+			// Came to end of block, so check if state from
+			// parent construct has been stored to enable
+			// further processing
+			//java.util.List<TransformState> stack=
+			//				context.getStack();
+			boolean f_continue=true;
+			
+			java.util.List<TransformState> tmpstack=
+					new java.util.Vector<TransformState>();
+			TransformState bp=null;
+		
+			//for (int i=0; f_continue && i < stack.size(); i++) {
+			//	TransformState bp=stack.get(i);
+				
+			while (f_continue && (bp=context.pop()) != null) {
+				
+				tmpstack.add(bp);
+
+				// TODO: Possibly check for 'parent' object
+				// that is repetition and also whether it
+				// is completely defined within the same
+				// block - can this be done based on checking
+				// the stack?
+				
+				if (bp.getParent() != src &&
+						bp.getParent() instanceof SinglePathBehaviour &&
+						bp.getParent().isWaitState() == false &&
+						((SinglePathBehaviour)bp.getParent()).isRepetition()) {
+					f_continue = false;
+
+				} else {
+					f_continue = BlockStatelessTransformationRule.processBlock(context, bp.getBlock(),
+								elseBlock, bp.getPosition()+1, false);
+				}
+			}
+			
+			for (int i=tmpstack.size()-1; i >= 0; i--) {
+				context.push(tmpstack.get(i));
+			}
+			
+			((If)ret).setElseBlock(elseBlock);
+
+		}
+	
+		ret.derivedFrom(src);
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/osgi/Activator.java
===================================================================
--- trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/osgi/Activator.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.comparator/src/main/java/org/scribble/conversation/comparator/osgi/Activator.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,48 @@
+package org.scribble.conversation.comparator.osgi;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator implements BundleActivator {
+
+	// The plug-in ID
+	public static final String PLUGIN_ID = "org.scribble.experimental.conversation.comparator";
+
+	// The shared instance
+	private static Activator plugin;
+	
+	/**
+	 * The constructor
+	 */
+	public Activator() {
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
+	 */
+	public void start(BundleContext context) throws Exception {
+		plugin = this;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
+	 */
+	public void stop(BundleContext context) throws Exception {
+		plugin = null;
+	}
+
+	/**
+	 * Returns the shared instance
+	 *
+	 * @return the shared instance
+	 */
+	public static Activator getDefault() {
+		return plugin;
+	}
+
+}

Added: trunk/bundles/org.scribble.conversation.comparator/src/plugintest/org/scribble/conversation/comparator/model/transform/TransformTest.java
===================================================================
--- trunk/bundles/org.scribble.conversation.comparator/src/plugintest/org/scribble/conversation/comparator/model/transform/TransformTest.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.comparator/src/plugintest/org/scribble/conversation/comparator/model/transform/TransformTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,278 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.scribble.conversation.comparator.model.transform;
+
+import junit.framework.TestCase;
+import junit.framework.TestResult;
+import junit.framework.TestSuite;
+
+import org.scribble.conformance.model.transform.StatelessTransformer;
+import org.scribble.extensions.RegistryFactory;
+import org.scribble.model.Definition;
+
+public class TransformTest extends TestCase {
+
+    public static TestSuite suite() {
+        TestSuite suite = new TestSuite("Stateful -> Stateless Transform Tests");
+        
+        suite.addTest(new StatefulToStatelessTest("ESBBroker", "Broker", "scv"));
+        
+        suite.addTest(new StatefulToStatelessTest("InteractionRun1", "R2", "scv"));
+        
+        return suite;
+    }
+    
+    /**
+     * The test case for running the stateful to stateless test.
+     */
+	protected static class StatefulToStatelessTest extends TestCase {
+
+		/**
+		 * This constructor is initialized with the test
+		 * name.
+		 * 
+		 * @param name The test name
+		 * @param role The role
+		 * @param notation The notation
+		 */
+		public StatefulToStatelessTest(String name,
+							String role, String notation) {
+			super(name+"@"+role+"."+notation);
+			
+			m_name = name+"@"+role+"."+notation;
+			m_role = role;
+			m_notation = notation;
+		}
+		
+		/**
+		 * This method runs the test.
+		 * 
+		 * @param result The test result
+		 */
+		public void run(TestResult result) {
+			result.startTest(this);
+			
+			String filename="testmodels/"+m_name;
+			
+			java.io.InputStream is=
+				TransformTest.class.getResourceAsStream(filename);
+			
+			if (is == null) {
+				result.addError(this,
+						new Throwable("Unable to locate resource: "+filename));
+			} else {			
+				org.scribble.parser.Parser p=new org.scribble.parser.DefaultParser();
+				org.scribble.model.ModelReference ref=
+						new org.scribble.model.ModelReference(m_notation);
+				org.scribble.model.admin.ModelListener l=
+						new org.scribble.model.admin.DefaultModelListener();
+				
+				org.scribble.model.Model model=p.parse(ref, is, l, null);
+				
+				if (model == null) {
+					result.addError(this, new Throwable("Model is null"));
+				} else {
+					
+					/*
+					org.scribble.projector.Projector projector=
+						new org.scribble.projector.DefaultProjector();
+					*/
+					
+					//org.scribble.model.Role role=null;
+					
+					// Obtain role from definition
+					java.util.List<Definition> defns=model.getDefinitions();
+					Definition defn=null;
+					
+					if (defns.size() == 1) {
+						defn = defns.get(0);
+					}
+					
+					/*
+					java.util.List<org.scribble.model.Role> roles=defn.getRoles();
+					
+					for (int i=0; role == null && i < roles.size(); i++) {
+						if (roles.get(i).getName().equals(m_role)) {
+							role = roles.get(i);
+						}
+					}
+					
+					if (role == null) {
+						result.addError(this,
+								new Throwable("Role '"+m_role+"' not found"));						
+					} else {
+					*/
+						//org.scribble.model.Model projected=
+						//		projector.project(ref, model,role, l);
+						
+						StatelessTransformer transformer=(StatelessTransformer)
+								RegistryFactory.getRegistry().getExtension(
+										StatelessTransformer.class, null);
+					
+						defns = model.getDefinitions();
+						defn = null;
+						
+						if (defns.size() == 1) {
+							defn = defns.get(0);
+						}
+						
+						if (transformer != null && defn != null) {
+							
+							org.scribble.model.Definition transformed=
+										transformer.transform(defn, ref);
+							
+							org.scribble.export.Exporter exporter=
+								(org.scribble.export.Exporter)
+								RegistryFactory.getRegistry().getExtension(
+										org.scribble.export.Exporter.class, null);
+
+							org.scribble.export.text.TextFormatter formatter=
+								new org.scribble.export.text.TextFormatter();
+							
+							java.io.ByteArrayOutputStream os=
+								new java.io.ByteArrayOutputStream();
+							
+							formatter.setOutputStream(os);
+								
+							try {
+								exporter.export(ref, transformed, formatter);
+								
+								String text=new String(os.toByteArray());
+
+								checkResults(result, text);
+							} catch(Exception e) {
+								result.addError(this, e);
+							}
+							
+						} else {
+							result.addError(this,
+									new Throwable("Unable to find Model Generator"));						
+						}
+					//}
+				}
+			}
+			
+			result.endTest(this);
+		}
+		
+		/**
+		 * This method checks the generated stateless against a
+		 * previously stored correct version.
+		 * 
+		 * @param result The test result
+		 * @param text The stateless definition
+		 */
+		protected void checkResults(TestResult result, String text) {
+			boolean f_valid=false;
+
+			String filename="results/"+m_name;
+			
+			java.io.InputStream is=
+				TransformTest.class.getResourceAsStream(filename);
+			
+			if (is != null) {
+				
+				try {
+					byte[] b=new byte[is.available()];
+				
+					is.read(b);
+					
+					is.close();
+					
+					String orig=new String(b);
+					
+					if (orig.equals(text) == false) {
+						result.addError(this,
+								new Throwable("Transformed stateless definition does not match stored version"));
+					} else {
+						f_valid = true;
+					}
+				} catch(Exception e) {
+					result.addError(this, e);
+				}
+			} else {
+				result.addError(this,
+						new Throwable("Resulting stateless definition '"+filename+
+								"' not found for comparison"));
+			}
+			
+			if (f_valid == false) {
+				String modelfile="testmodels/"+m_name;
+				
+				java.net.URL url=TransformTest.class.getResource(modelfile);
+				
+				try {
+					url = org.eclipse.core.runtime.FileLocator.toFileURL(url);
+				} catch(Exception e) {
+					e.printStackTrace();
+				}
+				
+				if (url != null) {
+					// URL will point to copy of test models in the classes folder, so need
+					// to obtain reference back to source version
+					java.io.File f=null;
+					
+					if (url.getFile().indexOf("classes") != -1) {
+						f = new java.io.File(url.getFile().replaceFirst("classes","src/plugintest"));
+					} else if (url.getFile().indexOf("bin") != -1) {						
+						f = new java.io.File(url.getFile().replaceFirst("bin","src/plugintest"));
+					} else {
+						result.addError(this, new Exception("Could not locate results folder to record expected result"));
+					}
+					
+					if (f != null && f.exists()) {
+						f = f.getParentFile().getParentFile();
+						
+						java.io.File resultsDir=new java.io.File(f, "results");
+						
+						if (resultsDir.exists() == false) {
+							resultsDir.mkdirs();
+						}
+						
+						java.io.File resultFile=new java.io.File(resultsDir,
+											m_name+".expected");
+						
+						if (resultFile.exists() == false) {
+							try {
+								java.io.FileOutputStream fos=new java.io.FileOutputStream(resultFile);
+								
+								fos.write(text.getBytes());
+								
+								fos.flush();
+								fos.close();
+								
+							} catch(Exception e){
+								result.addError(this, e);
+							}
+						} else {
+							System.err.println("NOTE: Expected output '"+resultFile+
+										"' already exists - not being overwritten");
+						}
+					} else {
+						result.addError(this, new Throwable("Unable to obtain URL for stateful model source '"+
+								m_name+"': "+url));
+					}
+				}
+			}
+		}
+
+		private String m_name=null;
+		private String m_role=null;
+		private String m_notation=null;
+	}
+}

Added: trunk/bundles/org.scribble.conversation.comparator/src/plugintest/org/scribble/conversation/comparator/model/transform/results/ESBBroker at Broker.scv
===================================================================
--- trunk/bundles/org.scribble.conversation.comparator/src/plugintest/org/scribble/conversation/comparator/model/transform/results/ESBBroker at Broker.scv	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.comparator/src/plugintest/org/scribble/conversation/comparator/model/transform/results/ESBBroker at Broker.scv	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,32 @@
+stateless conversation ESBBroker at Broker conforms to savara.samples.LoanBroker at Broker {
+	role	Buyer, SupplierQuoteEngine, Broker, CreditAgency, SupplierTxnProcessor;
+	if {
+		makeEnquiry(enquiry) from Buyer request "makeEnquiry";
+		if @ Broker {
+			getQuote(requestForQuote) to SupplierQuoteEngine request "getQuote";
+		} else {
+		}
+	} else if {
+		getQuote(quote) from SupplierQuoteEngine replyTo "getQuote";
+		if @ Broker {
+			getQuote(requestForQuote) to SupplierQuoteEngine request "getQuote";
+		} else {
+		}
+	} else if {
+		makeEnquiry(quoteList) to Buyer replyTo "makeEnquiry";
+	} else if {
+		buy(buy) from Buyer request "buy";
+		checkCredit(CreditCheckRequest) to CreditAgency request "checkCredit";
+	} else if {
+		checkCredit(CreditCheckOk) from CreditAgency replyTo "checkCredit";
+		confirm(orderConfirmed) to SupplierTxnProcessor request "confirm";
+	} else if {
+		confirm(bookingReference) from SupplierTxnProcessor replyTo "confirm";
+		buy(bookingReference) to Buyer replyTo "buy";
+	} else if {
+		checkCredit(CreditCheckInvalid) from CreditAgency replyTo "checkCredit";
+		buy(orderRejected) to Buyer replyTo "buy";
+	} else if {
+		cancel(cancel) from Buyer;
+	}
+}
\ No newline at end of file

Added: trunk/bundles/org.scribble.conversation.comparator/src/plugintest/org/scribble/conversation/comparator/model/transform/results/InteractionRun1 at R2.scv
===================================================================
--- trunk/bundles/org.scribble.conversation.comparator/src/plugintest/org/scribble/conversation/comparator/model/transform/results/InteractionRun1 at R2.scv	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.comparator/src/plugintest/org/scribble/conversation/comparator/model/transform/results/InteractionRun1 at R2.scv	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,10 @@
+stateless conversation Interaction1 at R2 {
+	role	R1;
+	if {
+		M1 from R1;
+		M2 to R1;
+	} else if {
+		M3 from R1;
+		M4 to R1;
+	}
+}
\ No newline at end of file

Added: trunk/bundles/org.scribble.conversation.comparator/src/plugintest/org/scribble/conversation/comparator/model/transform/testmodels/ESBBroker at Broker.scv
===================================================================
--- trunk/bundles/org.scribble.conversation.comparator/src/plugintest/org/scribble/conversation/comparator/model/transform/testmodels/ESBBroker at Broker.scv	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.comparator/src/plugintest/org/scribble/conversation/comparator/model/transform/testmodels/ESBBroker at Broker.scv	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,38 @@
+namespace test;
+
+conversation ESBBroker at Broker conforms to savara.samples.LoanBroker at Broker {
+	role	Buyer, CreditAgency, Supplier;
+	makeEnquiry(enquiry) from Buyer request "makeEnquiry";
+	while @ Broker {
+		run RequestForQuote at Broker;
+	}
+	when @ Broker {
+		makeEnquiry(quoteList) to Buyer replyTo "makeEnquiry";
+	}
+	if @ Buyer {
+		run CompleteTransaction at Broker (Buyer for Buyer,CreditAgency for CreditAgency);
+	} else if {
+		cancel(cancel) from Buyer;
+	}
+	conversation CompleteTransaction at Broker {
+		role	SupplierTxnProcessor;
+		role	Buyer, CreditAgency;
+		buy(buy) from Buyer request "buy";
+		checkCredit(CreditCheckRequest) to CreditAgency request "checkCredit";
+		if @ CreditAgency {
+			checkCredit(CreditCheckOk) from CreditAgency replyTo "checkCredit";
+			confirm(orderConfirmed) to SupplierTxnProcessor request "confirm";
+			confirm(bookingReference) from SupplierTxnProcessor replyTo "confirm";
+			buy(bookingReference) to Buyer replyTo "buy";
+		} else if {
+			checkCredit(CreditCheckInvalid) from CreditAgency replyTo "checkCredit";
+			buy(orderRejected) to Buyer replyTo "buy";
+		}
+	}
+	conversation RequestForQuote at Broker {
+		role	SupplierQuoteEngine;
+		role	;
+		getQuote(requestForQuote) to SupplierQuoteEngine request "getQuote";
+		getQuote(quote) from SupplierQuoteEngine replyTo "getQuote";
+	}
+}

Added: trunk/bundles/org.scribble.conversation.comparator/src/plugintest/org/scribble/conversation/comparator/model/transform/testmodels/InteractionRun1 at R2.scv
===================================================================
--- trunk/bundles/org.scribble.conversation.comparator/src/plugintest/org/scribble/conversation/comparator/model/transform/testmodels/InteractionRun1 at R2.scv	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.comparator/src/plugintest/org/scribble/conversation/comparator/model/transform/testmodels/InteractionRun1 at R2.scv	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,17 @@
+namespace test;
+
+conversation Interaction1 at R2 {
+	role	R1;
+	
+	M1 from R1;
+	M2 to R1;
+	
+	run Sub at R2(R1 for R1);
+	
+	conversation Sub at R2 {
+		role	R1;
+		
+		M3 from R1;
+		M4 to R1;
+	}
+}

Added: trunk/bundles/org.scribble.conversation.comparator/src/test/org/scribble/conversation/comparator/CatchBlockComparatorRuleTest.java
===================================================================
--- trunk/bundles/org.scribble.conversation.comparator/src/test/org/scribble/conversation/comparator/CatchBlockComparatorRuleTest.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.comparator/src/test/org/scribble/conversation/comparator/CatchBlockComparatorRuleTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,179 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 1 Mar 2009 : Initial version created by gary
+ */
+package org.scribble.conversation.comparator;
+
+import org.scribble.extensions.RegistryFactory;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+import org.scribble.model.admin.DefaultModelListener;
+import org.scribble.comparator.*;
+
+import junit.framework.TestCase;
+
+public class CatchBlockComparatorRuleTest extends TestCase {
+
+	private static final String TEST_NOTATION = "test";
+
+	public void testCompareSameCatchType() {
+		CatchBlockComparatorRule rule=
+				new CatchBlockComparatorRule();
+		
+		RegistryFactory.setRegistry(null);
+		
+		DefaultModelListener l=new DefaultModelListener();
+		
+		java.util.List<ComparatorRule> rules=
+					new java.util.Vector<ComparatorRule>();
+		
+		rules.add(new TypeReferenceComparatorRule());
+		
+		DefaultComparatorContext context=
+			new DefaultComparatorContext(new ModelReference(TEST_NOTATION),
+						new ModelReference(TEST_NOTATION), rules);
+
+		CatchBlock main=new CatchBlock();
+		TypeReference mainType=new TypeReference();
+		mainType.setLocalpart("catchType");
+		main.setType(mainType);
+		
+		CatchBlock reference=new CatchBlock();
+		TypeReference refType=new TypeReference();
+		refType.setLocalpart("catchType");
+		reference.setType(refType);
+			
+		boolean result=rule.compare(context, main, reference, l, false);
+		
+		if (l.getErrors().size() > 0) {
+			fail("No errors expected");
+		}
+		
+		if (result == false) {
+			fail("Comparator should NOT have failed");
+		}
+	}
+
+	public void testCompareDiffTypes() {
+		CatchBlockComparatorRule rule=
+				new CatchBlockComparatorRule();
+		
+		RegistryFactory.setRegistry(null);
+		
+		DefaultModelListener l=new DefaultModelListener();
+		
+		java.util.List<ComparatorRule> rules=
+					new java.util.Vector<ComparatorRule>();
+		
+		rules.add(new TypeReferenceComparatorRule());
+		
+		DefaultComparatorContext context=
+			new DefaultComparatorContext(new ModelReference(TEST_NOTATION),
+						new ModelReference(TEST_NOTATION), rules);
+
+		CatchBlock main=new CatchBlock();
+		TypeReference mainType=new TypeReference();
+		mainType.setLocalpart("catchType1");
+		main.setType(mainType);
+		
+		CatchBlock reference=new CatchBlock();
+		TypeReference refType=new TypeReference();
+		refType.setLocalpart("catchType2");
+		reference.setType(refType);
+			
+		boolean result=rule.compare(context, main, reference, l, false);
+		
+		if (l.getErrors().size() != 1) {
+			fail("One error expected");
+		}
+		
+		if (result == true) {
+			fail("Comparator should have failed");
+		}
+	}
+
+	public void testCompareMissingMainCatchType() {
+		CatchBlockComparatorRule rule=
+				new CatchBlockComparatorRule();
+		
+		RegistryFactory.setRegistry(null);
+		
+		DefaultModelListener l=new DefaultModelListener();
+		
+		java.util.List<ComparatorRule> rules=
+					new java.util.Vector<ComparatorRule>();
+		
+		rules.add(new TypeReferenceComparatorRule());
+		
+		DefaultComparatorContext context=
+			new DefaultComparatorContext(new ModelReference(TEST_NOTATION),
+						new ModelReference(TEST_NOTATION), rules);
+
+		CatchBlock main=new CatchBlock();
+		
+		CatchBlock reference=new CatchBlock();
+		TypeReference refType=new TypeReference();
+		refType.setLocalpart("catchType");
+		reference.setType(refType);
+			
+		boolean result=rule.compare(context, main, reference, l, false);
+		
+		if (l.getErrors().size() > 0) {
+			fail("No errors expected");
+		}
+		
+		if (result == false) {
+			fail("Comparator should NOT have failed");
+		}
+	}
+
+	public void testCompareMissingRefCatchType() {
+		CatchBlockComparatorRule rule=
+				new CatchBlockComparatorRule();
+		
+		RegistryFactory.setRegistry(null);
+		
+		DefaultModelListener l=new DefaultModelListener();
+		
+		java.util.List<ComparatorRule> rules=
+					new java.util.Vector<ComparatorRule>();
+		
+		rules.add(new TypeReferenceComparatorRule());
+		
+		DefaultComparatorContext context=
+			new DefaultComparatorContext(new ModelReference(TEST_NOTATION),
+						new ModelReference(TEST_NOTATION), rules);
+
+		CatchBlock main=new CatchBlock();
+		TypeReference mainType=new TypeReference();
+		mainType.setLocalpart("catchType");
+		main.setType(mainType);
+		
+		CatchBlock reference=new CatchBlock();
+			
+		boolean result=rule.compare(context, main, reference, l, false);
+		
+		if (l.getErrors().size() > 0) {
+			fail("No errors expected");
+		}
+		
+		if (result == false) {
+			fail("Comparator should NOT have failed");
+		}
+	}
+}

Added: trunk/bundles/org.scribble.conversation.comparator/src/test/org/scribble/conversation/comparator/ConditionalBlockComparatorRuleTest.java
===================================================================
--- trunk/bundles/org.scribble.conversation.comparator/src/test/org/scribble/conversation/comparator/ConditionalBlockComparatorRuleTest.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.comparator/src/test/org/scribble/conversation/comparator/ConditionalBlockComparatorRuleTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 2 Mar 2009 : Initial version created by gary
+ */
+package org.scribble.conversation.comparator;
+
+import org.scribble.extensions.RegistryFactory;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+import org.scribble.model.admin.DefaultModelListener;
+import org.scribble.comparator.*;
+
+import junit.framework.TestCase;
+
+public class ConditionalBlockComparatorRuleTest extends TestCase {
+
+	private static final String TEST_NOTATION = "test";
+
+	public void testCompareNoExpression() {
+		ConditionalBlockComparatorRule rule=
+				new ConditionalBlockComparatorRule();
+		
+		RegistryFactory.setRegistry(null);
+		
+		DefaultModelListener l=new DefaultModelListener();
+		
+		java.util.List<ComparatorRule> rules=
+					new java.util.Vector<ComparatorRule>();
+		
+		DefaultComparatorContext context=
+			new DefaultComparatorContext(new ModelReference(TEST_NOTATION),
+						new ModelReference(TEST_NOTATION), rules);
+
+		ConditionalBlock main=new ConditionalBlock();
+		ConditionalBlock reference=new ConditionalBlock();
+		
+		boolean result=rule.compare(context, main, reference, l, false);
+		
+		if (l.getErrors().size() > 0) {
+			fail("No errors expected");
+		}
+		
+		if (result == false) {
+			fail("Comparator should NOT have failed");
+		}
+	}
+	
+	// TODO: Decide whether compare should check for
+	// equivalent expressions?
+}

Added: trunk/bundles/org.scribble.conversation.comparator/src/test/org/scribble/conversation/comparator/ConversationComparatorRuleTest.java
===================================================================
--- trunk/bundles/org.scribble.conversation.comparator/src/test/org/scribble/conversation/comparator/ConversationComparatorRuleTest.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.comparator/src/test/org/scribble/conversation/comparator/ConversationComparatorRuleTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,490 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 2 Mar 2009 : Initial version created by gary
+ */
+package org.scribble.conversation.comparator;
+
+import org.scribble.extensions.RegistryFactory;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+import org.scribble.model.admin.DefaultModelListener;
+import org.scribble.comparator.*;
+import org.scribble.conformance.comparator.*;
+
+import junit.framework.TestCase;
+
+public class ConversationComparatorRuleTest extends TestCase {
+
+	private static final String TEST_NOTATION = "test";
+
+	public void testCompare() {
+		ConversationComparatorRule rule=
+				new ConversationComparatorRule();
+		
+		RegistryFactory.setRegistry(null);
+		
+		DefaultModelListener l=new DefaultModelListener();
+		
+		java.util.List<ComparatorRule> rules=
+					new java.util.Vector<ComparatorRule>();
+		
+		rules.add(new BehaviourListComparatorRule());
+		rules.add(new BlockComparatorRule());
+		
+		DefaultComparatorContext context=
+			new DefaultComparatorContext(new ModelReference(TEST_NOTATION),
+						new ModelReference(TEST_NOTATION), rules);
+
+		Conversation main=new Conversation();
+		LocatedName mainName=new LocatedName();
+		mainName.setName("modelName");
+		Role mainRole=new Role();
+		mainRole.setName("roleName");
+		mainName.setRole(mainRole);
+		main.setLocatedName(mainName);
+		
+		Conversation reference=new Conversation();
+		LocatedName refName=new LocatedName();
+		refName.setName("modelName");
+		Role refRole=new Role();
+		refRole.setName("roleName");
+		refName.setRole(refRole);
+		reference.setLocatedName(refName);
+			
+		boolean result=rule.compare(context, main, reference, l, true);
+		
+		if (l.getErrors().size() > 0) {
+			fail("No errors expected");
+		}
+		
+		if (result == false) {
+			fail("Comparator should NOT have failed");
+		}
+	}
+
+	public void testShouldCompareSameNameAndRole() {
+		ConversationComparatorRule rule=new ConversationComparatorRule();
+		
+		java.util.List<ComparatorRule> rules=
+			new java.util.Vector<ComparatorRule>();
+
+		ModelReference mainRef=new ModelReference(TEST_NOTATION);
+		ModelReference refRef=new ModelReference(TEST_NOTATION);
+		
+		DefaultComparatorContext context=
+			new DefaultComparatorContext(mainRef, refRef, rules);
+		
+		Conversation main=new Conversation();
+		LocatedName mainName=new LocatedName();
+		mainName.setName("modelName");
+		Role mainRole=new Role();
+		mainRole.setName("roleName");
+		mainName.setRole(mainRole);
+		main.setLocatedName(mainName);
+		
+		Conversation reference=new Conversation();
+		LocatedName refName=new LocatedName();
+		refName.setName("modelName");
+		Role refRole=new Role();
+		refRole.setName("roleName");
+		refName.setRole(refRole);
+		reference.setLocatedName(refName);
+
+		boolean result=rule.shouldCompare(context, main, reference);
+	
+		if (result == false) {
+			fail("Should be comparable");
+		}
+	}
+
+	public void testShouldCompareDiffNameSameRole() {
+		ConversationComparatorRule rule=new ConversationComparatorRule();
+		
+		java.util.List<ComparatorRule> rules=
+			new java.util.Vector<ComparatorRule>();
+
+		ModelReference mainRef=new ModelReference(TEST_NOTATION);
+		ModelReference refRef=new ModelReference(TEST_NOTATION);
+		
+		DefaultComparatorContext context=
+			new DefaultComparatorContext(mainRef, refRef, rules);
+		
+		Conversation main=new Conversation();
+		LocatedName mainName=new LocatedName();
+		mainName.setName("modelName1");
+		Role mainRole=new Role();
+		mainRole.setName("roleName");
+		mainName.setRole(mainRole);
+		main.setLocatedName(mainName);
+		
+		Conversation reference=new Conversation();
+		LocatedName refName=new LocatedName();
+		refName.setName("modelName2");
+		Role refRole=new Role();
+		refRole.setName("roleName");
+		refName.setRole(refRole);
+		reference.setLocatedName(refName);
+
+		boolean result=rule.shouldCompare(context, main, reference);
+	
+		if (result == true) {
+			fail("Should NOT be comparable");
+		}
+	}
+
+	public void testShouldCompareSameNameDiffRole() {
+		ConversationComparatorRule rule=new ConversationComparatorRule();
+		
+		java.util.List<ComparatorRule> rules=
+			new java.util.Vector<ComparatorRule>();
+
+		ModelReference mainRef=new ModelReference(TEST_NOTATION);
+		ModelReference refRef=new ModelReference(TEST_NOTATION);
+		
+		DefaultComparatorContext context=
+			new DefaultComparatorContext(mainRef, refRef, rules);
+		
+		Conversation main=new Conversation();
+		LocatedName mainName=new LocatedName();
+		mainName.setName("modelName");
+		Role mainRole=new Role();
+		mainRole.setName("roleName1");
+		mainName.setRole(mainRole);
+		main.setLocatedName(mainName);
+		
+		Conversation reference=new Conversation();
+		LocatedName refName=new LocatedName();
+		refName.setName("modelName");
+		Role refRole=new Role();
+		refRole.setName("roleName2");
+		refName.setRole(refRole);
+		reference.setLocatedName(refName);
+
+		boolean result=rule.shouldCompare(context, main, reference);
+	
+		if (result == true) {
+			fail("Should NOT be comparable");
+		}
+	}
+
+	public void testShouldCompareMainImplementsRef() {
+		ConversationComparatorRule rule=new ConversationComparatorRule();
+		
+		java.util.List<ComparatorRule> rules=
+			new java.util.Vector<ComparatorRule>();
+
+		ModelReference mainRef=new ModelReference("main.ns",
+				"main.lp", "main.role", "main.notation");
+		
+		ModelReference refRef=new ModelReference("ref.ns",
+				"ref.lp", "ref.role", "ref.notation");
+		
+		DefaultComparatorContext context=
+			new DefaultComparatorContext(mainRef, refRef, rules);
+		
+		Conversation main=new Conversation();
+		LocatedName mainName=new LocatedName();
+		mainName.setName("modelName");
+		Role mainRole=new Role();
+		mainRole.setName("roleName1");
+		mainName.setRole(mainRole);
+		main.setLocatedName(mainName);
+		
+		Conversation reference=new Conversation();
+		LocatedName refName=new LocatedName();
+		refName.setName("modelName");
+		Role refRole=new Role();
+		refRole.setName("roleName2");
+		refName.setRole(refRole);
+		reference.setLocatedName(refName);
+		
+		ImplementsReference implRef=
+				new ImplementsReference(refRef.getNotation());
+		implRef.setNamespace(refRef.getNamespace());
+		implRef.setLocalpart(refRef.getLocalpart());
+		implRef.setLocatedRole(refRef.getLocatedRole());
+		
+		main.getImplements().add(implRef);
+
+		boolean result=rule.shouldCompare(context, main, reference);
+	
+		if (result == false) {
+			fail("Should be comparable");
+		}
+	}
+
+	public void testShouldCompareMainConformsToRef() {
+		ConversationComparatorRule rule=new ConversationComparatorRule();
+		
+		java.util.List<ComparatorRule> rules=
+			new java.util.Vector<ComparatorRule>();
+
+		ModelReference mainRef=new ModelReference("main.ns",
+				"main.lp", "main.role", "main.notation");
+		
+		ModelReference refRef=new ModelReference("ref.ns",
+				"ref.lp", "ref.role", "ref.notation");
+		
+		DefaultComparatorContext context=
+			new DefaultComparatorContext(mainRef, refRef, rules);
+		
+		Conversation main=new Conversation();
+		LocatedName mainName=new LocatedName();
+		mainName.setName("modelName");
+		Role mainRole=new Role();
+		mainRole.setName("roleName1");
+		mainName.setRole(mainRole);
+		main.setLocatedName(mainName);
+		
+		Conversation reference=new Conversation();
+		LocatedName refName=new LocatedName();
+		refName.setName("modelName");
+		Role refRole=new Role();
+		refRole.setName("roleName2");
+		refName.setRole(refRole);
+		reference.setLocatedName(refName);
+		
+		ConformanceReference conformsRef=
+				new ConformanceReference(refRef.getNotation());
+		conformsRef.setNamespace(refRef.getNamespace());
+		conformsRef.setLocalpart(refRef.getLocalpart());
+		conformsRef.setLocatedRole(refRef.getLocatedRole());
+		
+		main.getConformsTo().add(conformsRef);
+
+		boolean result=rule.shouldCompare(context, main, reference);
+	
+		if (result == false) {
+			fail("Should be comparable");
+		}
+	}
+
+	public void testShouldCompareMainImplsRefConformsTo() {
+		ConversationComparatorRule rule=new ConversationComparatorRule();
+		
+		java.util.List<ComparatorRule> rules=
+			new java.util.Vector<ComparatorRule>();
+
+		ModelReference mainRef=new ModelReference("main.ns",
+				"main.lp", "main.role", "main.notation");
+		
+		ModelReference refRef=new ModelReference("ref.ns",
+				"ref.lp", "ref.role", "ref.notation");
+		
+		DefaultComparatorContext context=
+			new DefaultComparatorContext(mainRef, refRef, rules);
+		
+		Conversation main=new Conversation();
+		LocatedName mainName=new LocatedName();
+		mainName.setName("modelName");
+		Role mainRole=new Role();
+		mainRole.setName("roleName1");
+		mainName.setRole(mainRole);
+		main.setLocatedName(mainName);
+		
+		Conversation reference=new Conversation();
+		LocatedName refName=new LocatedName();
+		refName.setName("modelName");
+		Role refRole=new Role();
+		refRole.setName("roleName2");
+		refName.setRole(refRole);
+		reference.setLocatedName(refName);
+		
+		String notation="notation";
+		String namespace="namespace";
+		String localpart="localpart";
+		String role="role";
+
+		ConformanceReference conformsRef=
+				new ConformanceReference(notation);
+		conformsRef.setNamespace(namespace);
+		conformsRef.setLocalpart(localpart);
+		conformsRef.setLocatedRole(role);
+		
+		reference.getConformsTo().add(conformsRef);
+
+		ImplementsReference implRef=
+				new ImplementsReference(notation);
+		implRef.setNamespace(namespace);
+		implRef.setLocalpart(localpart);
+		implRef.setLocatedRole(role);
+		
+		main.getImplements().add(implRef);
+		
+		boolean result=rule.shouldCompare(context, main, reference);
+	
+		if (result == false) {
+			fail("Should be comparable");
+		}
+	}
+
+	public void testShouldCompareRefImplsMainConformsTo() {
+		ConversationComparatorRule rule=new ConversationComparatorRule();
+		
+		java.util.List<ComparatorRule> rules=
+			new java.util.Vector<ComparatorRule>();
+
+		ModelReference mainRef=new ModelReference("main.ns",
+				"main.lp", "main.role", "main.notation");
+		
+		ModelReference refRef=new ModelReference("ref.ns",
+				"ref.lp", "ref.role", "ref.notation");
+		
+		DefaultComparatorContext context=
+			new DefaultComparatorContext(mainRef, refRef, rules);
+		
+		Conversation main=new Conversation();
+		LocatedName mainName=new LocatedName();
+		mainName.setName("modelName");
+		Role mainRole=new Role();
+		mainRole.setName("roleName1");
+		mainName.setRole(mainRole);
+		main.setLocatedName(mainName);
+		
+		Conversation reference=new Conversation();
+		LocatedName refName=new LocatedName();
+		refName.setName("modelName");
+		Role refRole=new Role();
+		refRole.setName("roleName2");
+		refName.setRole(refRole);
+		reference.setLocatedName(refName);
+		
+		String notation="notation";
+		String namespace="namespace";
+		String localpart="localpart";
+		String role="role";
+		
+		ConformanceReference conformsRef=
+				new ConformanceReference(notation);
+		conformsRef.setNamespace(namespace);
+		conformsRef.setLocalpart(localpart);
+		conformsRef.setLocatedRole(role);
+		
+		main.getConformsTo().add(conformsRef);
+
+		ImplementsReference implRef=
+				new ImplementsReference(notation);
+		implRef.setNamespace(namespace);
+		implRef.setLocalpart(localpart);
+		implRef.setLocatedRole(role);
+		
+		reference.getImplements().add(implRef);
+		
+		boolean result=rule.shouldCompare(context, main, reference);
+	
+		if (result == false) {
+			fail("Should be comparable");
+		}
+	}
+	
+	public void testShouldCompareRefImplsMainImpls() {
+		ConversationComparatorRule rule=new ConversationComparatorRule();
+		
+		java.util.List<ComparatorRule> rules=
+			new java.util.Vector<ComparatorRule>();
+
+		ModelReference mainRef=new ModelReference("main.ns",
+				"main.lp", "main.role", "main.notation");
+		
+		ModelReference refRef=new ModelReference("ref.ns",
+				"ref.lp", "ref.role", "ref.notation");
+		
+		DefaultComparatorContext context=
+			new DefaultComparatorContext(mainRef, refRef, rules);
+		
+		Conversation main=new Conversation();
+		LocatedName mainName=new LocatedName();
+		mainName.setName("modelName");
+		Role mainRole=new Role();
+		mainRole.setName("roleName1");
+		mainName.setRole(mainRole);
+		main.setLocatedName(mainName);
+		
+		Conversation reference=new Conversation();
+		LocatedName refName=new LocatedName();
+		refName.setName("modelName");
+		Role refRole=new Role();
+		refRole.setName("roleName2");
+		refName.setRole(refRole);
+		reference.setLocatedName(refName);
+		
+		ImplementsReference ir1=
+				new ImplementsReference("notation");
+		ir1.setNamespace("namespace");
+		ir1.setLocalpart("localpart");
+		ir1.setLocatedRole("role");
+		
+		main.getImplements().add(ir1);
+
+		reference.getImplements().add(ir1);
+		
+		boolean result=rule.shouldCompare(context, main, reference);
+	
+		if (result == false) {
+			fail("Should be comparable");
+		}
+	}
+	
+	public void testShouldCompareRefConformsToMainConformsTo() {
+		ConversationComparatorRule rule=new ConversationComparatorRule();
+		
+		java.util.List<ComparatorRule> rules=
+			new java.util.Vector<ComparatorRule>();
+
+		ModelReference mainRef=new ModelReference("main.ns",
+				"main.lp", "main.role", "main.notation");
+		
+		ModelReference refRef=new ModelReference("ref.ns",
+				"ref.lp", "ref.role", "ref.notation");
+		
+		DefaultComparatorContext context=
+			new DefaultComparatorContext(mainRef, refRef, rules);
+		
+		Conversation main=new Conversation();
+		LocatedName mainName=new LocatedName();
+		mainName.setName("modelName");
+		Role mainRole=new Role();
+		mainRole.setName("roleName1");
+		mainName.setRole(mainRole);
+		main.setLocatedName(mainName);
+		
+		Conversation reference=new Conversation();
+		LocatedName refName=new LocatedName();
+		refName.setName("modelName");
+		Role refRole=new Role();
+		refRole.setName("roleName2");
+		refName.setRole(refRole);
+		reference.setLocatedName(refName);
+		
+		ConformanceReference cr1=
+				new ConformanceReference("notation");
+		cr1.setNamespace("namespace");
+		cr1.setLocalpart("localpart");
+		cr1.setLocatedRole("role");
+		
+		main.getConformsTo().add(cr1);
+
+		reference.getConformsTo().add(cr1);
+		
+		boolean result=rule.shouldCompare(context, main, reference);
+	
+		if (result == false) {
+			fail("Should be comparable");
+		}
+	}
+}

Added: trunk/bundles/org.scribble.conversation.comparator/src/test/org/scribble/conversation/comparator/IfComparatorRuleTest.java
===================================================================
--- trunk/bundles/org.scribble.conversation.comparator/src/test/org/scribble/conversation/comparator/IfComparatorRuleTest.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.comparator/src/test/org/scribble/conversation/comparator/IfComparatorRuleTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 3 Mar 2009 : Initial version created by gary
+ */
+package org.scribble.conversation.comparator;
+
+import org.scribble.extensions.RegistryFactory;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+import org.scribble.model.admin.DefaultModelListener;
+import org.scribble.comparator.*;
+
+import junit.framework.TestCase;
+
+public class IfComparatorRuleTest extends TestCase {
+
+	private static final String TEST_NOTATION = "test";
+
+	public void testCompareShallow() {
+		IfComparatorRule rule=
+				new IfComparatorRule();
+		
+		RegistryFactory.setRegistry(null);
+		
+		DefaultModelListener l=new DefaultModelListener();
+		
+		java.util.List<ComparatorRule> rules=
+					new java.util.Vector<ComparatorRule>();
+		
+		DefaultComparatorContext context=
+			new DefaultComparatorContext(new ModelReference(TEST_NOTATION),
+						new ModelReference(TEST_NOTATION), rules);
+
+		If main=new If();
+		
+		If reference=new If();
+			
+		boolean result=rule.compare(context, main, reference, l, false);
+		
+		if (l.getErrors().size() > 0) {
+			fail("No errors expected");
+		}
+		
+		if (result == false) {
+			fail("Comparator should NOT have failed");
+		}
+	}
+}

Added: trunk/bundles/org.scribble.conversation.comparator/src/test/org/scribble/conversation/comparator/InterruptBlockComparatorRuleTest.java
===================================================================
--- trunk/bundles/org.scribble.conversation.comparator/src/test/org/scribble/conversation/comparator/InterruptBlockComparatorRuleTest.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.comparator/src/test/org/scribble/conversation/comparator/InterruptBlockComparatorRuleTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 3 Mar 2009 : Initial version created by gary
+ */
+package org.scribble.conversation.comparator;
+
+import org.scribble.extensions.RegistryFactory;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+import org.scribble.model.admin.DefaultModelListener;
+import org.scribble.comparator.*;
+
+import junit.framework.TestCase;
+
+public class InterruptBlockComparatorRuleTest extends TestCase {
+
+	private static final String TEST_NOTATION = "test";
+
+	public void testCompareShallow() {
+		InterruptBlockComparatorRule rule=
+				new InterruptBlockComparatorRule();
+		
+		RegistryFactory.setRegistry(null);
+		
+		DefaultModelListener l=new DefaultModelListener();
+		
+		java.util.List<ComparatorRule> rules=
+					new java.util.Vector<ComparatorRule>();
+		
+		DefaultComparatorContext context=
+			new DefaultComparatorContext(new ModelReference(TEST_NOTATION),
+						new ModelReference(TEST_NOTATION), rules);
+
+		InterruptBlock main=new InterruptBlock();
+		
+		InterruptBlock reference=new InterruptBlock();
+			
+		boolean result=rule.compare(context, main, reference, l, false);
+		
+		if (l.getErrors().size() > 0) {
+			fail("No errors expected");
+		}
+		
+		if (result == false) {
+			fail("Comparator should NOT have failed");
+		}
+	}
+	
+	// TODO: If defined in both, may need to check expressions
+	// are compatible
+}

Added: trunk/bundles/org.scribble.conversation.comparator/src/test/org/scribble/conversation/comparator/ParallelComparatorRuleTest.java
===================================================================
--- trunk/bundles/org.scribble.conversation.comparator/src/test/org/scribble/conversation/comparator/ParallelComparatorRuleTest.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.comparator/src/test/org/scribble/conversation/comparator/ParallelComparatorRuleTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 3 Mar 2009 : Initial version created by gary
+ */
+package org.scribble.conversation.comparator;
+
+import org.scribble.extensions.RegistryFactory;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+import org.scribble.model.admin.DefaultModelListener;
+import org.scribble.comparator.*;
+
+import junit.framework.TestCase;
+
+public class ParallelComparatorRuleTest extends TestCase {
+
+	private static final String TEST_NOTATION = "test";
+
+	public void testCompareShallow() {
+		ParallelComparatorRule rule=
+				new ParallelComparatorRule();
+		
+		RegistryFactory.setRegistry(null);
+		
+		DefaultModelListener l=new DefaultModelListener();
+		
+		java.util.List<ComparatorRule> rules=
+					new java.util.Vector<ComparatorRule>();
+		
+		DefaultComparatorContext context=
+			new DefaultComparatorContext(new ModelReference(TEST_NOTATION),
+						new ModelReference(TEST_NOTATION), rules);
+
+		Parallel main=new Parallel();
+		
+		Parallel reference=new Parallel();
+			
+		boolean result=rule.compare(context, main, reference, l, false);
+		
+		if (l.getErrors().size() > 0) {
+			fail("No errors expected");
+		}
+		
+		if (result == false) {
+			fail("Comparator should NOT have failed");
+		}
+	}
+}

Added: trunk/bundles/org.scribble.conversation.comparator/src/test/org/scribble/conversation/comparator/RaiseComparatorRuleTest.java
===================================================================
--- trunk/bundles/org.scribble.conversation.comparator/src/test/org/scribble/conversation/comparator/RaiseComparatorRuleTest.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.comparator/src/test/org/scribble/conversation/comparator/RaiseComparatorRuleTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,179 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 3 Mar 2009 : Initial version created by gary
+ */
+package org.scribble.conversation.comparator;
+
+import org.scribble.extensions.RegistryFactory;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+import org.scribble.model.admin.DefaultModelListener;
+import org.scribble.comparator.*;
+
+import junit.framework.TestCase;
+
+public class RaiseComparatorRuleTest extends TestCase {
+
+	private static final String TEST_NOTATION = "test";
+
+	public void testCompareSameRaiseType() {
+		RaiseComparatorRule rule=
+				new RaiseComparatorRule();
+		
+		RegistryFactory.setRegistry(null);
+		
+		DefaultModelListener l=new DefaultModelListener();
+		
+		java.util.List<ComparatorRule> rules=
+					new java.util.Vector<ComparatorRule>();
+		
+		rules.add(new TypeReferenceComparatorRule());
+		
+		DefaultComparatorContext context=
+			new DefaultComparatorContext(new ModelReference(TEST_NOTATION),
+						new ModelReference(TEST_NOTATION), rules);
+
+		Raise main=new Raise();
+		TypeReference mainType=new TypeReference();
+		mainType.setLocalpart("RaiseType");
+		main.setType(mainType);
+		
+		Raise reference=new Raise();
+		TypeReference refType=new TypeReference();
+		refType.setLocalpart("RaiseType");
+		reference.setType(refType);
+			
+		boolean result=rule.compare(context, main, reference, l, false);
+		
+		if (l.getErrors().size() > 0) {
+			fail("No errors expected");
+		}
+		
+		if (result == false) {
+			fail("Comparator should NOT have failed");
+		}
+	}
+
+	public void testCompareDiffRaiseTypes() {
+		RaiseComparatorRule rule=
+				new RaiseComparatorRule();
+		
+		RegistryFactory.setRegistry(null);
+		
+		DefaultModelListener l=new DefaultModelListener();
+		
+		java.util.List<ComparatorRule> rules=
+					new java.util.Vector<ComparatorRule>();
+		
+		rules.add(new TypeReferenceComparatorRule());
+		
+		DefaultComparatorContext context=
+			new DefaultComparatorContext(new ModelReference(TEST_NOTATION),
+						new ModelReference(TEST_NOTATION), rules);
+
+		Raise main=new Raise();
+		TypeReference mainType=new TypeReference();
+		mainType.setLocalpart("RaiseType1");
+		main.setType(mainType);
+		
+		Raise reference=new Raise();
+		TypeReference refType=new TypeReference();
+		refType.setLocalpart("RaiseType2");
+		reference.setType(refType);
+			
+		boolean result=rule.compare(context, main, reference, l, false);
+		
+		if (l.getErrors().size() != 1) {
+			fail("One error expected");
+		}
+		
+		if (result == true) {
+			fail("Comparator should have failed");
+		}
+	}
+
+	public void testCompareMissingMainRaiseType() {
+		RaiseComparatorRule rule=
+				new RaiseComparatorRule();
+		
+		RegistryFactory.setRegistry(null);
+		
+		DefaultModelListener l=new DefaultModelListener();
+		
+		java.util.List<ComparatorRule> rules=
+					new java.util.Vector<ComparatorRule>();
+		
+		rules.add(new TypeReferenceComparatorRule());
+		
+		DefaultComparatorContext context=
+			new DefaultComparatorContext(new ModelReference(TEST_NOTATION),
+						new ModelReference(TEST_NOTATION), rules);
+
+		Raise main=new Raise();
+		
+		Raise reference=new Raise();
+		TypeReference refType=new TypeReference();
+		refType.setLocalpart("RaiseType");
+		reference.setType(refType);
+			
+		boolean result=rule.compare(context, main, reference, l, false);
+		
+		if (l.getErrors().size() > 0) {
+			fail("No errors expected");
+		}
+		
+		if (result == true) {
+			fail("Comparator should have failed");
+		}
+	}
+
+	public void testCompareMissingRefRaiseType() {
+		RaiseComparatorRule rule=
+				new RaiseComparatorRule();
+		
+		RegistryFactory.setRegistry(null);
+		
+		DefaultModelListener l=new DefaultModelListener();
+		
+		java.util.List<ComparatorRule> rules=
+					new java.util.Vector<ComparatorRule>();
+		
+		rules.add(new TypeReferenceComparatorRule());
+		
+		DefaultComparatorContext context=
+			new DefaultComparatorContext(new ModelReference(TEST_NOTATION),
+						new ModelReference(TEST_NOTATION), rules);
+
+		Raise main=new Raise();
+		TypeReference mainType=new TypeReference();
+		mainType.setLocalpart("RaiseType");
+		main.setType(mainType);
+		
+		Raise reference=new Raise();
+			
+		boolean result=rule.compare(context, main, reference, l, false);
+		
+		if (l.getErrors().size() > 0) {
+			fail("No errors expected");
+		}
+		
+		if (result == true) {
+			fail("Comparator should have failed");
+		}
+	}
+}

Added: trunk/bundles/org.scribble.conversation.export.text/.classpath
===================================================================
--- trunk/bundles/org.scribble.conversation.export.text/.classpath	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.export.text/.classpath	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src/main/java"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="output" path="classes"/>
+</classpath>

Added: trunk/bundles/org.scribble.conversation.export.text/.project
===================================================================
--- trunk/bundles/org.scribble.conversation.export.text/.project	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.export.text/.project	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.scribble.conversation.export.text</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.ManifestBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.SchemaBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.pde.PluginNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

Added: trunk/bundles/org.scribble.conversation.export.text/LICENSE.txt
===================================================================
--- trunk/bundles/org.scribble.conversation.export.text/LICENSE.txt	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.export.text/LICENSE.txt	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,201 @@
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   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.

Added: trunk/bundles/org.scribble.conversation.export.text/META-INF/MANIFEST.MF
===================================================================
--- trunk/bundles/org.scribble.conversation.export.text/META-INF/MANIFEST.MF	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.export.text/META-INF/MANIFEST.MF	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,30 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Scribble Conversation Export Text Plug-in
+Bundle-SymbolicName: org.scribble.conversation.export.text;singleton:=true
+Bundle-Version: 1.2.0.qualifier
+Bundle-Activator: org.scribble.conversation.export.text.osgi.Activator
+Bundle-Vendor: www.scribble.org
+Import-Package: org.osgi.framework;version="1.3.0"
+Require-Bundle: org.scribble.core;bundle-version="[1.0.0,2.0.0)",
+ org.scribble.conversation.model;bundle-version="[1.0.0,2.0.0)"
+Bundle-ActivationPolicy: lazy
+Scribble-Extensions: org.scribble.conversation.export.text.ConversationModelTextExportRule,
+   org.scribble.conversation.export.text.ConversationTextExportRule,
+   org.scribble.conversation.export.text.ConversationReferenceTextExportRule,
+   org.scribble.conversation.export.text.ConversationInteractionTextExportRule,
+   org.scribble.conversation.export.text.VariableListTextExportRule,
+   org.scribble.conversation.export.text.VariableTextExportRule,
+   org.scribble.conversation.export.text.WhileTextExportRule,
+   org.scribble.conversation.export.text.WhenTextExportRule,
+   org.scribble.conversation.export.text.RaiseTextExportRule,
+   org.scribble.conversation.export.text.AssignmentTextExportRule,
+   org.scribble.conversation.export.text.ParallelTextExportRule,
+   org.scribble.conversation.export.text.RunTextExportRule,
+   org.scribble.conversation.export.text.SpawnTextExportRule,
+   org.scribble.conversation.export.text.IfTextExportRule,
+   org.scribble.conversation.export.text.ConditionalBlockTextExportRule,
+   org.scribble.conversation.export.text.TryEscapeTextExportRule,
+   org.scribble.conversation.export.text.CatchBlockTextExportRule,
+   org.scribble.conversation.export.text.InterruptBlockTextExportRule
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6

Added: trunk/bundles/org.scribble.conversation.export.text/build.properties
===================================================================
--- trunk/bundles/org.scribble.conversation.export.text/build.properties	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.export.text/build.properties	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,5 @@
+source.. = src/main/java/
+output.. = classes/
+bin.includes = META-INF/,\
+               .,\
+               plugin.xml

Added: trunk/bundles/org.scribble.conversation.export.text/pom.xml
===================================================================
--- trunk/bundles/org.scribble.conversation.export.text/pom.xml	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.export.text/pom.xml	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,33 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  	<modelVersion>4.0.0</modelVersion>
+	<groupId>org.savara.bundles</groupId>
+	<artifactId>org.scribble.conversation.export.text</artifactId> 
+	<version>1.2.0-SNAPSHOT</version>
+	<packaging>jar</packaging>
+	<name>Savara::Bundles::ScribbleConversationExportText</name>
+
+	<parent>
+		<groupId>org.savara</groupId>
+		<artifactId>bundles</artifactId>
+		<version>1.2.0-SNAPSHOT</version>
+	</parent>
+  
+	<dependencies>
+		<dependency>
+			<groupId>org.savara.bundles</groupId>
+			<artifactId>org.scribble.core</artifactId>
+			<version>1.2.0-SNAPSHOT</version>
+		</dependency>
+		<dependency>
+			<groupId>org.savara.bundles</groupId>
+			<artifactId>org.scribble.conversation.model</artifactId>
+			<version>1.2.0-SNAPSHOT</version>
+		</dependency>
+	    <dependency>
+	      <groupId>org.apache.felix</groupId>
+	      <artifactId>org.osgi.core</artifactId>
+	      <version>${osgi.version}</version>
+	    </dependency>
+	</dependencies>
+</project>

Added: trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/stream/ConversationModelStreamExportRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/stream/ConversationModelStreamExportRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/stream/ConversationModelStreamExportRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 13 Sept, 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.export.stream;
+
+import org.scribble.export.*;
+import org.scribble.export.stream.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class implements the stream based export rule for the
+ * ConversationModel entity.
+ */
+ at RegistryInfo(extension=ExportRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class ConversationModelStreamExportRule extends AbstractModelStreamExportRule {
+
+	/**
+	 * This method determines whether the exporter rule is appropriate
+	 * for the supplied model object and format.
+	 * 
+	 * @param modelObject The model object
+	 * @param format The format
+	 * @return Whether the rule is appropriate for the model object and
+	 * 						format
+	 */
+	public boolean isSupported(ModelObject modelObject, Formatter format) {
+		return(super.isSupported(modelObject, format) &&
+				ConversationModel.class.isAssignableFrom(modelObject.getClass()));
+	}
+}

Added: trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/AssignmentTextExportRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/AssignmentTextExportRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/AssignmentTextExportRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2007-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 3 June 2009 : Initial version created by gary
+ */
+package org.scribble.conversation.export.text;
+
+import org.scribble.export.*;
+import org.scribble.export.text.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class implements the text based export rule for the
+ * Assignment entity.
+ */
+ at RegistryInfo(extension=ExportRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class AssignmentTextExportRule implements ExportRule {
+
+	/**
+	 * This method determines whether the exporter rule is appropriate
+	 * for the supplied model object and format.
+	 * 
+	 * @param modelObject The model object
+	 * @param format The format
+	 * @return Whether the rule is appropriate for the model object and
+	 * 						format
+	 */
+	public boolean isSupported(ModelObject modelObject, Formatter format) {
+		return(Assignment.class.isAssignableFrom(modelObject.getClass()) &&
+				format instanceof TextFormatter);
+	}
+
+	/**
+	 * This method exports the model object.
+	 * 
+	 * @param modelObject The model object
+	 * @param context The context
+	 * @throws IOException Failed to record export information
+	 */
+	public void export(ModelObject modelObject, ExporterContext context)
+							throws java.io.IOException {
+		Assignment assign=(Assignment)modelObject;
+		TextFormatter formatter=(TextFormatter)context.getFormatter();
+		
+		context.export(assign.getVariable());
+		
+		if (assign.getRoles().size() > 0) {
+			formatter.record(" @ ");
+
+			for (int i=0; i < assign.getRoles().size(); i++) {
+				if (i > 0) {
+					formatter.record(",");
+				}				
+				formatter.record(assign.getRoles().get(i).getName());
+			}
+		}
+
+		formatter.record(" = ");
+		
+		context.export(assign.getExpression());
+	}
+}

Added: trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/CatchBlockTextExportRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/CatchBlockTextExportRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/CatchBlockTextExportRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 19 Oct 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.export.text;
+
+import org.scribble.export.*;
+import org.scribble.export.text.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class implements the text based export rule for the
+ * CatchBlock entity.
+ */
+ at RegistryInfo(extension=ExportRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class CatchBlockTextExportRule extends AbstractBlockTextExportRule {
+
+	/**
+	 * This method determines whether the exporter rule is appropriate
+	 * for the supplied model object and format.
+	 * 
+	 * @param modelObject The model object
+	 * @param format The format
+	 * @return Whether the rule is appropriate for the model object and
+	 * 						format
+	 */
+	public boolean isSupported(ModelObject modelObject, Formatter format) {
+		return(modelObject.getClass() == CatchBlock.class &&
+				format instanceof TextFormatter);
+	}
+
+	/**
+	 * This method exports the model object.
+	 * 
+	 * @param modelObject The model object
+	 * @param context The context
+	 * @throws IOException Failed to record export information
+	 */
+	public void export(ModelObject modelObject, ExporterContext context)
+							throws java.io.IOException {
+		CatchBlock elem=(CatchBlock)modelObject;
+		TextFormatter formatter=(TextFormatter)context.getFormatter();
+		
+		formatter.record("catch");
+		
+		if (elem.getRoles().size() > 0) {
+			formatter.record(" @ ");
+
+			for (int i=0; i < elem.getRoles().size(); i++) {
+				if (i > 0) {
+					formatter.record(",");
+				}				
+				formatter.record(elem.getRoles().get(i).getName());
+			}
+		}
+		
+		if (elem.getType() != null) {
+			formatter.record(" ");
+			context.export(elem.getType());
+		}
+
+		super.export(elem, context);
+	}
+}

Added: trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/ConditionalBlockTextExportRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/ConditionalBlockTextExportRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/ConditionalBlockTextExportRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 20 Oct 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.export.text;
+
+import org.scribble.export.*;
+import org.scribble.export.text.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class implements the text based export rule for the
+ * ConditionalBlock entity.
+ */
+ at RegistryInfo(extension=ExportRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class ConditionalBlockTextExportRule extends AbstractBlockTextExportRule {
+
+	/**
+	 * This method determines whether the exporter rule is appropriate
+	 * for the supplied model object and format.
+	 * 
+	 * @param modelObject The model object
+	 * @param format The format
+	 * @return Whether the rule is appropriate for the model object and
+	 * 						format
+	 */
+	public boolean isSupported(ModelObject modelObject, Formatter format) {
+		return(modelObject.getClass() == ConditionalBlock.class &&
+				format instanceof TextFormatter);
+	}
+
+	/**
+	 * This method exports the model object.
+	 * 
+	 * @param modelObject The model object
+	 * @param context The context
+	 * @throws IOException Failed to record export information
+	 */
+	public void export(ModelObject modelObject, ExporterContext context)
+							throws java.io.IOException {
+		ConditionalBlock elem=(ConditionalBlock)modelObject;
+		TextFormatter formatter=(TextFormatter)context.getFormatter();
+		
+		if (elem.getExpression() != null) {
+			formatter.record(" (");
+			
+			context.export(elem.getExpression());
+			
+			formatter.record(") ");
+		}
+
+		super.export(elem, context);
+	}
+}

Added: trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/ConversationInteractionTextExportRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/ConversationInteractionTextExportRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/ConversationInteractionTextExportRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 24 Jan, 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.export.text;
+
+import org.scribble.export.*;
+import org.scribble.export.text.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class implements the text based export rule for the
+ * ConversationInteraction entity.
+ */
+ at RegistryInfo(extension=ExportRule.class,notation=ConversationNotation.NOTATION_CODE) //,preference=10,category=Interaction.class)
+public class ConversationInteractionTextExportRule extends InteractionTextExportRule {
+
+	/**
+	 * This method determines whether the exporter rule is appropriate
+	 * for the supplied model object and format.
+	 * 
+	 * @param modelObject The model object
+	 * @param format The format
+	 * @return Whether the rule is appropriate for the model object and
+	 * 						format
+	 */
+	public boolean isSupported(ModelObject modelObject, Formatter format) {
+		return(ConversationInteraction.class.isAssignableFrom(modelObject.getClass()) &&
+				format instanceof TextFormatter);
+	}
+
+	/**
+	 * This method exports the text related to an interactions
+	 * 'from' role.
+	 * 
+	 * @param interaction The interaction
+	 * @param context The export context
+	 * @throws java.io.IOException Failed to export information
+	 */
+	protected void exportFrom(Interaction interaction,
+			ExporterContext context) throws java.io.IOException {
+		ConversationInteraction ci=(ConversationInteraction)interaction;
+		TextFormatter formatter=(TextFormatter)context.getFormatter();
+		
+		if (ci.getFromVariable() != null) {
+			formatter.record(" from "+ci.getFromVariable().getName());
+			
+			if (ci.getFromRole() != null) {
+				formatter.record("@"+ci.getFromRole().getName());
+			}
+		} else if (ci.getFromRole() != null) {
+			formatter.record(" from "+ci.getFromRole().getName());
+		}
+	}
+	
+	/**
+	 * This method exports the text related to an interactions
+	 * 'to' role.
+	 * 
+	 * @param interaction The interaction
+	 * @param context The export context
+	 * @throws java.io.IOException Failed to export information
+	 */
+	protected void exportTo(Interaction interaction,
+			ExporterContext context) throws java.io.IOException {		
+		ConversationInteraction ci=(ConversationInteraction)interaction;
+		TextFormatter formatter=(TextFormatter)context.getFormatter();
+		
+		if (ci.getToVariable() != null) {
+			formatter.record(" to "+ci.getToVariable().getName());
+			
+			if (ci.getToRole() != null) {
+				formatter.record("@"+ci.getToRole().getName());
+			}
+		} else if (ci.getToRole() != null) {
+			formatter.record(" to "+ci.getToRole().getName());
+		}
+	}
+}

Added: trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/ConversationModelTextExportRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/ConversationModelTextExportRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/ConversationModelTextExportRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 24 Jan, 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.export.text;
+
+import org.scribble.export.*;
+import org.scribble.export.text.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class implements the text based export rule for the
+ * ConversationModel entity.
+ */
+ at RegistryInfo(extension=ExportRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class ConversationModelTextExportRule extends AbstractModelTextExportRule {
+
+	/**
+	 * This method determines whether the exporter rule is appropriate
+	 * for the supplied model object and format.
+	 * 
+	 * @param modelObject The model object
+	 * @param format The format
+	 * @return Whether the rule is appropriate for the model object and
+	 * 						format
+	 */
+	public boolean isSupported(ModelObject modelObject, Formatter format) {
+		return(super.isSupported(modelObject, format) &&
+				ConversationModel.class.isAssignableFrom(modelObject.getClass()));
+	}
+
+	/**
+	 * This method exports the model object.
+	 * 
+	 * @param modelObject The model object
+	 * @param context The context
+	 * @throws IOException Failed to record export information
+	 */
+	public void export(ModelObject modelObject, ExporterContext context)
+							throws java.io.IOException {
+		ConversationModel model=(ConversationModel)modelObject;
+		
+		super.export(model, context);
+		
+		if (model.getConversation() != null) {
+			context.export(model.getConversation());
+		}
+	}
+}

Added: trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/ConversationReferenceTextExportRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/ConversationReferenceTextExportRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/ConversationReferenceTextExportRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 9 Mar 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.export.text;
+
+import org.scribble.export.*;
+import org.scribble.export.text.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class implements the text based export rule for the
+ * ConversationReference entity.
+ */
+ at RegistryInfo(extension=ExportRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class ConversationReferenceTextExportRule
+					extends AbstractModelReferenceTextExportRule {
+
+	/**
+	 * This method determines whether the exporter rule is appropriate
+	 * for the supplied model object and format.
+	 * 
+	 * @param modelObject The model object
+	 * @param format The format
+	 * @return Whether the rule is appropriate for the model object and
+	 * 						format
+	 */
+	public boolean isSupported(ModelObject modelObject, Formatter format) {
+		return(super.isSupported(modelObject, format) &&
+				ConversationReference.class.isAssignableFrom(modelObject.getClass()));
+	}
+
+	/**
+	 * This method exports the model object.
+	 * 
+	 * @param modelObject The model object
+	 * @param context The context
+	 * @throws IOException Failed to record export information
+	 */
+	public void export(ModelObject modelObject, ExporterContext context)
+							throws java.io.IOException {
+		ConversationReference ref=(ConversationReference)modelObject;
+		
+		super.export(ref, context);
+	}
+}

Added: trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/ConversationTextExportRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/ConversationTextExportRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/ConversationTextExportRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 24 Jan, 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.export.text;
+
+import org.scribble.export.*;
+import org.scribble.export.text.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class implements the text based export rule for the
+ * Conversation entity.
+ */
+ at RegistryInfo(extension=ExportRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class ConversationTextExportRule implements ExportRule {
+
+	/**
+	 * This method determines whether the exporter rule is appropriate
+	 * for the supplied model object and format.
+	 * 
+	 * @param modelObject The model object
+	 * @param format The format
+	 * @return Whether the rule is appropriate for the model object and
+	 * 						format
+	 */
+	public boolean isSupported(ModelObject modelObject, Formatter format) {
+		return(Conversation.class.isAssignableFrom(modelObject.getClass()) &&
+				format instanceof TextFormatter);
+	}
+
+	/**
+	 * This method exports the model object.
+	 * 
+	 * @param modelObject The model object
+	 * @param context The context
+	 * @throws IOException Failed to record export information
+	 */
+	public void export(ModelObject modelObject, ExporterContext context)
+							throws java.io.IOException {
+		Conversation conversation=(Conversation)modelObject;
+		TextFormatter formatter=(TextFormatter)context.getFormatter();
+		
+		if (conversation.isStateless()) {
+			formatter.record("stateless ");
+		}
+		
+		formatter.record("conversation ");
+		
+		context.export(conversation.getLocatedName());
+		
+		if (conversation.getConformsTo().size() > 0) {
+			formatter.record(" conforms to ");
+			
+			for (int i=0; i < conversation.getConformsTo().size(); i++) {
+				
+				if (i > 0) {
+					formatter.record(", ");
+				}
+				context.export(conversation.getConformsTo().get(i));
+			}
+		}
+
+		if (conversation.getImplements().size() > 0) {
+			formatter.record(" implements ");
+			
+			for (int i=0; i < conversation.getImplements().size(); i++) {
+				
+				if (i > 0) {
+					formatter.record(", ");
+				}
+				context.export(conversation.getImplements().get(i));
+			}
+		}
+
+		context.export(conversation.getBlock());
+	}
+}

Added: trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/IfTextExportRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/IfTextExportRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/IfTextExportRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 2 Feb 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.export.text;
+
+import org.scribble.export.*;
+import org.scribble.export.text.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class implements the text based export rule for the
+ * If entity.
+ */
+ at RegistryInfo(extension=ExportRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class IfTextExportRule implements ExportRule {
+
+	/**
+	 * This method determines whether the exporter rule is appropriate
+	 * for the supplied model object and format.
+	 * 
+	 * @param modelObject The model object
+	 * @param format The format
+	 * @return Whether the rule is appropriate for the model object and
+	 * 						format
+	 */
+	public boolean isSupported(ModelObject modelObject, Formatter format) {
+		return(If.class.isAssignableFrom(modelObject.getClass()) &&
+				format instanceof TextFormatter);
+	}
+
+	/**
+	 * This method exports the model object.
+	 * 
+	 * @param modelObject The model object
+	 * @param context The context
+	 * @throws IOException Failed to record export information
+	 */
+	public void export(ModelObject modelObject, ExporterContext context)
+							throws java.io.IOException {
+		If ifElem=(If)modelObject;
+		TextFormatter formatter=(TextFormatter)context.getFormatter();
+		
+		formatter.record("if");
+		
+		if (ifElem.getRoles().size() > 0) {
+			formatter.record(" @ ");
+
+			for (int i=0; i < ifElem.getRoles().size(); i++) {
+				if (i > 0) {
+					formatter.record(",");
+				}				
+				formatter.record(ifElem.getRoles().get(i).getName());
+			}
+		}
+		
+		for (int i=0; i < ifElem.getConditionalBlocks().size(); i++) {
+			
+			if (i > 0) {
+				formatter.record(" else if");
+			} else {
+				((TextFormatter)context.getFormatter()).cancelEndOfBlock();
+			}
+
+			context.export(ifElem.getConditionalBlocks().get(i));
+		}
+		
+		if (ifElem.getElseBlock() != null) {
+			
+			((TextFormatter)context.getFormatter()).cancelEndOfBlock();
+			formatter.record(" else");
+
+			context.export(ifElem.getElseBlock());
+		}
+	}
+}

Added: trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/InterruptBlockTextExportRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/InterruptBlockTextExportRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/InterruptBlockTextExportRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 19 Oct 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.export.text;
+
+import org.scribble.export.*;
+import org.scribble.export.text.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class implements the text based export rule for the
+ * InterruptBlock entity.
+ */
+ at RegistryInfo(extension=ExportRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class InterruptBlockTextExportRule extends AbstractBlockTextExportRule {
+
+	/**
+	 * This method determines whether the exporter rule is appropriate
+	 * for the supplied model object and format.
+	 * 
+	 * @param modelObject The model object
+	 * @param format The format
+	 * @return Whether the rule is appropriate for the model object and
+	 * 						format
+	 */
+	public boolean isSupported(ModelObject modelObject, Formatter format) {
+		return(modelObject.getClass() == InterruptBlock.class &&
+				format instanceof TextFormatter);
+	}
+
+	/**
+	 * This method exports the model object.
+	 * 
+	 * @param modelObject The model object
+	 * @param context The context
+	 * @throws IOException Failed to record export information
+	 */
+	public void export(ModelObject modelObject, ExporterContext context)
+							throws java.io.IOException {
+		InterruptBlock elem=(InterruptBlock)modelObject;
+		TextFormatter formatter=(TextFormatter)context.getFormatter();
+		
+		formatter.record("interrupt");
+		
+		if (elem.getRoles().size() > 0) {
+			formatter.record(" @ ");
+
+			for (int i=0; i < elem.getRoles().size(); i++) {
+				if (i > 0) {
+					formatter.record(",");
+				}				
+				formatter.record(elem.getRoles().get(i).getName());
+			}
+		}
+		
+		if (elem.getExpression() != null) {
+			formatter.record(" (");
+			
+			context.export(elem.getExpression());
+			
+			formatter.record(") ");
+		}
+
+		super.export(elem, context);
+	}
+}

Added: trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/ParallelTextExportRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/ParallelTextExportRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/ParallelTextExportRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 9 Mar 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.export.text;
+
+import org.scribble.export.*;
+import org.scribble.export.text.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class implements the text based export rule for the
+ * Parallel entity.
+ */
+ at RegistryInfo(extension=ExportRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class ParallelTextExportRule implements ExportRule {
+
+	/**
+	 * This method determines whether the exporter rule is appropriate
+	 * for the supplied model object and format.
+	 * 
+	 * @param modelObject The model object
+	 * @param format The format
+	 * @return Whether the rule is appropriate for the model object and
+	 * 						format
+	 */
+	public boolean isSupported(ModelObject modelObject, Formatter format) {
+		return(Parallel.class.isAssignableFrom(modelObject.getClass()) &&
+				format instanceof TextFormatter);
+	}
+
+	/**
+	 * This method exports the model object.
+	 * 
+	 * @param modelObject The model object
+	 * @param context The context
+	 * @throws IOException Failed to record export information
+	 */
+	public void export(ModelObject modelObject, ExporterContext context)
+							throws java.io.IOException {
+		Parallel parallel=(Parallel)modelObject;
+		TextFormatter formatter=(TextFormatter)context.getFormatter();
+		
+		formatter.record("parallel");
+		
+		for (int i=0; i < parallel.getBlocks().size(); i++) {
+			
+			if (i > 0) {
+				formatter.record(" and");
+			}
+
+			context.export(parallel.getBlocks().get(i));
+		}
+	}
+}

Added: trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/RaiseTextExportRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/RaiseTextExportRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/RaiseTextExportRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 10 Nov, 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.export.text;
+
+import org.scribble.export.*;
+import org.scribble.export.text.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class implements the text based export rule for the
+ * Raise entity.
+ */
+ at RegistryInfo(extension=ExportRule.class,notation=ConversationNotation.NOTATION_CODE) //,preference=10,category=Raise.class)
+public class RaiseTextExportRule implements ExportRule {
+
+	/**
+	 * This method determines whether the exporter rule is appropriate
+	 * for the supplied model object and format.
+	 * 
+	 * @param modelObject The model object
+	 * @param format The format
+	 * @return Whether the rule is appropriate for the model object and
+	 * 						format
+	 */
+	public boolean isSupported(ModelObject modelObject, Formatter format) {
+		return(Raise.class.isAssignableFrom(modelObject.getClass()) &&
+				format instanceof TextFormatter);
+	}
+
+	/**
+	 * This method exports the model object.
+	 * 
+	 * @param modelObject The model object
+	 * @param context The context
+	 * @throws IOException Failed to record export information
+	 */
+	public void export(ModelObject modelObject, ExporterContext context)
+							throws java.io.IOException {
+		Raise raise=(Raise)modelObject;
+		TextFormatter formatter=(TextFormatter)context.getFormatter();
+		
+		formatter.record("raise");
+		
+		if (raise.getRoles().size() > 0) {
+			formatter.record(" @ ");
+
+			for (int i=0; i < raise.getRoles().size(); i++) {
+				if (i > 0) {
+					formatter.record(",");
+				}				
+				formatter.record(raise.getRoles().get(i).getName());
+			}
+		}
+
+		if (raise.getType() != null) {
+			formatter.record(" ");			
+			context.export(raise.getType());
+		}
+	}
+}

Added: trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/RunTextExportRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/RunTextExportRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/RunTextExportRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 9 Mar 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.export.text;
+
+import org.scribble.export.*;
+import org.scribble.export.text.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class implements the text based export rule for the
+ * Run entity.
+ */
+ at RegistryInfo(extension=ExportRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class RunTextExportRule implements ExportRule {
+
+	/**
+	 * This method determines whether the exporter rule is appropriate
+	 * for the supplied model object and format.
+	 * 
+	 * @param modelObject The model object
+	 * @param format The format
+	 * @return Whether the rule is appropriate for the model object and
+	 * 						format
+	 */
+	public boolean isSupported(ModelObject modelObject, Formatter format) {
+		return(Run.class.isAssignableFrom(modelObject.getClass()) &&
+				format instanceof TextFormatter);
+	}
+
+	/**
+	 * This method exports the model object.
+	 * 
+	 * @param modelObject The model object
+	 * @param context The context
+	 * @throws IOException Failed to record export information
+	 */
+	public void export(ModelObject modelObject, ExporterContext context)
+							throws java.io.IOException {
+		Run run=(Run)modelObject;
+		TextFormatter formatter=(TextFormatter)context.getFormatter();
+		
+		formatter.record("run ");
+		
+		if (run.getReference() != null) {
+			context.export(run.getReference());
+		} else if (run.getInlineDefinition() != null) {
+			formatter.record("conversation");
+		}
+		
+		if (run.getBindings().size() > 0) {
+			formatter.record(" (");
+			
+			java.util.Iterator<DeclarationBinding> iter=
+					run.getBindings().iterator();
+			
+			boolean first=true;
+			
+			while (iter.hasNext()) {
+				DeclarationBinding db=iter.next();
+				
+				if (first == false) {
+					formatter.record(",");
+				}
+				
+				formatter.record(db.getDeclaration().getName()+
+						" for "+db.getBoundName());
+				
+				first = false;
+			}
+			
+			formatter.record(")");
+		}
+		
+		if (run.getInlineDefinition() != null) { 
+			context.export(run.getInlineDefinition().getBlock());
+		}
+	}
+}

Added: trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/SpawnTextExportRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/SpawnTextExportRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/SpawnTextExportRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 7 Aug 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.export.text;
+
+import org.scribble.export.*;
+import org.scribble.export.text.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class implements the text based export rule for the
+ * Spawn entity.
+ */
+ at RegistryInfo(extension=ExportRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class SpawnTextExportRule implements ExportRule {
+
+	/**
+	 * This method determines whether the exporter rule is appropriate
+	 * for the supplied model object and format.
+	 * 
+	 * @param modelObject The model object
+	 * @param format The format
+	 * @return Whether the rule is appropriate for the model object and
+	 * 						format
+	 */
+	public boolean isSupported(ModelObject modelObject, Formatter format) {
+		return(Spawn.class.isAssignableFrom(modelObject.getClass()) &&
+				format instanceof TextFormatter);
+	}
+
+	/**
+	 * This method exports the model object.
+	 * 
+	 * @param modelObject The model object
+	 * @param context The context
+	 * @throws IOException Failed to record export information
+	 */
+	public void export(ModelObject modelObject, ExporterContext context)
+							throws java.io.IOException {
+		Spawn spawn=(Spawn)modelObject;
+		TextFormatter formatter=(TextFormatter)context.getFormatter();
+		
+		formatter.record("spawn ");
+		
+		if (spawn.getReference() != null) {
+			context.export(spawn.getReference());
+		} else if (spawn.getInlineDefinition() != null) {
+			formatter.record("conversation");
+		}
+		
+		if (spawn.getBindings().size() > 0) {
+			formatter.record(" (");
+			
+			java.util.Iterator<DeclarationBinding> iter=
+					spawn.getBindings().iterator();
+			
+			boolean first=true;
+			
+			while (iter.hasNext()) {
+				DeclarationBinding db=iter.next();
+				
+				if (first == false) {
+					formatter.record(",");
+				}
+				
+				formatter.record(db.getDeclaration().getName()+
+						" for "+db.getBoundName());
+				
+				first = false;
+			}
+			
+			formatter.record(")");
+		}
+		
+		if (spawn.getInlineDefinition() != null) { 
+			context.export(spawn.getInlineDefinition().getBlock());
+		}
+	}
+}

Added: trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/TryEscapeTextExportRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/TryEscapeTextExportRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/TryEscapeTextExportRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 19 Oct 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.export.text;
+
+import org.scribble.export.*;
+import org.scribble.export.text.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class implements the text based export rule for the
+ * TryEscape entity.
+ */
+ at RegistryInfo(extension=ExportRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class TryEscapeTextExportRule implements ExportRule {
+
+	/**
+	 * This method determines whether the exporter rule is appropriate
+	 * for the supplied model object and format.
+	 * 
+	 * @param modelObject The model object
+	 * @param format The format
+	 * @return Whether the rule is appropriate for the model object and
+	 * 						format
+	 */
+	public boolean isSupported(ModelObject modelObject, Formatter format) {
+		return(TryEscape.class.isAssignableFrom(modelObject.getClass()) &&
+				format instanceof TextFormatter);
+	}
+
+	/**
+	 * This method exports the model object.
+	 * 
+	 * @param modelObject The model object
+	 * @param context The context
+	 * @throws IOException Failed to record export information
+	 */
+	public void export(ModelObject modelObject, ExporterContext context)
+							throws java.io.IOException {
+		TryEscape elem=(TryEscape)modelObject;
+		TextFormatter formatter=(TextFormatter)context.getFormatter();
+		
+		formatter.record("try");
+		
+		context.export(elem.getBlock());
+		
+		for (int i=0; i < elem.getEscapeBlocks().size(); i++) {
+			
+			((TextFormatter)context.getFormatter()).cancelEndOfBlock();
+			
+			formatter.record(" ");
+			context.export(elem.getEscapeBlocks().get(i));
+		}
+	}
+}

Added: trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/VariableListTextExportRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/VariableListTextExportRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/VariableListTextExportRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 25 Jan, 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.export.text;
+
+import org.scribble.export.*;
+import org.scribble.export.text.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class implements the text based export rule for the
+ * VariableList entity.
+ */
+ at RegistryInfo(extension=ExportRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class VariableListTextExportRule implements ExportRule {
+
+	/**
+	 * This method determines whether the exporter rule is appropriate
+	 * for the supplied model object and format.
+	 * 
+	 * @param modelObject The model object
+	 * @param format The format
+	 * @return Whether the rule is appropriate for the model object and
+	 * 						format
+	 */
+	public boolean isSupported(ModelObject modelObject, Formatter format) {
+		return(VariableList.class.isAssignableFrom(modelObject.getClass()) &&
+				format instanceof TextFormatter);
+	}
+
+	/**
+	 * This method exports the model object.
+	 * 
+	 * @param modelObject The model object
+	 * @param context The context
+	 * @throws IOException Failed to record export information
+	 */
+	public void export(ModelObject modelObject, ExporterContext context)
+							throws java.io.IOException {
+		VariableList variableList=(VariableList)modelObject;
+		TextFormatter formatter=(TextFormatter)context.getFormatter();
+		
+		for (int i=0; i < variableList.getVariables().size(); i++) {
+			Variable var=variableList.getVariables().get(i);
+			
+			if (i == 0) {
+				// TODO: Need ability to check whether full
+				// or local only type needs to be displayed,
+				// but this will rely on being able to
+				// navigate up the description object model.
+				formatter.record(var.getType().getLocalpart()+"\t");
+			} else {
+				formatter.record(", ");
+			}
+			
+			context.export(var);
+		}
+	}
+}

Added: trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/VariableTextExportRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/VariableTextExportRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/VariableTextExportRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 25 Jan, 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.export.text;
+
+import org.scribble.export.*;
+import org.scribble.export.text.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class implements the text based export rule for the
+ * Variable entity.
+ */
+ at RegistryInfo(extension=ExportRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class VariableTextExportRule implements ExportRule {
+
+	/**
+	 * This method determines whether the exporter rule is appropriate
+	 * for the supplied model object and format.
+	 * 
+	 * @param modelObject The model object
+	 * @param format The format
+	 * @return Whether the rule is appropriate for the model object and
+	 * 						format
+	 */
+	public boolean isSupported(ModelObject modelObject, Formatter format) {
+		return(Variable.class.isAssignableFrom(modelObject.getClass()) &&
+				format instanceof TextFormatter);
+	}
+
+	/**
+	 * This method exports the model object.
+	 * 
+	 * @param modelObject The model object
+	 * @param context The context
+	 * @throws IOException Failed to record export information
+	 */
+	public void export(ModelObject modelObject, ExporterContext context)
+							throws java.io.IOException {
+		Variable variable=(Variable)modelObject;
+		TextFormatter formatter=(TextFormatter)context.getFormatter();
+		
+		formatter.record(variable.getName());
+	}
+}

Added: trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/WhenTextExportRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/WhenTextExportRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/WhenTextExportRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 9 Mar 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.export.text;
+
+import org.scribble.export.*;
+import org.scribble.export.text.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class implements the text based export rule for the
+ * When entity.
+ */
+ at RegistryInfo(extension=ExportRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class WhenTextExportRule implements ExportRule {
+
+	/**
+	 * This method determines whether the exporter rule is appropriate
+	 * for the supplied model object and format.
+	 * 
+	 * @param modelObject The model object
+	 * @param format The format
+	 * @return Whether the rule is appropriate for the model object and
+	 * 						format
+	 */
+	public boolean isSupported(ModelObject modelObject, Formatter format) {
+		return(When.class.isAssignableFrom(modelObject.getClass()) &&
+				format instanceof TextFormatter);
+	}
+
+	/**
+	 * This method exports the model object.
+	 * 
+	 * @param modelObject The model object
+	 * @param context The context
+	 * @throws IOException Failed to record export information
+	 */
+	public void export(ModelObject modelObject, ExporterContext context)
+							throws java.io.IOException {
+		When when=(When)modelObject;
+		TextFormatter formatter=(TextFormatter)context.getFormatter();
+		
+		formatter.record("when");
+		
+		if (when.getRoles().size() > 0) {
+			formatter.record(" @ ");
+			for (int i=0; i < when.getRoles().size(); i++) {		
+				if (i > 0) {
+					formatter.record(",");
+				}				
+				formatter.record(when.getRoles().get(i).getName());
+			}
+		}
+		
+		for (int i=0; i < when.getConditionalBlocks().size(); i++) {
+			
+			if (i > 0) {
+				formatter.record(" else when");
+			}
+
+			context.export(when.getConditionalBlocks().get(i));
+		}
+	}
+}

Added: trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/WhileTextExportRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/WhileTextExportRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/WhileTextExportRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 9 Mar 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.export.text;
+
+import org.scribble.export.*;
+import org.scribble.export.text.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class implements the text based export rule for the
+ * While entity.
+ */
+ at RegistryInfo(extension=ExportRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class WhileTextExportRule implements ExportRule {
+
+	/**
+	 * This method determines whether the exporter rule is appropriate
+	 * for the supplied model object and format.
+	 * 
+	 * @param modelObject The model object
+	 * @param format The format
+	 * @return Whether the rule is appropriate for the model object and
+	 * 						format
+	 */
+	public boolean isSupported(ModelObject modelObject, Formatter format) {
+		return(While.class.isAssignableFrom(modelObject.getClass()) &&
+				format instanceof TextFormatter);
+	}
+
+	/**
+	 * This method exports the model object.
+	 * 
+	 * @param modelObject The model object
+	 * @param context The context
+	 * @throws IOException Failed to record export information
+	 */
+	public void export(ModelObject modelObject, ExporterContext context)
+							throws java.io.IOException {
+		While whileElem=(While)modelObject;
+		TextFormatter formatter=(TextFormatter)context.getFormatter();
+		
+		formatter.record("while");
+		
+		if (whileElem.getRoles().size() > 0) {
+			formatter.record(" @ ");
+			for (int i=0; i < whileElem.getRoles().size(); i++) {
+				if (i > 0) {
+					formatter.record(",");
+				}
+				context.export(whileElem.getRoles().get(i));				
+			}
+		}
+		
+		context.export(whileElem.getBlock());
+	}
+}

Added: trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/osgi/Activator.java
===================================================================
--- trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/osgi/Activator.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.export.text/src/main/java/org/scribble/conversation/export/text/osgi/Activator.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 24 Jan, 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.export.text.osgi;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator implements BundleActivator {
+
+	// The plug-in ID
+	public static final String PLUGIN_ID = "org.scribble.conversation.export.text";
+
+	// The shared instance
+	private static Activator plugin;
+	
+	/**
+	 * The constructor
+	 */
+	public Activator() {
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
+	 */
+	public void start(BundleContext context) throws Exception {
+		plugin = this;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
+	 */
+	public void stop(BundleContext context) throws Exception {
+		plugin = null;
+	}
+
+	/**
+	 * Returns the shared instance
+	 *
+	 * @return the shared instance
+	 */
+	public static Activator getDefault() {
+		return plugin;
+	}
+
+}

Added: trunk/bundles/org.scribble.conversation.model/.classpath
===================================================================
--- trunk/bundles/org.scribble.conversation.model/.classpath	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.model/.classpath	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src/test"/>
+	<classpathentry kind="src" path="src/main/java"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
+	<classpathentry kind="output" path="classes"/>
+</classpath>

Added: trunk/bundles/org.scribble.conversation.model/.project
===================================================================
--- trunk/bundles/org.scribble.conversation.model/.project	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.model/.project	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.scribble.conversation.model</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.ManifestBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.SchemaBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.pde.PluginNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

Added: trunk/bundles/org.scribble.conversation.model/LICENSE.txt
===================================================================
--- trunk/bundles/org.scribble.conversation.model/LICENSE.txt	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.model/LICENSE.txt	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,201 @@
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   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.

Added: trunk/bundles/org.scribble.conversation.model/META-INF/MANIFEST.MF
===================================================================
--- trunk/bundles/org.scribble.conversation.model/META-INF/MANIFEST.MF	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.model/META-INF/MANIFEST.MF	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,13 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Scribble Conversation Model Plug-in
+Bundle-SymbolicName: org.scribble.conversation.model;singleton:=true
+Bundle-Version: 1.2.0.qualifier
+Bundle-Activator: org.scribble.conversation.model.osgi.Activator
+Bundle-Vendor: www.scribble.org
+Import-Package: org.osgi.framework;version="1.3.0"
+Require-Bundle: org.scribble.core;bundle-version="[1.0.0,2.0.0)"
+Eclipse-LazyStart: true
+Export-Package: org.scribble.conversation.model
+Scribble-Extensions: org.scribble.conversation.model.ConversationNotation
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6

Added: trunk/bundles/org.scribble.conversation.model/build.properties
===================================================================
--- trunk/bundles/org.scribble.conversation.model/build.properties	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.model/build.properties	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,5 @@
+source.. = src/main/java/
+output.. = classes/
+bin.includes = META-INF/,\
+               .,\
+               plugin.xml

Added: trunk/bundles/org.scribble.conversation.model/pom.xml
===================================================================
--- trunk/bundles/org.scribble.conversation.model/pom.xml	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.model/pom.xml	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,28 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  	<modelVersion>4.0.0</modelVersion>
+	<groupId>org.savara.bundles</groupId>
+	<artifactId>org.scribble.conversation.model</artifactId> 
+	<version>1.2.0-SNAPSHOT</version>
+	<packaging>jar</packaging>
+	<name>Savara::Bundles::ScribbleConversationModel</name>
+
+	<parent>
+		<groupId>org.savara</groupId>
+		<artifactId>bundles</artifactId>
+		<version>1.2.0-SNAPSHOT</version>
+	</parent>
+  
+	<dependencies>
+		<dependency>
+			<groupId>org.savara.bundles</groupId>
+			<artifactId>org.scribble.core</artifactId>
+			<version>1.2.0-SNAPSHOT</version>
+		</dependency>
+	    <dependency>
+	      <groupId>org.apache.felix</groupId>
+	      <artifactId>org.osgi.core</artifactId>
+	      <version>${osgi.version}</version>
+	    </dependency>
+	</dependencies>
+</project>

Added: trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/Assignment.java
===================================================================
--- trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/Assignment.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/Assignment.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2007-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 3 June 2009 : Initial version created by gary
+ */
+package org.scribble.conversation.model;
+
+import org.scribble.model.*;
+
+/**
+ * This class represents the Assignment construct.
+ * 
+ */
+public class Assignment extends Behaviour {
+
+	private static final long serialVersionUID = 4692091825946345905L;
+
+	/**
+	 * This is the default constructor.
+	 * 
+	 */
+	public Assignment() {
+	}
+	
+	/**
+	 * This method returns the list of roles at which
+	 * the decision is located.
+	 * 
+	 * @return The list of roles
+	 */
+	public java.util.List<Role> getRoles() {
+		return(m_roles);
+	}
+	
+	/**
+	 * This method returns the variable that is the target
+	 * of the assignment.
+	 * 
+	 * @return The target variable
+	 */
+	@Reference(containment=true)
+	public Variable getVariable() {
+		return(m_variable);
+	}
+	
+	/**
+	 * This method sets the variable that is the target
+	 * of the assignment.
+	 * 
+	 * @param var The target variable
+	 */
+	public void setVariable(Variable var) {
+		m_variable = var;
+	}
+		
+	/**
+	 * This method returns the expression being assigned.
+	 * 
+	 * @return The expression
+	 */
+	@Reference(containment=true)
+	public Expression getExpression() {
+		return(m_expression);
+	}
+	
+	/**
+	 * This method sets the expression being assigned.
+	 * 
+	 * @param expr The expression
+	 */
+	public void setExpression(Expression expr) {
+		
+		if (m_expression != null) {
+			m_expression.setParent(null);
+		}
+		
+		m_expression = expr;
+		
+		if (m_expression != null) {
+			m_expression.setParent(this);
+		}
+	}
+	
+	private java.util.List<Role> m_roles=new java.util.Vector<Role>();
+	private Expression m_expression=null;
+	private Variable m_variable=null;
+}

Added: trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/CatchBlock.java
===================================================================
--- trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/CatchBlock.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/CatchBlock.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 18 Oct 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.model;
+
+import org.scribble.model.Reference;
+import org.scribble.model.TypeReference;
+
+/**
+ * This class represents a group of activities within
+ * a catch specific 'escape' block of a
+ * try/escape construct.
+ * 
+ */
+public class CatchBlock extends EscapeBlock {
+
+	private static final long serialVersionUID = -144273641545824962L;
+
+	/**
+	 * This method returns the reference of the type associated
+	 * with the catch block.
+	 * 
+	 * @return The type
+	 */
+	@Reference(containment=true)
+	public TypeReference getType() {
+		return(m_type);
+	}
+	
+	/**
+	 * This method sets the reference of the type associated
+	 * with the catch block.
+	 * 
+	 * @param type The type
+	 */
+	public void setType(TypeReference type) {
+		
+		if (m_type != null) {
+			m_type.setParent(null);
+		}
+		
+		m_type = type;
+		
+		if (m_type != null) {
+			m_type.setParent(this);
+		}
+	}
+	
+	private TypeReference m_type=null;
+}

Added: trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/Compose.java
===================================================================
--- trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/Compose.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/Compose.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,188 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 9 Mar 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.model;
+
+import org.scribble.extensions.RegistryFactory;
+import org.scribble.model.*;
+import org.scribble.model.admin.DefaultModelListener;
+import org.scribble.model.admin.ModelRepository;
+
+/**
+ * This class represents the composition semantics associated
+ * with the Run and Spawn constructs.
+ * 
+ */
+public abstract class Compose extends ModelInclude {
+
+	private static final long serialVersionUID = -197685339387762151L;
+
+	/**
+	 * This is the default constructor.
+	 * 
+	 */
+	public Compose() {
+	}
+	
+	/**
+	 * This method returns the associated conversation.
+	 * 
+	 * @return The conversation
+	 */
+	public Conversation getDefinition() {
+		Conversation ret=m_inlineDefinition;
+		
+		if (ret == null && m_reference != null) {
+			
+			// Check if local reference
+			if (m_reference.isInner()) {
+				
+				// Search in containing conversation
+				ModelObject cur=getParent();
+				
+				while (ret == null && cur != null) {
+					if (cur instanceof Conversation) {
+						Conversation conv=(Conversation)cur;
+						
+						// Check if conversation contains
+						// sub-conversation of interest
+						for (int i=0; ret == null && i < 
+								conv.getBlock().getContents().size(); i++) {
+							if (conv.getBlock().getContents().get(i) instanceof Conversation) {
+								Conversation subconv=(Conversation)
+									conv.getBlock().getContents().get(i);
+		
+								if (subconv.getLocatedName() != null &&
+										subconv.getLocatedName().getName() != null &&
+										m_reference.getAlias().equals(
+											subconv.getLocatedName().getName()) &&
+									((m_reference.getLocatedRole() == null &&
+											subconv.getLocatedName().getRole() == null) ||
+									((m_reference.getLocatedRole() != null &&
+											subconv.getLocatedName().getRole() != null &&
+											m_reference.getLocatedRole().equals(
+												subconv.getLocatedName().getRole().getName()))))) {
+									
+									ret = subconv;
+								}
+							}
+						}
+					}
+					
+					cur = cur.getParent();
+				}
+
+/* GPB: TO REMOVE
+			} else {
+				ModelRepository mrep=(ModelRepository)
+							RegistryFactory.getRegistry().getExtension(
+										ModelRepository.class, null);
+				
+				if (mrep != null) {
+					java.util.List<ModelInfo> models=mrep.getModels(m_reference,
+									new DefaultModelListener());
+					
+					for (int i=0; ret == null &&
+								i < models.size(); i++) {
+						if (models.get(i).getModel() instanceof
+										ConversationModel) {
+							ret = ((ConversationModel)models.get(i).getModel()).getConversation();
+						}
+					}
+				}
+*/
+			}
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the conversation reference associated
+	 * with the run construct.
+	 * 
+	 * @return The conversation reference, or null if not defined
+	 */
+	@Reference(containment=true)
+	public ConversationReference getReference() {
+		return(m_reference);
+	}
+	
+	/**
+	 * This method sets the conversation reference associated
+	 * with the run construct.
+	 * 
+	 * @param ref The conversation reference
+	 */
+	public void setReference(ConversationReference ref) {
+		
+		if (m_reference != null) {
+			m_reference.setParent(null);
+		}
+		
+		m_reference = ref;
+		
+		if (m_reference != null) {
+			m_reference.setParent(this);
+		}
+	}
+
+	/**
+	 * This method indicates whether the model include is
+	 * an inline definition.
+	 * 
+	 * @return Whether an inline definition
+	 */
+	public boolean isInline() {
+		return(getInlineDefinition() != null);
+	}
+
+	/**
+	 * This method returns the inline definition associated
+	 * with the model include construct.
+	 * 
+	 * @return The inline definition, or null if not defined
+	 */
+	@Reference(containment=true)
+	public Conversation getInlineDefinition() {
+		return(m_inlineDefinition);
+	}
+	
+	/**
+	 * This method sets the inline definition associated
+	 * with the run construct.
+	 * 
+	 * @param definition The inner definition
+	 */
+	public void setInlineDefinition(Conversation definition) {
+		
+		if (m_inlineDefinition != null) {
+			m_inlineDefinition.setParent(null);
+		}
+		
+		m_inlineDefinition = definition;
+		
+		if (m_inlineDefinition != null) {
+			m_inlineDefinition.setParent(this);
+		}
+	}
+
+	private ConversationReference m_reference=null;
+	private Conversation m_inlineDefinition=null;
+}

Added: trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/ConditionalBlock.java
===================================================================
--- trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/ConditionalBlock.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/ConditionalBlock.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 13 Jan 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.model;
+
+import org.scribble.model.Reference;
+
+/**
+ * This class provides a conditional implementation of the
+ * Block component.
+ */
+public class ConditionalBlock extends org.scribble.model.Block {
+
+	private static final long serialVersionUID = 5438311908743472800L;
+
+	/**
+	 * This method returns the optional expression.
+	 * 
+	 * @return The expression, or null if not defined
+	 */
+	@Reference(containment=true)
+	public Expression getExpression() {
+		return(m_expression);
+	}
+	
+	/**
+	 * This method sets the optional expression.
+	 * 
+	 * @param expr The expression
+	 */
+	public void setExpression(Expression expr) {
+		// Clear the parent
+		if (m_expression != null) {
+			m_expression.setParent(null);
+		}
+		
+		m_expression = expr;
+		
+		// Set the parent
+		if (m_expression != null) {
+			m_expression.setParent(this);
+		}
+	}
+	
+	private Expression m_expression=null;
+}

Added: trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/Conversation.java
===================================================================
--- trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/Conversation.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/Conversation.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 9 Jan 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.model;
+
+import org.scribble.model.Activity;
+import org.scribble.model.ContainmentList;
+import org.scribble.model.Declaration;
+import org.scribble.model.Reference;
+
+/**
+ * This class represents the conversation notation.
+ */
+public class Conversation extends org.scribble.model.Definition {
+	
+	private static final long serialVersionUID = -664687154813751756L;
+
+	/**
+	 * The default constructor.
+	 */
+	public Conversation() {
+	}
+	
+	/**
+	 * This method returns whether the activity represents
+	 * a scope.
+	 * 
+	 * @return Whether activity represents a scope
+	 */
+	@Override
+	public boolean isScope() {
+		return(true);
+	}
+
+	/**
+	 * This method returns the list of identity definitions
+	 * that are used to identity a conversation.
+	 * 
+	 * @return The list of identities
+	 */
+	@Reference(containment=true)
+	public java.util.List<Identity> getIdentities() {
+		return(m_identities);
+	}
+	
+	/**
+	 * This method return the top level declarations associated
+	 * with the definition.
+	 * 
+	 * @return The declarations
+	 */
+	public java.util.Set<Declaration> getDeclarations() {
+		java.util.Set<Declaration> ret=super.getDeclarations();
+		
+		java.util.Iterator<Activity> iter=getBlock().getContents().iterator();
+		
+		while (iter.hasNext()) {
+			Activity act=iter.next();
+			
+			if (act instanceof VariableList) {
+				ret.addAll(((VariableList)act).getVariables());
+			}
+		}
+		
+		return(ret);
+	}
+		
+	private java.util.List<Identity> m_identities=
+			new ContainmentList<Identity>(this, Identity.class);
+}

Added: trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/ConversationInteraction.java
===================================================================
--- trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/ConversationInteraction.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/ConversationInteraction.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 10 Jan 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.model;
+
+/**
+ * This class represents a specific type of interaction associated
+ * with the conversation notation.
+ */
+public class ConversationInteraction extends org.scribble.model.Interaction {
+
+	private static final long serialVersionUID = 6037971710485056449L;
+
+	/**
+	 * This method returns the optional 'from' variable.
+	 * 
+	 * @return The optional 'from' variable
+	 */
+	public Variable getFromVariable() {
+		return(m_fromVariable);
+	}
+	
+	/**
+	 * This method sets the optional 'from' variable.
+	 * 
+	 * @param part The optional 'from' variable
+	 */
+	public void setFromVariable(Variable part) {
+		m_fromVariable = part;
+	}
+	
+	/**
+	 * This method returns the optional 'to' variable.
+	 * 
+	 * @return The optional 'to' variable
+	 */
+	public Variable getToVariable() {
+		return(m_toVariable);
+	}
+	
+	/**
+	 * This method sets the optional 'to' variable.
+	 * 
+	 * @param part The optional 'to' variable
+	 */
+	public void setToVariable(Variable part) {
+		m_toVariable = part;
+	}
+	
+	private Variable m_fromVariable=null;
+	private Variable m_toVariable=null;
+}

Added: trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/ConversationModel.java
===================================================================
--- trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/ConversationModel.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/ConversationModel.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 9 Jan 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.model;
+
+import org.scribble.model.*;
+import org.scribble.extensions.*;
+
+/**
+ * This class represents the conversation model.
+ * 
+ */
+ at RegistryInfo(extension=Model.class,notation=ConversationNotation.NOTATION_CODE)
+public class ConversationModel extends Model {
+
+	private static final long serialVersionUID = -1229586889208810341L;
+
+	/**
+	 * This method returns the model name associated with
+	 * the model.
+	 * 
+	 * @return The model name
+	 */
+	public LocatedName getModelName() {
+		LocatedName ret=null;
+		
+		if (m_conversation != null) {
+			ret = m_conversation.getLocatedName();
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the list of identity locators.
+	 * 
+	 * @return The identity locators
+	 */
+	@Reference(containment=true)
+	public java.util.List<IdentityLocator> getIdentityLocators() {
+		return(m_identityLocators);
+	}
+	
+	/**
+	 * This method sets the conversation.
+	 * 
+	 * @param conversation The conversation
+	 */
+	public void setConversation(Conversation conversation) {
+		
+		if (m_conversation != null) {
+			m_conversation.setParent(null);
+		}
+		
+		m_conversation = conversation;
+		
+		if (m_conversation != null) {
+			m_conversation.setParent(this);
+		}
+	}
+	
+	/**
+	 * This method returns the conversation.
+	 * 
+	 * @return The conversation
+	 */
+	@Reference(containment=true)
+	public Conversation getConversation() {
+		return(m_conversation);
+	}
+	
+	/**
+	 * This method returns the list of definitions supported by
+	 * this model.
+	 * 
+	 * @return The list of definitions
+	 */
+	public java.util.List<Definition> getDefinitions() {
+		java.util.List<Definition> ret=new java.util.Vector<Definition>();
+		
+		ret.add(getConversation());
+		
+		return(ret);
+	}
+	
+	private Conversation m_conversation=null;
+	private java.util.List<IdentityLocator> m_identityLocators=
+		new ContainmentList<IdentityLocator>(this, IdentityLocator.class);
+}

Added: trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/ConversationNotation.java
===================================================================
--- trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/ConversationNotation.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/ConversationNotation.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 9 Jan 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.model;
+
+import org.scribble.extensions.*;
+import org.scribble.model.ModelReference;
+
+/**
+ * This class represents the Conversation notation.
+ */
+ at RegistryInfo(extension=org.scribble.model.Notation.class)
+public class ConversationNotation extends org.scribble.model.AbstractNotation {
+
+	public static final String NOTATION_CODE="scv";
+	
+	/**
+	 * The default constructor for the conversation notation.
+	 */
+	public ConversationNotation() {
+		super(NOTATION_CODE, "Conversation", true);
+	}
+		
+	/**
+	 * This method returns the initial description associated
+	 * with the supplied reference.
+	 * 
+	 * @param ref The reference
+	 * @return The initial description, or null if no description
+	 */
+	public String getInitialDescription(ModelReference ref) {
+		StringBuffer buf=new StringBuffer();
+		
+		buf.append("namespace ");
+		buf.append(ref.getNamespace());
+		buf.append(";\r\n\r\n");
+		
+		buf.append("conversation ");
+		buf.append(ref.getLocalpart());
+		
+		if (ref.getLocatedRole() != null) {
+			buf.append(ModelReference.LOCATED_REFERENCE_SEPARATOR);
+			buf.append(ref.getLocatedRole());
+			buf.append(" {\r\n\trole\tP;\r\n\r\n}\r\n");
+		} else {		
+			buf.append(" {\r\n\trole\tP1, P2;\r\n\r\n}\r\n");
+		}
+		
+		return(buf.toString());
+	}
+}

Added: trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/ConversationReference.java
===================================================================
--- trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/ConversationReference.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/ConversationReference.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 9 Jan 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.model;
+
+import org.scribble.model.*;
+
+/**
+ * This class represents a conversation reference.
+ */
+public class ConversationReference extends ModelReference {
+
+	private static final long serialVersionUID = -5130644330077284094L;
+
+	/**
+	 * This is the default constructor for the conversation reference.
+	 */
+	public ConversationReference() {
+		super(ConversationNotation.NOTATION_CODE);
+	}
+	
+}

Added: trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/EscapeBlock.java
===================================================================
--- trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/EscapeBlock.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/EscapeBlock.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 18 Oct 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.model;
+
+import org.scribble.model.Block;
+import org.scribble.model.Role;
+
+/**
+ * This class represents a group of activities within
+ * an 'escape' block of a try/escape construct.
+ * 
+ */
+public abstract class EscapeBlock extends Block {
+
+	private static final long serialVersionUID = -3847008405100548354L;
+
+	/**
+	 * This method returns the list of roles at which
+	 * the escape decision is located.
+	 * 
+	 * @return The list of roles
+	 */
+	public java.util.List<Role> getRoles() {
+		return(m_roles);
+	}
+		
+	private java.util.List<Role> m_roles=new java.util.Vector<Role>();
+}

Added: trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/Expression.java
===================================================================
--- trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/Expression.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/Expression.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 1 Feb 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.model;
+
+/**
+ * This class describes a conditional expression.
+ */
+public abstract class Expression extends org.scribble.model.ModelObject {
+
+	private static final long serialVersionUID = -3588494040013982118L;
+	
+}

Added: trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/Identity.java
===================================================================
--- trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/Identity.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/Identity.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 27 Jul 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.model;
+
+import org.scribble.model.ModelObject;
+
+/**
+ * This interface represents a list of tokens used to determine the
+ * identity of the conversation.
+ */
+public class Identity extends ModelObject {
+
+	private static final long serialVersionUID = 4448340635894911022L;
+
+	/**
+	 * This method returns the list of identity token
+	 * names that represent this identity.
+	 * 
+	 * @return The list of identity token name
+	 */
+	public java.util.List<String> getNames() {
+		return(m_names);
+	}
+	
+	/**
+	 * This method returns the identity type.
+	 * 
+	 * @return The identity type
+	 */
+	public IdentityType getIdentityType() {
+		return(m_identityType);
+	}
+	
+	/**
+	 * This method sets the type associated with the
+	 * identity.
+	 * 
+	 * @param idtype The identity type
+	 */
+	public void setIdentityType(IdentityType idtype) {
+		m_identityType = idtype;
+	}
+	
+	public boolean equals(Object obj) {
+		boolean ret=false;
+
+		if (obj instanceof Identity) {
+			Identity other=(Identity)obj;
+			
+			if (other.m_identityType == m_identityType &&
+					other.m_names.size() == m_names.size()) {
+		
+				ret = true;
+				
+				for (int i=0; ret && i < m_names.size(); i++) {
+					ret = m_names.get(i).equals(other.m_names.get(i));
+				}
+			}
+		}
+		
+		return(ret);
+	}
+	
+	private java.util.List<String> m_names=new java.util.Vector<String>();
+	private IdentityType m_identityType=null;
+}

Added: trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/IdentityLocator.java
===================================================================
--- trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/IdentityLocator.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/IdentityLocator.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,142 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 27 Jul 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.model;
+
+import org.scribble.model.*;
+
+/**
+ * This interface represents the identity locators associated
+ * with a particular type.
+ */
+public class IdentityLocator extends ModelObject {
+
+	private static final long serialVersionUID = 5279517129760939317L;
+
+	/**
+	 * The default constructor for the identity locator.
+	 */
+	public IdentityLocator() {
+	}
+	
+	/**
+	 * This method returns the type associated with the
+	 * identity locator.
+	 * 
+	 * @return The type
+	 */
+	public TypeReference getType() {
+		return(m_type);
+	}
+	
+	/**
+	 * This method sets the type associated with the
+	 * identity locator.
+	 * 
+	 * @param type The type
+	 */
+	public void setType(TypeReference type) {
+		m_type = type;
+	}
+	
+	/** 
+	 * This method sets the locator associated with the identity
+	 * token.
+	 * 
+	 * @param identity The identity
+	 * @param locator The locator
+	 */
+	public void setLocator(String identity, String locator) {
+		
+		// TODO: The locator should really be modelled as an
+		// expresion.
+		
+		m_identities.add(identity);
+		m_locators.add(locator);
+	}
+	
+	/**
+	 * This method returns the number of identity locators.
+	 * 
+	 * @return The number of identity locators
+	 */
+	public int getNumberOfLocators() {
+		return(m_identities.size());
+	}
+	
+	/**
+	 * This method returns the identity at the supplied
+	 * index.
+	 * 
+	 * @param index The index
+	 * @return The identity at the index, or null if out of
+	 * 						range
+	 */
+	public String getIdentity(int index) {
+		String ret=null;
+		
+		if (index < m_identities.size()) {
+			ret = m_identities.get(index);
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the locator at the supplied
+	 * index.
+	 * 
+	 * @param index The index
+	 * @return The locator at the index, or null if out of
+	 * 						range
+	 */
+	public String getLocator(int index) {
+		String ret=null;
+		
+		if (index < m_locators.size()) {
+			ret = m_locators.get(index);
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the locator associated with
+	 * the supplied identity name.
+	 * 
+	 * @param identity The identiy name
+	 * @return The locator for the identity, or null if not
+	 * 						found
+	 */
+	public String getLocator(String identity) {
+		String ret=null;
+		
+		int index=m_identities.indexOf(identity);
+		
+		if (index != -1) {
+			ret = m_locators.get(index);
+		}
+		
+		return(ret);
+	}
+	
+	private TypeReference m_type=null;
+	private java.util.List<String> m_identities=new java.util.Vector<String>();
+	private java.util.List<String> m_locators=new java.util.Vector<String>();
+}

Added: trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/IdentityType.java
===================================================================
--- trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/IdentityType.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/IdentityType.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 27 Jul 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.model;
+
+/**
+ * This enumeration represents the values for the
+ * identity type.
+ */
+public enum IdentityType {
+	Primary,
+	Association,
+	Derived
+}

Added: trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/If.java
===================================================================
--- trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/If.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/If.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,297 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 13 Jan 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.model;
+
+import org.scribble.model.*;
+
+/**
+ * This class represents the If construct.
+ * 
+ */
+public class If extends MultiPathBehaviour {
+
+	private static final long serialVersionUID = -6399962290109914156L;
+
+	/**
+	 * This is the default constructor.
+	 * 
+	 */
+	public If() {
+	}
+	
+	/**
+	 * This method indicates whether the activity
+	 * is a conditional construct.
+	 * 
+	 * @return Whether the activity is conditional
+	 */
+	@Override
+	public boolean isConditional() {
+		// Will be conditional if there is no default path
+		return(getElseBlock() == null);
+	}
+	
+	/**
+	 * This method determines whether the paths are mutually
+	 * exclusive.
+	 * 
+	 * @return Whether the paths are mutually exclusive
+	 */
+	public boolean isMutuallyExclusivePaths() {
+		return(true);
+	}
+
+	/**
+	 * This method returns whether the behaviour is a wait
+	 * state.
+	 * 
+	 * @return Whether the behaviour is a wait state
+	 */
+	@Override
+	public boolean isWaitState() {
+		boolean ret=false;
+		
+		Role role=getLocatedRole();
+		
+		// Check if not a decision making role
+		if (role != null && m_roles.contains(role) == false) {
+			ret = true;
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the list of roles at which
+	 * the if decision is located.
+	 * 
+	 * @return The list of roles
+	 */
+	public java.util.List<Role> getRoles() {
+		return(m_roles);
+	}
+	
+	/**
+	 * This method returns the list of mutually exclusive
+	 * activity blocks that comprise the multi-path construct.
+	 * 
+	 * @return The list of blocks
+	 */
+	@Reference(containment=true)
+	public java.util.List<ConditionalBlock> getConditionalBlocks() {
+		return(m_blocks);
+	}
+	
+	/**
+	 * This method returns the optional 'else' block for the
+	 * 'if' statement.
+	 * 
+	 * @return The 'else' block
+	 */
+	@Reference(containment=true)
+	public Block getElseBlock() {
+		return(m_elseBlock);
+	}
+	
+	/**
+	 * This method sets the optional 'else' block for the
+	 * 'if' statement.
+	 * 
+	 * @param block The 'else' block
+	 */
+	public void setElseBlock(Block block) {
+		
+		if (m_elseBlock != null) {
+			m_elseBlock.setParent(null);
+		}
+		
+		m_elseBlock = block;
+		
+		if (m_elseBlock != null) {
+			m_elseBlock.setParent(this);
+		}
+	}
+	
+	/**
+	 * This method returns the list of mutually exclusive
+	 * activity blocks that comprise the multi-path construct.
+	 * 
+	 * @return The list of blocks
+	 */
+	public java.util.List<Block> getPaths() {
+		java.util.List<Block> ret=new java.util.Vector<Block>();
+		
+		ret.addAll(getConditionalBlocks());
+
+		if (m_elseBlock != null &&
+				getElseBlock().getContents().size() > 0) {
+			ret.add(getElseBlock());
+	
+		/* Shouldn't add path that is not there?
+		} else {
+			// Add place holder for this default path
+			ret.add(new Block());
+		*/
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method creates a new path within the multi-path
+	 * behaviour. If the implementation cannot create
+	 * the new path, then it will return null.
+	 * 
+	 * @return The new block, or null if cannot be created
+	 */
+	public Block createNewPath() {
+		ConditionalBlock ret=null;
+		
+		if (m_elseBlock == null) {
+			ret = new ConditionalBlock();
+			
+			m_blocks.add(ret);
+		}
+		
+		return(ret);
+	}
+
+	/**
+	 * This method removes a path from the multi-path
+	 * behaviour.
+	 * 
+	 * @param path The path
+	 * @return Whether the path was removed
+	 */
+	public boolean removePath(Block path) {
+		boolean ret=false;
+		
+		if (path == m_elseBlock) {
+			m_elseBlock = null;
+			
+			ret = true;
+		} else {
+			ret = m_blocks.remove(path);
+		}
+		
+		return(ret);
+	}
+
+	/**
+	 * This method indicates whether the construct requires a
+	 * strict scope to be maintained. If the scope does not
+	 * need to be strictly maintained, then it is possible that
+	 * either activities relevant to each path could either
+	 * be duplicated within each path, or shared following
+	 * the construct.
+	 * 
+	 * @return Whether a strict scope should be maintained
+	 */
+	public boolean isStrictScope() {
+		
+		// NOTE (20/11/08): When the If is conditional,
+		// i.e. where an else clause is not specified, then
+		// it seems like it is strict scope. Need to
+		// consider whether this mechanism is necessary or
+		// can be done another way - it is used in support
+		// of working out whether subsequent activities
+		// could potentially be duplicated in all paths.
+		
+		//return(false);
+		return(isConditional());
+	}
+	
+	/**
+	 * This method returns the ordering constraint for
+	 * the multipath behaviour.
+	 * 
+	 * @return The ordering constraint
+	 */
+	public OrderingConstraint getOrdering() {
+		// Return value must determine whether the
+		// 'if' construct is being used in a
+		// stateful or stateless conversation.
+		// If stateful, then order must be preserved.
+		// If stateless, then the ordering of all
+		// the paths in the top level construct
+		// can be unordered - but if constructs contained
+		// within any of those unordered paths would
+		// equally be ordered.
+		// NOTE: May be better to use a different
+		// specific construct for top level stateless
+		// conversation?? But then that complicates
+		// the language.
+		OrderingConstraint ret=OrderingConstraint.Ordered;
+		
+		Definition def=getEnclosingDefinition();
+		
+		if (def != null) {
+			def = def.getTopLevelDefinition();
+		}
+		
+		if (def != null && def.isStateless() && getParent()
+				instanceof Block && getParent().getParent()
+							== def) {
+			ret = OrderingConstraint.Unordered;
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the list of roles that are
+	 * responsible for initiating the activity. This can
+	 * be used to determine whether the model is
+	 * consistent in terms of decision makers subsequently
+	 * initiating actions.
+	 * 
+	 * @return The list of initiator roles
+	 */
+	@Override
+	public java.util.List<Role> getInitiatorRoles() {
+		java.util.List<Role> ret=super.getInitiatorRoles();
+
+		for (int i=0; i < getRoles().size(); i++) {
+			if (ret.contains(getRoles().get(i)) == false) {
+				ret.add(getRoles().get(i));
+			}
+		}
+		
+		return(ret);
+	}
+
+	/**
+	 * This method returns the list of roles that are
+	 * associated with the outcome of the activity.
+	 * 
+	 * @return The list of final roles
+	 */
+	@Override
+	public java.util.List<Role> getFinalRoles() {
+		java.util.List<Role> ret=super.getFinalRoles();
+				
+		return(ret);
+	}
+
+	private java.util.List<Role> m_roles=new java.util.Vector<Role>();
+	private java.util.List<ConditionalBlock> m_blocks=
+			new ContainmentList<ConditionalBlock>(this, ConditionalBlock.class);
+	private Block m_elseBlock=null;
+}

Added: trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/InterruptBlock.java
===================================================================
--- trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/InterruptBlock.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/InterruptBlock.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 18 Oct 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.model;
+
+import org.scribble.model.Reference;
+
+/**
+ * This class represents a group of activities within
+ * an interrupt specific 'escape' block of a
+ * try/escape construct.
+ * 
+ */
+public class InterruptBlock extends EscapeBlock {
+
+	private static final long serialVersionUID = 3296525328792975708L;
+
+	/**
+	 * This method returns the optional expression.
+	 * 
+	 * @return The expression, or null if not defined
+	 */
+	@Reference(containment=true)
+	public Expression getExpression() {
+		return(m_expression);
+	}
+	
+	/**
+	 * This method sets the optional expression.
+	 * 
+	 * @param expr The expression
+	 */
+	public void setExpression(Expression expr) {
+		// Clear the parent
+		if (m_expression != null) {
+			m_expression.setParent(null);
+		}
+		
+		m_expression = expr;
+		
+		// Set the parent
+		if (m_expression != null) {
+			m_expression.setParent(this);
+		}
+	}
+	
+	private Expression m_expression=null;
+}

Added: trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/Parallel.java
===================================================================
--- trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/Parallel.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/Parallel.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 8 Mar 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.model;
+
+import org.scribble.model.*;
+
+/**
+ * This class represents the Parallel construct with
+ * two or more concurrent paths.
+ * 
+ */
+public class Parallel extends MultiPathBehaviour {
+
+	private static final long serialVersionUID = -7183099368840527442L;
+
+	/**
+	 * This is the default constructor.
+	 * 
+	 */
+	public Parallel() {
+	}
+	
+	/**
+	 * This method returns the list of mutually exclusive
+	 * activity blocks that comprise the multi-path construct.
+	 * 
+	 * @return The list of blocks
+	 */
+	@Reference(containment=true)
+	public java.util.List<Block> getBlocks() {
+		return(m_blocks);
+	}
+	
+	/**
+	 * This method returns the list of mutually exclusive
+	 * activity blocks that comprise the multi-path construct.
+	 * 
+	 * @return The list of blocks
+	 */
+	public java.util.List<Block> getPaths() {
+		return(getBlocks());
+	}
+
+	/**
+	 * This method creates a new path within the multi-path
+	 * behaviour. If the implementation cannot create
+	 * the new path, then it will return null.
+	 * 
+	 * @return The new block, or null if cannot be created
+	 */
+	public Block createNewPath() {
+		Block ret=new Block();
+		
+		m_blocks.add(ret);
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method removes a path from the multi-path
+	 * behaviour.
+	 * 
+	 * @param path The path
+	 * @return Whether the path was removed
+	 */
+	public boolean removePath(Block path) {
+		boolean ret=false;
+		
+		ret = m_blocks.remove(path);
+		
+		return(ret);
+	}
+
+	/**
+	 * This method indicates whether the construct requires a
+	 * strict scope to be maintained. If the scope does not
+	 * need to be strictly maintained, then it is possible that
+	 * either activities relevant to each path could either
+	 * be duplicated within each path, or shared following
+	 * the construct.
+	 * 
+	 * @return Whether a strict scope should be maintained
+	 */
+	public boolean isStrictScope() {
+		return(true);
+	}
+	
+	/**
+	 * This method returns the ordering constraint for
+	 * the multipath behaviour.
+	 * 
+	 * @return The ordering constraint
+	 */
+	public OrderingConstraint getOrdering() {
+		return(OrderingConstraint.Unordered);
+	}
+	
+	private java.util.List<Block> m_blocks=new ContainmentList<Block>(this, Block.class);
+}

Added: trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/Raise.java
===================================================================
--- trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/Raise.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/Raise.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 10 Nov 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.model;
+
+import org.scribble.model.*;
+
+/**
+ * This class represents the Raise construct.
+ * 
+ */
+public class Raise extends Behaviour {
+
+	private static final long serialVersionUID = -3870323388560306665L;
+
+	/**
+	 * This is the default constructor.
+	 * 
+	 */
+	public Raise() {
+	}
+	
+	/**
+	 * This method returns the list of roles at which
+	 * the decision is located.
+	 * 
+	 * @return The list of roles
+	 */
+	public java.util.List<Role> getRoles() {
+		return(m_roles);
+	}
+		
+	/**
+	 * This method returns the reference of the type associated
+	 * with the catch block.
+	 * 
+	 * @return The type
+	 */
+	@Reference(containment=true)
+	public TypeReference getType() {
+		return(m_type);
+	}
+	
+	/**
+	 * This method sets the reference of the type associated
+	 * with the catch block.
+	 * 
+	 * @param type The type
+	 */
+	public void setType(TypeReference type) {
+		
+		if (m_type != null) {
+			m_type.setParent(null);
+		}
+		
+		m_type = type;
+		
+		if (m_type != null) {
+			m_type.setParent(this);
+		}
+	}
+	
+	private java.util.List<Role> m_roles=new java.util.Vector<Role>();
+	private TypeReference m_type=null;
+}

Added: trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/Run.java
===================================================================
--- trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/Run.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/Run.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 9 Mar 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.model;
+
+/**
+ * This class represents the Run construct.
+ * 
+ */
+public class Run extends Compose {
+
+	private static final long serialVersionUID = 6265665009720442123L;
+
+	/**
+	 * This is the default constructor.
+	 * 
+	 */
+	public Run() {
+	}
+	
+	/**
+	 * This method determines whether the compose construct
+	 * is asynchronous.
+	 * 
+	 * @return Whether the compose is asynchronous
+	 */
+	public boolean isAsynchronous() {
+		return(false);
+	}
+}

Added: trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/Spawn.java
===================================================================
--- trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/Spawn.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/Spawn.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 7 Aug 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.model;
+
+/**
+ * This class represents the Spawn construct.
+ * 
+ */
+public class Spawn extends Compose {
+
+	private static final long serialVersionUID = -7928304100765235995L;
+
+	/**
+	 * This is the default constructor.
+	 * 
+	 */
+	public Spawn() {
+	}
+	
+	/**
+	 * This method determines whether the compose construct
+	 * is asynchronous.
+	 * 
+	 * @return Whether the compose is asynchronous
+	 */
+	public boolean isAsynchronous() {
+		return(true);
+	}	
+}

Added: trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/TryEscape.java
===================================================================
--- trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/TryEscape.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/TryEscape.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,151 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 18 Oct 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.model;
+
+import org.scribble.model.*;
+
+/**
+ * This class represents the Try/Escape construct.
+ * 
+ */
+public class TryEscape extends MultiPathBehaviour {
+
+	private static final long serialVersionUID = -7186370891826420328L;
+
+	/**
+	 * This is the default constructor.
+	 * 
+	 */
+	public TryEscape() {
+		m_block.setParent(this);
+	}
+		
+	/**
+	 * This method returns the activities.
+	 * 
+	 * @return The block of activities
+	 */
+	@Reference(containment=true)
+	public Block getBlock() {
+		return(m_block);
+	}
+	
+	/**
+	 * This method sets the block.
+	 * 
+	 * @param block The block
+	 */
+	public void setBlock(Block block) {
+		if (m_block != null) {
+			m_block.setParent(null);
+		}
+		
+		m_block = block;
+		
+		if (m_block != null) {
+			m_block.setParent(this);
+		}
+	}
+
+	/**
+	 * This method returns the list of mutually exclusive
+	 * escape blocks.
+	 * 
+	 * @return The list of escape blocks
+	 */
+	@Reference(containment=true)
+	public java.util.List<EscapeBlock> getEscapeBlocks() {
+		return(m_escapeBlocks);
+	}
+	
+	/**
+	 * This method returns the list of mutually exclusive
+	 * activity blocks that comprise the multi-path construct.
+	 * 
+	 * @return The list of blocks
+	 */
+	public java.util.List<Block> getPaths() {
+		java.util.List<Block> ret=new java.util.Vector<Block>();
+		
+		ret.add(getBlock());
+		
+		ret.addAll(getEscapeBlocks());
+
+		return(ret);
+	}
+	
+	/**
+	 * This method creates a new path within the multi-path
+	 * behaviour. If the implementation cannot create
+	 * the new path, then it will return null.
+	 * 
+	 * @return The new block, or null if cannot be created
+	 */
+	public Block createNewPath() {
+		Block ret=null;
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method removes a path from the multi-path
+	 * behaviour.
+	 * 
+	 * @param path The path
+	 * @return Whether the path was removed
+	 */
+	public boolean removePath(Block path) {
+		boolean ret=false;
+		
+		return(ret);
+	}
+
+	/**
+	 * This method indicates whether the construct requires a
+	 * strict scope to be maintained. If the scope does not
+	 * need to be strictly maintained, then it is possible that
+	 * either activities relevant to each path could either
+	 * be duplicated within each path, or shared following
+	 * the construct.
+	 * 
+	 * @return Whether a strict scope should be maintained
+	 */
+	public boolean isStrictScope() {
+		return(true);
+	}
+	
+	/**
+	 * This method returns the ordering constraint for
+	 * the multipath behaviour.
+	 * 
+	 * @return The ordering constraint
+	 */
+	public OrderingConstraint getOrdering() {
+		// Return as unordered, although the first path
+		// (i.e. the try block) must appear first - but
+		// this will be guaranteed in a comparison
+		// against another try/escape construct,
+		// as this is determined by the language construct.
+		return(OrderingConstraint.Unordered);
+	}
+	
+	private Block m_block=new Block();
+	private java.util.List<EscapeBlock> m_escapeBlocks=new ContainmentList<EscapeBlock>(this, EscapeBlock.class);
+}

Added: trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/Variable.java
===================================================================
--- trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/Variable.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/Variable.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 10 Jan 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.model;
+
+import org.scribble.model.*;
+
+/**
+ * This class represents the variable declaration.
+ */
+public class Variable extends ModelObject implements Declaration {
+
+	private static final long serialVersionUID = 9101786233697037485L;
+
+	/**
+	 * This is the default constructor.
+	 */
+	public Variable() {
+	}
+	
+	/**
+	 * This method returns the name of the variable.
+	 * 
+	 * @return The name
+	 */
+	public String getName() {
+		return(m_name);
+	}
+	
+	/**
+	 * This method sets the name of the variable.
+	 * 
+	 * @param name The name
+	 */
+	public void setName(String name) {
+		m_name = name;
+	}
+	
+	/**
+	 * This method returns the reference of the type associated
+	 * with the variable.
+	 * 
+	 * @return The type
+	 */
+	public TypeReference getType() {
+		TypeReference ret=null;
+		
+		if (getParent() instanceof VariableList) {
+			ret = ((VariableList)getParent()).getType();
+		}
+		
+		return(ret);
+	}
+	
+	private String m_name=null;
+}

Added: trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/VariableList.java
===================================================================
--- trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/VariableList.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/VariableList.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 10 Jan 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.model;
+
+import org.scribble.model.*;
+
+/**
+ * This class represents the list of variables declared within
+ * a Scribble definition.
+ */
+public class VariableList extends Activity {
+
+	private static final long serialVersionUID = 2189313571333015979L;
+
+	/**
+	 * This method returns the reference of the type associated
+	 * with the variable list.
+	 * 
+	 * @return The type
+	 */
+	@Reference(containment=true)
+	public TypeReference getType() {
+		return(m_type);
+	}
+	
+	/**
+	 * This method sets the reference of the type associated
+	 * with the variable.
+	 * 
+	 * @param type The variable's type
+	 */
+	public void setType(TypeReference type) {
+		
+		if (m_type != null) {
+			m_type.setParent(null);
+		}
+		
+		m_type = type;
+		
+		if (m_type != null) {
+			m_type.setParent(this);
+		}
+	}
+	
+	/**
+	 * This method returns the list of variables.
+	 * 
+	 * @return The list of variables
+	 */
+	@Reference(containment=true)
+	public java.util.List<Variable> getVariables() {
+		return(m_variables);
+	}
+	
+	private TypeReference m_type=null;
+	private java.util.List<Variable> m_variables=
+				new ContainmentList<Variable>(this, Variable.class);
+}

Added: trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/When.java
===================================================================
--- trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/When.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/When.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,187 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 8 Mar 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.model;
+
+import org.scribble.model.*;
+
+/**
+ * This class represents the When construct.
+ * 
+ */
+public class When extends MultiPathBehaviour {
+
+	private static final long serialVersionUID = 482982129600626545L;
+
+	/**
+	 * This is the default constructor.
+	 * 
+	 */
+	public When() {
+	}
+	
+	/**
+	 * This method determines whether the paths are mutually
+	 * exclusive.
+	 * 
+	 * @return Whether the paths are mutually exclusive
+	 */
+	public boolean isMutuallyExclusivePaths() {
+		return(true);
+	}
+	
+	/**
+	 * This method returns whether the behaviour is a wait
+	 * state.
+	 * 
+	 * @return Whether the behaviour is a wait state
+	 */
+	@Override
+	public boolean isWaitState() {
+		return(true);
+	}
+	
+	/**
+	 * This method returns the list of roles at which
+	 * the 'when' decision is located.
+	 * 
+	 * @return The list of roles
+	 */
+	public java.util.List<Role> getRoles() {
+		return(m_roles);
+	}
+	
+	/**
+	 * This method returns the list of mutually exclusive
+	 * activity blocks that comprise the multi-path construct.
+	 * 
+	 * @return The list of blocks
+	 */
+	@Reference(containment=true)
+	public java.util.List<ConditionalBlock> getConditionalBlocks() {
+		return(m_blocks);
+	}
+	
+	/**
+	 * This method returns the list of mutually exclusive
+	 * activity blocks that comprise the multi-path construct.
+	 * 
+	 * @return The list of blocks
+	 */
+	public java.util.List<Block> getPaths() {
+		java.util.List<Block> ret=new java.util.Vector<Block>();
+		
+		ret.addAll(getConditionalBlocks());
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method creates a new path within the multi-path
+	 * behaviour. If the implementation cannot create
+	 * the new path, then it will return null.
+	 * 
+	 * @return The new block, or null if cannot be created
+	 */
+	public Block createNewPath() {
+		ConditionalBlock ret=new ConditionalBlock();
+		
+		m_blocks.add(ret);
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method removes a path from the multi-path
+	 * behaviour.
+	 * 
+	 * @param path The path
+	 * @return Whether the path was removed
+	 */
+	public boolean removePath(Block path) {
+		boolean ret=false;
+		
+		ret = m_blocks.remove(path);
+		
+		return(ret);
+	}
+
+	/**
+	 * This method indicates whether the construct requires a
+	 * strict scope to be maintained. If the scope does not
+	 * need to be strictly maintained, then it is possible that
+	 * either activities relevant to each path could either
+	 * be duplicated within each path, or shared following
+	 * the construct.
+	 * 
+	 * @return Whether a strict scope should be maintained
+	 */
+	public boolean isStrictScope() {
+		return(false);
+	}
+	
+	/**
+	 * This method returns the ordering constraint for
+	 * the multipath behaviour.
+	 * 
+	 * @return The ordering constraint
+	 */
+	public OrderingConstraint getOrdering() {
+		return(OrderingConstraint.Ordered);
+	}
+	
+	/**
+	 * This method returns the list of roles that are
+	 * responsible for initiating the activity. This can
+	 * be used to determine whether the model is
+	 * consistent in terms of decision makers subsequently
+	 * initiating actions.
+	 * 
+	 * @return The list of initiator roles
+	 */
+	@Override
+	public java.util.List<Role> getInitiatorRoles() {
+		java.util.List<Role> ret=super.getInitiatorRoles();
+
+		for (int i=0; i < getRoles().size(); i++) {
+			if (ret.contains(getRoles().get(i)) == false) {
+				ret.add(getRoles().get(i));
+			}
+		}
+		
+		return(ret);
+	}
+
+	/**
+	 * This method returns the list of roles that are
+	 * associated with the outcome of the activity.
+	 * 
+	 * @return The list of final roles
+	 */
+	@Override
+	public java.util.List<Role> getFinalRoles() {
+		java.util.List<Role> ret=super.getFinalRoles();
+				
+		return(ret);
+	}
+
+	private java.util.List<Role> m_roles=new java.util.Vector<Role>();
+	private java.util.List<ConditionalBlock> m_blocks=
+			new ContainmentList<ConditionalBlock>(this, ConditionalBlock.class);
+}

Added: trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/While.java
===================================================================
--- trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/While.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/While.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,167 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 8 Mar 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.model;
+
+import org.scribble.model.*;
+
+/**
+ * This class represents the While construct.
+ * 
+ */
+public class While extends SinglePathBehaviour {
+
+	private static final long serialVersionUID = 1095711964302049544L;
+
+	/**
+	 * This is the default constructor.
+	 * 
+	 */
+	public While() {
+		m_block.setParent(this);
+	}
+	
+	/**
+	 * This method returns whether the behaviour is a wait
+	 * state.
+	 * 
+	 * @return Whether the behaviour is a wait state
+	 */
+	@Override
+	public boolean isWaitState() {
+		boolean ret=false;
+		
+		Role role=getLocatedRole();
+		
+		// Check if not a decision making role
+		if (role != null && m_roles.contains(role) == false) {
+			ret = true;
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the list of roles at which
+	 * the repeat decision is located.
+	 * 
+	 * @return The list of roles
+	 */
+	public java.util.List<Role> getRoles() {
+		return(m_roles);
+	}
+	
+	/**
+	 * This method returns the activities.
+	 * 
+	 * @return The block of activities
+	 */
+	@Reference(containment=true)
+	public ConditionalBlock getBlock() {
+		return(m_block);
+	}
+	
+	/**
+	 * This method sets the conditional block.
+	 * 
+	 * @param block The conditional block
+	 */
+	public void setBlock(ConditionalBlock block) {
+		if (m_block != null) {
+			m_block.setParent(null);
+		}
+		
+		m_block = block;
+		
+		if (m_block != null) {
+			m_block.setParent(this);
+		}
+	}
+
+	/**
+	 * This method indicates whether the construct requires a
+	 * strict scope to be maintained. If the scope does not
+	 * need to be strictly maintained, then it is possible that
+	 * activities could be contained by the construct or
+	 * following the construct.
+	 * 
+	 * @return Whether a strict scope should be maintained
+	 */
+	public boolean isStrictScope() {
+		return(true);
+	}
+	
+	/**
+	 * This method indicates whether the activity
+	 * is a conditional construct.
+	 * 
+	 * @return Whether the activity is conditional
+	 */
+	public boolean isConditional() {
+		return(true);
+	}
+	
+	/**
+	 * This method indicates whether the construct is
+	 * repetitive.
+	 * 
+	 * @return Whether the construct supports repetition
+	 */
+	public boolean isRepetition() {
+		return(true);
+	}
+	
+	/**
+	 * This method returns the list of roles that are
+	 * responsible for initiating the activity. This can
+	 * be used to determine whether the model is
+	 * consistent in terms of decision makers subsequently
+	 * initiating actions.
+	 * 
+	 * @return The list of initiator roles
+	 */
+	@Override
+	public java.util.List<Role> getInitiatorRoles() {
+		java.util.List<Role> ret=super.getInitiatorRoles();
+
+		for (int i=0; i < getRoles().size(); i++) {
+			if (ret.contains(getRoles().get(i)) == false) {
+				ret.add(getRoles().get(i));
+			}
+		}
+		
+		return(ret);
+	}
+
+	/**
+	 * This method returns the list of roles that are
+	 * associated with the outcome of the activity.
+	 * 
+	 * @return The list of final roles
+	 */
+	@Override
+	public java.util.List<Role> getFinalRoles() {
+		java.util.List<Role> ret=super.getFinalRoles();
+				
+		return(ret);
+	}
+
+	private ConditionalBlock m_block=new ConditionalBlock();
+	private java.util.List<Role> m_roles=new java.util.Vector<Role>();
+}

Added: trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/osgi/Activator.java
===================================================================
--- trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/osgi/Activator.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.model/src/main/java/org/scribble/conversation/model/osgi/Activator.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 9 Jan 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.model.osgi;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleActivator;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator implements BundleActivator {
+
+	// The plug-in ID
+	public static final String PLUGIN_ID = "org.scribble.conversation.model";
+
+	// The shared instance
+	private static Activator plugin;
+	
+	/**
+	 * The constructor
+	 */
+	public Activator() {
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
+	 */
+	public void start(BundleContext context) throws Exception {
+		plugin = this;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
+	 */
+	public void stop(BundleContext context) throws Exception {
+		plugin = null;
+	}
+
+	/**
+	 * Returns the shared instance
+	 *
+	 * @return the shared instance
+	 */
+	public static Activator getDefault() {
+		return plugin;
+	}
+
+}

Added: trunk/bundles/org.scribble.conversation.model/src/test/org/scribble/conversation/model/IfTest.java
===================================================================
--- trunk/bundles/org.scribble.conversation.model/src/test/org/scribble/conversation/model/IfTest.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.model/src/test/org/scribble/conversation/model/IfTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,128 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 10 Nov 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.model;
+
+import org.scribble.model.*;
+
+import junit.framework.TestCase;
+
+public class IfTest extends TestCase {
+
+	public void testIsWaitStateFalse() {
+		
+		Definition d=new Definition() {
+		};
+		
+		LocatedName mn=new LocatedName();
+		d.setLocatedName(mn);
+		
+		Role r1=new Role();
+		r1.setName("r1");
+		
+		Role r2=new Role();
+		r2.setName("r2");
+		
+		mn.setRole(r1);
+		
+		If ifelem=new If();
+		d.getBlock().getContents().add(ifelem);
+		
+		ifelem.getRoles().add(r1);
+		ifelem.getRoles().add(r2);
+		
+		if (ifelem.isWaitState()) {
+			fail("NOT a wait state");
+		}
+	}
+
+	public void testIsWaitStateTrue() {
+		
+		Definition d=new Definition() {
+		};
+		
+		LocatedName mn=new LocatedName();
+		d.setLocatedName(mn);
+		
+		Role r1=new Role();
+		r1.setName("r1");
+		
+		Role r2=new Role();
+		r2.setName("r2");
+		
+		mn.setRole(r1);
+		
+		If ifelem=new If();
+		d.getBlock().getContents().add(ifelem);
+		
+		ifelem.getRoles().add(r2);
+		
+		if (ifelem.isWaitState() == false) {
+			fail("Is a wait state");
+		}
+	}
+	
+	public void testGetOrdering() {
+		
+		Conversation conv=new Conversation();
+		
+		If ifelem=new If();
+		
+		conv.getBlock().getContents().add(ifelem);
+		
+		if (ifelem.getOrdering() != OrderingConstraint.Ordered) {
+			fail("If should be ordered");
+		}
+	}
+	
+	public void testGetOrderingStateless() {
+		
+		Conversation conv=new Conversation();
+		conv.setStateless(true);
+		
+		If ifelem=new If();
+		
+		conv.getBlock().getContents().add(ifelem);
+		
+		if (ifelem.getOrdering() != OrderingConstraint.Unordered) {
+			fail("If should be unordered");
+		}
+	}
+	
+	public void testGetOrderingStatelessContainedIf() {
+		
+		Conversation conv=new Conversation();
+		conv.setStateless(true);
+		
+		If topif=new If();
+		
+		conv.getBlock().getContents().add(topif);
+		
+		ConditionalBlock cb=new ConditionalBlock();
+		topif.getConditionalBlocks().add(cb);
+		
+		If ifelem=new If();
+		
+		cb.getContents().add(ifelem);
+		
+		if (ifelem.getOrdering() != OrderingConstraint.Ordered) {
+			fail("If should be ordered");
+		}
+	}
+}

Added: trunk/bundles/org.scribble.conversation.model/src/test/org/scribble/conversation/model/WhileTest.java
===================================================================
--- trunk/bundles/org.scribble.conversation.model/src/test/org/scribble/conversation/model/WhileTest.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.model/src/test/org/scribble/conversation/model/WhileTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 10 Nov 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.model;
+
+import org.scribble.model.*;
+
+import junit.framework.TestCase;
+
+public class WhileTest extends TestCase {
+
+	public void testIsWaitStateFalse() {
+		
+		Definition d=new Definition() {
+		};
+		
+		LocatedName mn=new LocatedName();
+		d.setLocatedName(mn);
+		
+		Role r1=new Role();
+		r1.setName("r1");
+		
+		Role r2=new Role();
+		r2.setName("r2");
+		
+		mn.setRole(r1);
+		
+		While whileElem=new While();
+		d.getBlock().getContents().add(whileElem);
+		
+		whileElem.getRoles().add(r1);
+		whileElem.getRoles().add(r2);
+		
+		if (whileElem.isWaitState()) {
+			fail("NOT a wait state");
+		}
+	}
+
+	public void testIsWaitStateTrue() {
+		
+		Definition d=new Definition() {
+		};
+		
+		LocatedName mn=new LocatedName();
+		d.setLocatedName(mn);
+		
+		Role r1=new Role();
+		r1.setName("r1");
+		
+		Role r2=new Role();
+		r2.setName("r2");
+		
+		mn.setRole(r1);
+		
+		While whileElem=new While();
+		d.getBlock().getContents().add(whileElem);
+		
+		whileElem.getRoles().add(r2);
+		
+		if (whileElem.isWaitState() == false) {
+			fail("Is a wait state");
+		}
+	}
+}

Added: trunk/bundles/org.scribble.conversation.parser/.classpath
===================================================================
--- trunk/bundles/org.scribble.conversation.parser/.classpath	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.parser/.classpath	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src/main/java"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="output" path="classes"/>
+</classpath>

Added: trunk/bundles/org.scribble.conversation.parser/.project
===================================================================
--- trunk/bundles/org.scribble.conversation.parser/.project	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.parser/.project	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.scribble.conversation.parser</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.ManifestBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.SchemaBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.pde.PluginNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

Added: trunk/bundles/org.scribble.conversation.parser/LICENSE.txt
===================================================================
--- trunk/bundles/org.scribble.conversation.parser/LICENSE.txt	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.parser/LICENSE.txt	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,201 @@
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   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.

Added: trunk/bundles/org.scribble.conversation.parser/META-INF/MANIFEST.MF
===================================================================
--- trunk/bundles/org.scribble.conversation.parser/META-INF/MANIFEST.MF	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.parser/META-INF/MANIFEST.MF	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,31 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Scribble Conversation Parser Plug-in
+Bundle-SymbolicName: org.scribble.conversation.parser;singleton:=true
+Bundle-Version: 1.2.0.qualifier
+Bundle-Activator: org.scribble.conversation.parser.osgi.Activator
+Bundle-Vendor: www.scribble.org
+Import-Package: org.osgi.framework;version="1.3.0"
+Require-Bundle: org.scribble.core;bundle-version="[1.0.0,2.0.0)",
+ org.scribble.conversation.model;bundle-version="[1.0.0,2.0.0)"
+Bundle-ActivationPolicy: lazy
+Scribble-Extensions: org.scribble.conversation.parser.ConversationKeyWordProvider,
+   org.scribble.conversation.parser.ConversationParserRule,
+   org.scribble.conversation.parser.ConversationReferenceParserRule,
+   org.scribble.conversation.parser.ConversationInteractionParserRule,
+   org.scribble.conversation.parser.IfParserRule,
+   org.scribble.conversation.parser.WhenParserRule,
+   org.scribble.conversation.parser.WhileParserRule,
+   org.scribble.conversation.parser.ParallelParserRule,
+   org.scribble.conversation.parser.RunParserRule,
+   org.scribble.conversation.parser.RunConversationParserRule,
+   org.scribble.conversation.parser.SpawnParserRule,
+   org.scribble.conversation.parser.SpawnConversationParserRule,
+   org.scribble.conversation.parser.VariableListParserRule,
+   org.scribble.conversation.parser.ConversationModelParserRule,
+   org.scribble.conversation.parser.RaiseParserRule,
+   org.scribble.conversation.parser.TryEscapeParserRule,
+   org.scribble.conversation.parser.CatchBlockParserRule,
+   org.scribble.conversation.parser.InterruptBlockParserRule
+Export-Package: org.scribble.conversation.parser
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6

Added: trunk/bundles/org.scribble.conversation.parser/build.properties
===================================================================
--- trunk/bundles/org.scribble.conversation.parser/build.properties	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.parser/build.properties	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,5 @@
+source.. = src/main/java/
+output.. = classes/
+bin.includes = META-INF/,\
+               .,\
+               plugin.xml

Added: trunk/bundles/org.scribble.conversation.parser/pom.xml
===================================================================
--- trunk/bundles/org.scribble.conversation.parser/pom.xml	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.parser/pom.xml	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,33 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  	<modelVersion>4.0.0</modelVersion>
+	<groupId>org.savara.bundles</groupId>
+	<artifactId>org.scribble.conversation.parser</artifactId> 
+	<version>1.2.0-SNAPSHOT</version>
+	<packaging>jar</packaging>
+	<name>Savara::Bundles::ScribbleConversationParser</name>
+
+	<parent>
+		<groupId>org.savara</groupId>
+		<artifactId>bundles</artifactId>
+		<version>1.2.0-SNAPSHOT</version>
+	</parent>
+  
+	<dependencies>
+		<dependency>
+			<groupId>org.savara.bundles</groupId>
+			<artifactId>org.scribble.core</artifactId>
+			<version>1.2.0-SNAPSHOT</version>
+		</dependency>
+		<dependency>
+			<groupId>org.savara.bundles</groupId>
+			<artifactId>org.scribble.conversation.model</artifactId>
+			<version>1.2.0-SNAPSHOT</version>
+		</dependency>
+	    <dependency>
+	      <groupId>org.apache.felix</groupId>
+	      <artifactId>org.osgi.core</artifactId>
+	      <version>${osgi.version}</version>
+	    </dependency>
+	</dependencies>
+</project>

Added: trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/CatchBlockParserRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/CatchBlockParserRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/CatchBlockParserRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,154 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 18 Oct 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.parser;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.parser.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class provides the parser rule for the CatchBlock construct.
+ * 
+ */
+ at RegistryInfo(extension=ParserRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class CatchBlockParserRule extends org.scribble.parser.AbstractParserRule {
+
+	/**
+	 * The default constructor.
+	 */
+	public CatchBlockParserRule() {
+		super(ParserRuleType.Group);
+	}
+	
+	/**
+	 * This method determines whether the parser rules is
+	 * appropriate to return a model object of the required
+	 * type.
+	 * 
+	 * @param type The required type
+	 * @return Whether the parser rule returns a
+	 * 				model object of the required type
+	 */
+	public boolean isSupported(Class<?> type) {
+		return(type.isAssignableFrom(CatchBlock.class));
+	}
+
+	/**
+	 * This method parses the description to obtain
+	 * a model object of the appropriate type.
+	 * 
+	 * @param context The context
+	 * @param l The listener
+	 * @return The model object
+	 */
+	public Object parse(ParserContext context, ModelListener l) {
+		CatchBlock ret=null;
+		
+		Token t=context.lookahead(0);
+		
+		if (t.isToken("catch", TokenType.Keyword)) {
+			int startpos=t.getSource().getStartPosition();
+			
+			// Consume token
+			context.nextToken();
+			
+			ret = new CatchBlock();
+			
+			ret.getSource().setStartPosition(startpos);
+			
+			// Check for located roles
+			t = context.lookahead(0);
+			
+			if (t.isToken(ModelReference.LOCATED_REFERENCE_SEPARATOR,
+								TokenType.Symbol)) {
+				boolean f_error=false;
+				
+				// Work through list of roles
+				do {
+					// Consume token
+					context.nextToken();
+					
+					// Read next token, which should be an identifier
+					t = context.lookahead(0);
+				
+					if (t.getType() == TokenType.Identifier) {
+						
+						// Consume token
+						context.nextToken();
+					
+						// Locate the role definition
+						Object part=context.getState(t.getText());
+						
+						if (part == null) {
+							l.error(new ModelIssue(t,
+								org.scribble.util.MessageUtil.format(
+										java.util.PropertyResourceBundle.getBundle(
+												"org.scribble.parser.Messages"),
+										"_UNKNOWN_ROLE",
+										new String[]{t.getText()})));
+						} else if (part instanceof Role) {
+							ret.getRoles().add((Role)part);
+						} else {
+							l.error(new ModelIssue(t,
+								org.scribble.util.MessageUtil.format(
+										java.util.PropertyResourceBundle.getBundle(
+												"org.scribble.parser.Messages"),
+										"_REQUIRED_ROLE",
+										new String[]{t.getText()})));
+						}
+						
+						t = context.lookahead(0);
+					} else {
+						l.error(new ModelIssue(t, java.util.PropertyResourceBundle.getBundle(
+							"org.scribble.parser.Messages").
+							getString("_EXPECTING_ROLE_NAME")));
+						f_error = true;
+					}
+				} while (f_error == false &&
+						t.isToken(ParserConstants.LIST_SEPARATOR,
+								TokenType.Symbol));				
+			}
+
+			// Get the type reference
+			TypeReference typeRef=(TypeReference)
+						context.parse(TypeReference.class, l);
+			
+			
+			// GPB: TO REMOVE resolveReference(context, l, typeRef, DependencyType.Uses);
+
+			ret.setType(typeRef);
+
+			// Parse group
+			parseGroup(context, l, ret, true);
+			
+			// Parsing the group does not consume the final curly
+			// bracket, to ensure that other rules know that the
+			// block has completed, so need to look past this token
+			t = context.lookahead(0);
+			
+			ret.getSource().setEndPosition(t.getSource().getStartPosition());
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/ConversationInteractionParserRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/ConversationInteractionParserRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/ConversationInteractionParserRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,285 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 10 Jan 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.parser;
+
+import org.scribble.extensions.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.conversation.model.*;
+import org.scribble.parser.*;
+
+/**
+ * This class provides the parser rule for the ConversationInteraction.
+ * 
+ */
+ at RegistryInfo(extension=ParserRule.class,notation=ConversationNotation.NOTATION_CODE) //,preference=10,category=Interaction.class
+public class ConversationInteractionParserRule extends org.scribble.parser.InteractionParserRule {
+
+	/**
+	 * The default constructor.
+	 */
+	public ConversationInteractionParserRule() {
+	}
+	
+	/**
+	 * This method determines whether the parser rules is
+	 * appropriate to return a model object of the required
+	 * type.
+	 * 
+	 * @param type The required type
+	 * @return Whether the parser rule returns a
+	 * 				model object of the required type
+	 */
+	public boolean isSupported(Class<?> type) {
+		return(type.isAssignableFrom(ConversationInteraction.class));
+	}
+
+	/**
+	 * This method creates a new interaction instance.
+	 * 
+	 * @return The interaction instance
+	 */
+	protected Interaction createInteraction() {
+		return(new ConversationInteraction());
+	}
+
+	/**
+	 * This method parses the set of tokens associated with an interaction
+	 * based on the supplied keyword.
+	 * 
+	 * @param keyword The keyword
+	 * @param interaction The interaction being constructed
+	 * @param context The context
+	 * @param l The model listener
+	 * @return Whether the supplied keyword was processed
+	 */
+	protected boolean parseKeyword(String keyword, Interaction interaction,
+					ParserContext context, ModelListener l) {
+		boolean f_processed=false;
+		
+		if (keyword.equals("from")) {
+						
+			// Consume
+			context.nextToken();
+			
+			Token roleOrVar=context.nextToken();
+			Token atVar=null;
+			
+			if (roleOrVar.getType() == TokenType.Identifier) {
+				
+				// Check if variable has been specified
+				Token t=context.lookahead(0);
+				
+				if (t.isToken("@", TokenType.Symbol)) {
+					context.nextToken();
+					
+					atVar = context.lookahead(0);
+					
+					if (atVar.getType() != TokenType.Identifier) {
+						atVar = null;
+					} else {
+						context.nextToken();
+					}
+				}
+				
+				Object state=context.getState(roleOrVar.getText());
+	
+				if (state == null) {
+					l.error(new ModelIssue(roleOrVar,
+							org.scribble.util.MessageUtil.format(
+									java.util.PropertyResourceBundle.getBundle(
+											"org.scribble.conversation.parser.Messages"),
+									"_UNKNOWN_VARIABLE_OR_ROLE",
+									new String[]{roleOrVar.getText()})));
+				} else if (state instanceof Variable) {
+					((ConversationInteraction)interaction).
+								setFromVariable((Variable)state);
+					
+					if (atVar != null) {
+						state=context.getState(atVar.getText());
+						
+						if (state == null) {
+							l.error(new ModelIssue(atVar,
+									org.scribble.util.MessageUtil.format(
+											java.util.PropertyResourceBundle.getBundle(
+													"org.scribble.parser.Messages"),
+											"_UNKNOWN_ROLE",
+											new String[]{atVar.getText()})));
+						} else if (state instanceof Role) {
+							Role r=new Role();
+							r.setName(atVar.getText());
+							
+							r.derivedFrom(atVar);
+							
+							((ConversationInteraction)interaction).
+										setFromRole(r);
+							
+						} else {
+							l.error(new ModelIssue(atVar,
+									org.scribble.util.MessageUtil.format(
+											java.util.PropertyResourceBundle.getBundle(
+													"org.scribble.parser.Messages"),
+											"_REQUIRED_ROLE",
+											new String[]{atVar.getText()})));
+						}
+					}
+				} else if (atVar != null) {
+					l.error(new ModelIssue(roleOrVar,
+							org.scribble.util.MessageUtil.format(
+									java.util.PropertyResourceBundle.getBundle(
+											"org.scribble.conversation.parser.Messages"),
+									"_REQUIRED_VARIABLE",
+									new String[]{roleOrVar.getText()})));
+				} else if (state instanceof Role) {
+					Role r=new Role();
+					r.setName(roleOrVar.getText());
+					
+					r.derivedFrom(roleOrVar);
+					
+					interaction.setFromRole(r);
+					
+					if (atVar != null) {
+						l.error(new ModelIssue(atVar,
+								org.scribble.util.MessageUtil.format(
+										java.util.PropertyResourceBundle.getBundle(
+												"org.scribble.conversation.parser.Messages"),
+										"_REQUIRED_VARIABLE",
+										new String[]{atVar.getText()})));
+					}
+				} else {
+					l.error(new ModelIssue(roleOrVar,
+							org.scribble.util.MessageUtil.format(
+									java.util.PropertyResourceBundle.getBundle(
+											"org.scribble.conversation.parser.Messages"),
+									"_REQUIRED_VARIABLE_OR_ROLE",
+									new String[]{roleOrVar.getText()})));
+				}
+				
+				f_processed = true;
+			}
+
+		} else if (keyword.equals("to")) {
+						
+			// Consume
+			context.nextToken();
+			
+			Token roleOrVar=context.nextToken();
+			Token atVar=null;
+			
+			if (roleOrVar.getType() == TokenType.Identifier) {
+				
+				// Check if variable has been specified
+				Token t=context.lookahead(0);
+				
+				if (t.isToken("@", TokenType.Symbol)) {
+					context.nextToken();
+					
+					atVar = context.lookahead(0);
+					
+					if (atVar.getType() != TokenType.Identifier) {
+						atVar = null;
+					} else {
+						context.nextToken();
+					}
+				}
+				
+				Object state=context.getState(roleOrVar.getText());
+	
+				if (state == null) {
+					l.error(new ModelIssue(roleOrVar,
+							org.scribble.util.MessageUtil.format(
+									java.util.PropertyResourceBundle.getBundle(
+											"org.scribble.conversation.parser.Messages"),
+									"_UNKNOWN_VARIABLE_OR_ROLE",
+									new String[]{roleOrVar.getText()})));
+				} else if (state instanceof Variable) {
+					((ConversationInteraction)interaction).
+								setToVariable((Variable)state);
+					
+					if (atVar != null) {
+						state=context.getState(atVar.getText());
+						
+						if (state == null) {
+							l.error(new ModelIssue(atVar,
+									org.scribble.util.MessageUtil.format(
+											java.util.PropertyResourceBundle.getBundle(
+													"org.scribble.parser.Messages"),
+											"_UNKNOWN_ROLE",
+											new String[]{atVar.getText()})));
+						} else if (state instanceof Role) {
+							Role r=new Role();
+							r.setName(atVar.getText());
+							
+							r.derivedFrom(atVar);
+							
+							((ConversationInteraction)interaction).
+										setToRole(r);
+							
+						} else {
+							l.error(new ModelIssue(atVar,
+									org.scribble.util.MessageUtil.format(
+											java.util.PropertyResourceBundle.getBundle(
+													"org.scribble.parser.Messages"),
+											"_REQUIRED_ROLE",
+											new String[]{atVar.getText()})));
+						}
+					}
+				} else if (atVar != null) {
+					l.error(new ModelIssue(roleOrVar,
+							org.scribble.util.MessageUtil.format(
+									java.util.PropertyResourceBundle.getBundle(
+											"org.scribble.conversation.parser.Messages"),
+									"_REQUIRED_VARIABLE",
+									new String[]{roleOrVar.getText()})));
+				} else if (state instanceof Role) {
+					Role r=new Role();
+					r.setName(roleOrVar.getText());
+					
+					r.derivedFrom(roleOrVar);
+					
+					interaction.setToRole(r);
+					
+					if (atVar != null) {
+						l.error(new ModelIssue(atVar,
+								org.scribble.util.MessageUtil.format(
+										java.util.PropertyResourceBundle.getBundle(
+												"org.scribble.conversation.parser.Messages"),
+										"_REQUIRED_VARIABLE",
+										new String[]{atVar.getText()})));
+					}
+				} else {
+					l.error(new ModelIssue(roleOrVar,
+							org.scribble.util.MessageUtil.format(
+									java.util.PropertyResourceBundle.getBundle(
+											"org.scribble.conversation.parser.Messages"),
+									"_REQUIRED_VARIABLE_OR_ROLE",
+									new String[]{roleOrVar.getText()})));
+				}
+				
+				f_processed = true;
+			}
+		} else {
+			f_processed = super.parseKeyword(keyword, interaction, context, l);
+		}
+		
+		return(f_processed);
+	}
+}

Added: trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/ConversationKeyWordProvider.java
===================================================================
--- trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/ConversationKeyWordProvider.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/ConversationKeyWordProvider.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 9 Jan 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.parser;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.parser.DefaultKeyWordProvider;
+import org.scribble.parser.KeyWordProvider;
+import org.scribble.conversation.model.*;
+
+/**
+ * The conversation notation keyword provider.
+ */
+ at RegistryInfo(extension=KeyWordProvider.class,notation=ConversationNotation.NOTATION_CODE)
+public class ConversationKeyWordProvider extends DefaultKeyWordProvider {
+	
+	public ConversationKeyWordProvider() {
+		super(CONVERSATION_KEYWORDS);
+	}
+	
+	private static final String[] CONVERSATION_KEYWORDS={
+		"namespace",
+		"import",
+		"as",
+		"identify",
+		"with",
+		"using",
+		"stateless",
+		"conversation",
+		"conforms",
+		"implements",
+		"identified",
+		"by",
+		"role",
+		"channel",
+		"via",
+		"from",
+		"to",
+		"request",
+		"replyTo",
+		"parallel",
+		"and",
+		"when",
+		"if",
+		"else",
+		"while",
+		"recur",
+		"run",
+		"spawn",
+		"for",
+		"try",
+		"catch",
+		"interrupt",
+		"raise"
+	};
+}

Added: trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/ConversationModelParserRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/ConversationModelParserRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/ConversationModelParserRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 9 Jan 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.parser;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.Import;
+import org.scribble.model.Model;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.parser.ParserContext;
+import org.scribble.parser.ParserRule;
+import org.scribble.parser.Token;
+import org.scribble.parser.TokenType;
+
+import org.scribble.conversation.model.*;
+
+/**
+ * This class provides the model parser for the Conversation notation.
+ * 
+ */
+ at RegistryInfo(extension=ParserRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class ConversationModelParserRule extends org.scribble.parser.AbstractModelParserRule {
+
+	/**
+	 * This method creates the initial empty model.
+	 * 
+	 * @return The model
+	 */
+	protected Model createModel() {
+		return(new ConversationModel());
+	}
+
+	/**
+	 * This method determines whether the keyword is associated
+	 * with the model.
+	 * 
+	 * @param keyword The model keyword
+	 * @return Whether the keyword is associated with the definition
+	 */
+	protected boolean isDefinitionKeyword(String keyword) {
+		return(ConversationParserRule.CONVERSATION_KEYWORD.equals(keyword) ||
+				ConversationParserRule.STATELESS_KEYWORD.equals(keyword));
+	}
+	
+	/**
+	 * This method parsers the model header items.
+	 * 
+	 * @param context The context
+	 * @param l The model listener
+	 * @param model The model
+	 * @return The item has been parsed
+	 */
+	@Override
+	protected boolean parseModelHeaderItem(ParserContext context,
+					ModelListener l, Model model) {
+		boolean ret=super.parseModelHeaderItem(context, l, model);
+		
+		if (ret == false) {
+			Token t = context.lookahead(0);
+			
+			if (t.isToken("identify", TokenType.Keyword)) {
+				ret = true;					
+
+				IdentityLocator locator=(IdentityLocator)context.parse(IdentityLocator.class, l);
+			
+				if (locator != null) {
+					((ConversationModel)model).getIdentityLocators().add(locator);
+				}
+			}
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method parsers the model body.
+	 * 
+	 * @param context The context
+	 * @param l The model listener
+	 * @param model The model
+	 */
+	@Override
+	protected void parseModelBody(ParserContext context,
+			ModelListener l, Model model) {
+		Conversation conversation=(Conversation)context.parse(Conversation.class, l);
+		
+		((ConversationModel)model).setConversation(conversation);
+	}
+
+}

Added: trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/ConversationParserRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/ConversationParserRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/ConversationParserRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,388 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 9 Jan 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.parser;
+
+import org.scribble.extensions.*;
+import org.scribble.conversation.model.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.parser.*;
+
+/**
+ * This class provides the parser rule for the Conversation
+ * definition.
+ */
+ at RegistryInfo(extension=ParserRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class ConversationParserRule extends org.scribble.parser.AbstractParserRule {
+
+	public static final String IDENTIFIED_KEYWORD = "identified";
+	public static final String BY_KEYWORD = "by";
+	public static final String TO_KEYWORD = "to";
+	public static final String CONFORMS_KEYWORD = "conforms";
+	public static final String IMPLEMENTS_KEYWORD = "implements";
+	public static final String CONVERSATION_KEYWORD = "conversation";
+	public static final String STATELESS_KEYWORD = "stateless";
+
+	/**
+	 * The default constructor.
+	 */
+	public ConversationParserRule() {
+		super(ParserRuleType.Group);
+	}
+	
+	/**
+	 * This method determines whether the parser rules is
+	 * appropriate to return a model object of the required
+	 * type.
+	 * 
+	 * @param type The required type
+	 * @return Whether the parser rule returns a
+	 * 				model object of the required type
+	 */
+	public boolean isSupported(Class<?> type) {
+		return(type.isAssignableFrom(Conversation.class));
+	}
+
+	/**
+	 * This method parses the description to obtain
+	 * a model object of the appropriate type.
+	 * 
+	 * @param context The context
+	 * @param l The listener
+	 * @return The model object
+	 */
+	public Object parse(ParserContext context, ModelListener l) {
+		Conversation ret=null;
+		boolean stateless=false;
+		int startPos=-1;
+		
+		Token t=context.nextToken();
+		
+		if (t.isToken(STATELESS_KEYWORD, TokenType.Keyword)) {
+			stateless = true;
+			
+			startPos = t.getSource().getStartPosition();
+			
+			t = context.nextToken();
+		}
+		
+		if (t.isToken(CONVERSATION_KEYWORD, TokenType.Keyword)) {
+			
+			ret = new Conversation();
+			
+			if (startPos == -1) {
+				startPos = t.getSource().getStartPosition();
+			}
+			
+			ret.getSource().setStartPosition(startPos);
+			ret.setStateless(stateless);
+			
+			LocatedName name=(LocatedName)context.parse(LocatedName.class, l);
+			
+			if (name != null) {
+				ret.setLocatedName(name);
+				
+				// Check if name has already been defined in state
+				if (context.getState(t.getText()) != null) {
+					l.error(new ModelIssue(t,
+							org.scribble.util.MessageUtil.format(
+									java.util.PropertyResourceBundle.getBundle(
+											"org.scribble.parser.Messages"),
+									"_DUPLICATE_DECLARATION",
+									new String[]{t.getText()})));
+				} else {
+					context.setState(t.getText(), ret);
+				}
+				
+				// Check if conforms specified
+				boolean f_processed=false;
+				
+				do {
+					f_processed = parseDefinitionConstruct(context, l,
+									ret);
+					
+					/*
+					t = context.lookahead(0);
+					
+					if (t.isToken(CONFORMS_KEYWORD, TokenType.Keyword)) {
+						f_processed = true;
+
+						t = context.lookahead(1);
+						
+						if (t.isToken(TO_KEYWORD, TokenType.Keyword)) {
+							context.nextToken();							
+						}
+						
+						do {
+							// Consume keyword
+							context.nextToken();
+							
+							ConformanceReference ref=(ConformanceReference)
+									context.parse(ConformanceReference.class, l);
+							
+							if (ref != null) {
+								resolveReference(context, l, ref, DependencyType.ConformsTo);
+								
+								ret.getConformsTo().add(ref);
+							}
+							
+							t = context.lookahead(0);
+						} while (t.isToken(",", TokenType.Symbol));
+						
+					} else if (t.isToken(IMPLEMENTS_KEYWORD, TokenType.Keyword)) {
+						f_processed = true;
+
+						do {
+							// Consume keyword
+							context.nextToken();
+							
+							ImplementsReference ref=(ImplementsReference)
+									context.parse(ImplementsReference.class, l);
+							
+							if (ref != null) {
+								resolveReference(context, l, ref, DependencyType.Implements);
+
+								ret.getImplements().add(ref);
+							}
+							
+							t = context.lookahead(0);
+						} while (t.isToken(",", TokenType.Symbol));
+
+					}
+					*/
+				} while (f_processed);
+				
+				// Need to create new scope for protocol
+				context.pushScope();
+					
+				if (name.getRole() != null) {
+					context.setState(name.getRole().getName(),
+									name.getRole());
+					
+					context.setLocatedRole(t.getText());
+					
+					/* 27/11/07
+					 * 'Conformance' dependency should be from global
+					 * model to local, not the other way around. If 
+					 * local model is changed, global will be revalidated
+					 * but if global changed, then local should not be.
+					 * 
+					if (context.isOuterScope()) {
+						// Establish dependency on the global model
+						org.scribble.model.DependencyManager dm=
+							(org.scribble.model.DependencyManager)
+							org.scribble.extensions.RegistryFactory.getRegistry().getExtension(
+									org.scribble.model.DependencyManager.class, null);
+						
+						org.scribble.model.ModelRepository mrep=
+							(org.scribble.model.ModelRepository)
+							RegistryFactory.getRegistry().getExtension(
+									org.scribble.model.ModelRepository.class, null);
+
+						if (dm != null && mrep != null) {
+							ModelReference ref=
+								new ModelReference(context.getSource().getNamespace(),
+									context.getSource().getLocalpart(), null,
+									context.getSource().getNotation());
+							
+							mrep.locate(ref, context.getSource());
+							
+							dm.recordDependency(context.getSource(), ref,
+										DependencyType.ConformsTo);
+						}
+					}
+					*/
+				}
+								
+				// Check that the conversation name/located role matches
+				// the source model reference, but only if the source
+				// model has a localpart - otherwise it may not have an
+				// associated file
+				if (context.isOuterScope() && context.getSource().getLocalpart() != null &&
+					(context.getSource().getLocalpart().equals(ret.getLocatedName().getName()) == false ||
+					(context.getSource().getLocatedRole() == null &&
+						ret.getLocatedName().getRole() != null) ||
+					(context.getSource().getLocatedRole() != null &&
+						ret.getLocatedName().getRole() == null) ||
+					(ret.getLocatedName().getRole() != null &&
+						context.getSource().getLocatedRole() != null &&
+						ret.getLocatedName().getRole().getName().equals(
+								context.getSource().getLocatedRole()) == false))) {
+					
+					l.error(new ModelIssue(ret.getLocatedName(), java.util.PropertyResourceBundle.getBundle(
+							"org.scribble.parser.Messages").
+								getString("_INCOMPATIBLE_NAME")));
+				}
+	
+				// Process group
+				parseGroup(context, l, ret.getBlock(), false);
+				
+				// Check unresolved references
+				
+				// TODO: In the ConversationModel, might want to
+				// check if any unresolved references still exist
+				// and report them - not sure if this is being done
+				// somewhere
+				
+				for (int i=0; i < context.getUnresolvedReferences().size(); i++) {
+					
+					if (context.getUnresolvedReferences().get(i) instanceof
+									ConversationReference) {
+						ConversationReference ref=
+							(ConversationReference)
+							context.getUnresolvedReferences().get(i);
+					
+						// Check contained protocol activities
+						for (int j=0; ref.getAlias() != null &&
+									ref.isResolved() == false &&
+									j < ret.getBlock().getContents().size(); j++) {
+							
+							if (ret.getBlock().getContents().get(j) instanceof Conversation) {
+								Conversation conversation=(Conversation)ret.getBlock().getContents().get(j);
+								
+								if (conversation.getLocatedName() != null &&
+									conversation.getLocatedName().getName() != null &&
+									ref.getAlias().equals(
+											conversation.getLocatedName().getName()) &&
+									((ref.getLocatedRole() == null &&
+										conversation.getLocatedName().getRole() == null) ||
+									((ref.getLocatedRole() != null &&
+										conversation.getLocatedName().getRole() != null &&
+										ref.getLocatedRole().equals(
+										conversation.getLocatedName().getRole().getName()))))) {
+										
+									ref.setLocalpart(ref.getAlias());
+									
+									ref.setInner(true);
+									
+									// Remove from unresolved list
+									context.getUnresolvedReferences().remove(i);
+									
+									i--;
+								}
+							}
+						}
+					}
+				}
+				
+				context.popScope();
+				
+				ret.getSource().setEndPosition(name.getSource().getEndPosition());
+			}
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method parses a definition construct.
+	 * 
+	 * @param context The context
+	 * @param l The model listener
+	 * @param conversation The conversation
+	 * @return Whether the construct was parsed
+	 */
+	protected boolean parseDefinitionConstruct(ParserContext context,
+				ModelListener l, Conversation conversation) {
+		boolean ret=false;
+		
+		Token t = context.lookahead(0);
+		
+		if (t.isToken(CONFORMS_KEYWORD, TokenType.Keyword)) {
+			ret = true;
+
+			t = context.lookahead(1);
+			
+			if (t.isToken(TO_KEYWORD, TokenType.Keyword)) {
+				context.nextToken();							
+			}
+			
+			do {
+				// Consume keyword
+				context.nextToken();
+				
+				ConformanceReference ref=(ConformanceReference)
+						context.parse(ConformanceReference.class, l);
+				
+				if (ref != null) {
+					// GPB: TO REMOVE resolveReference(context, l, ref, DependencyType.ConformsTo);
+					
+					conversation.getConformsTo().add(ref);
+				}
+				
+				t = context.lookahead(0);
+			} while (t.isToken(",", TokenType.Symbol));
+			
+		} else if (t.isToken(IMPLEMENTS_KEYWORD, TokenType.Keyword)) {
+			ret = true;
+
+			do {
+				// Consume keyword
+				context.nextToken();
+				
+				ImplementsReference ref=(ImplementsReference)
+						context.parse(ImplementsReference.class, l);
+				
+				if (ref != null) {
+					// GPB: TO REMOVE resolveReference(context, l, ref, DependencyType.Implements);
+
+					conversation.getImplements().add(ref);
+				}
+				
+				t = context.lookahead(0);
+			} while (t.isToken(",", TokenType.Symbol));
+
+		} else if (t.isToken(IDENTIFIED_KEYWORD, TokenType.Keyword)) {
+			ret = true;
+
+			t = context.lookahead(1);
+			
+			if (t.isToken(BY_KEYWORD, TokenType.Keyword)) {
+				context.nextToken();							
+			}
+			
+			do {
+				// Consume keyword
+				context.nextToken();
+				
+				t = context.lookahead(0);
+				
+				if (t.getType() == TokenType.Identifier) {
+					context.nextToken();
+					
+					Identity id=new Identity();
+					id.getNames().add(t.getText());
+					
+					conversation.getIdentities().add(id);
+				} else {
+					l.error(new ModelIssue(t, java.util.PropertyResourceBundle.getBundle(
+							"org.scribble.parser.Messages").
+						getString("_EXPECTING_IDENTIFIER")));
+				}
+				
+				t = context.lookahead(0);
+				
+			} while (t.isToken(",", TokenType.Symbol));
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/ConversationReferenceParserRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/ConversationReferenceParserRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/ConversationReferenceParserRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 9 Jan 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.parser;
+
+import org.scribble.extensions.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.conversation.model.*;
+import org.scribble.parser.*;
+
+/**
+ * This class provides the parser rule for the Conversation Reference.
+ */
+ at RegistryInfo(extension=ParserRule.class)
+public class ConversationReferenceParserRule extends AbstractModelReferenceParserRule {
+
+	/**
+	 * The default constructor.
+	 */
+	public ConversationReferenceParserRule() {
+		super(true);
+	}
+	
+	/**
+	 * This method returns the class associated with the
+	 * concrete model reference.
+	 * 
+	 * @return The model reference class
+	 */
+	protected Class<?> getReferenceClass() {
+		return(ConversationReference.class);
+	}
+
+	/**
+	 * This method instantiates an instance of the model
+	 * reference.
+	 * 
+	 * @param context The parser context
+	 * @param l The model listener
+	 * @return The instantiated model reference
+	 */
+	protected ModelReference createReference(ParserContext context, ModelListener l) {
+		return(new ConversationReference());
+	}
+
+	/**
+	 * This method parses the description to obtain
+	 * a model object of the appropriate type.
+	 * 
+	 * @param context The context
+	 * @param l The listener
+	 * @return The model object
+	 */
+	public Object parse(ParserContext context, ModelListener l) {
+		Object ret=super.parse(context, l);
+		
+		// Check if reference has been resolved
+		if (ret instanceof ConversationReference &&
+				((ConversationReference)ret).isResolved() == false) {
+			
+			// Add to unresolved reference list for current scope
+			context.getUnresolvedReferences().add(
+						(ConversationReference)ret);
+		}
+		
+		return(ret);
+	}	
+}

Added: trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/IdentityLocatorParserRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/IdentityLocatorParserRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/IdentityLocatorParserRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,194 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 27 July 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.parser;
+
+import org.scribble.extensions.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.conversation.model.*;
+import org.scribble.parser.*;
+
+/**
+ * This class provides the parser rule for the Identify statement.
+ */
+ at RegistryInfo(extension=ParserRule.class)
+public class IdentityLocatorParserRule extends AbstractParserRule {
+
+	/**
+	 * This is the default constructor.
+	 */
+	public IdentityLocatorParserRule() {
+		super(ParserRuleType.Line);
+	}
+	
+	/**
+	 * This method determines whether the parser rules is
+	 * appropriate to return a model object of the required
+	 * type.
+	 * 
+	 * @param type The required type
+	 * @return Whether the parser rule returns a
+	 * 				model object of the required type
+	 */
+	public boolean isSupported(Class<?> type) {
+		return(type.isAssignableFrom(IdentityLocator.class));
+	}
+
+	/**
+	 * This method parses the description to obtain
+	 * a model object of the appropriate type.
+	 * 
+	 * @param context The context
+	 * @param l The listener
+	 * @return The model object
+	 */
+	public Object parse(ParserContext context, ModelListener l) {
+		IdentityLocator ret=null;
+		
+		Token t=context.lookahead(0);
+		
+		if (t.isToken("identify", TokenType.Keyword)) {
+			ret = new IdentityLocator();
+			
+			ret.getSource().setStartPosition(t.getSource().getStartPosition());
+			
+			// Consume token
+			context.nextToken();
+			
+			ret.setType((TypeReference)
+						context.parse(TypeReference.class, l));
+			
+			t = context.lookahead(0);
+			
+			if (t.isToken("with", TokenType.Keyword)) {
+				
+				context.nextToken();
+				
+				do {
+					t = context.lookahead(0);
+					
+					if (ret.getNumberOfLocators() > 0 &&
+							t.isToken(",", TokenType.Symbol)) {
+						context.nextToken();
+						
+						t = context.lookahead(0);
+					}
+					
+					if (t.getType() == TokenType.Identifier) {
+						String identity=t.getText();
+						
+						context.nextToken();
+						
+						t = context.lookahead(0);
+						
+						if (t.isToken("using", TokenType.Keyword)) {
+							
+							context.nextToken();
+							
+							t = context.lookahead(0);
+							
+							// Get string literal
+							if (t.getType() == TokenType.StringLiteral) {
+								ret.setLocator(identity, t.getText());
+							}
+						} else {
+							// TODO: Expecting keyword
+						}
+					} else {
+						l.error(new ModelIssue(t, java.util.PropertyResourceBundle.getBundle(
+								"org.scribble.parser.Messages").
+							getString("_EXPECTING_IDENTIFIER")));
+					}
+					
+				} while (t.isToken(",", TokenType.Symbol));
+			} else {
+				// TODO: Expecting keyword
+			}
+			
+			/*
+			t = context.lookahead(0);
+			
+			String fqname="";
+			boolean f_end=false;
+			
+			do {
+				if (t.getType() == TokenType.Identifier) {
+					Token id=context.nextToken();
+					fqname += id.getText();
+				
+					t = context.lookahead(0);
+				
+					if (t.isToken(".", TokenType.Symbol)) {
+					
+						context.nextToken();
+						
+						fqname += ".";
+					
+						t = context.lookahead(0);
+					} else {
+						f_end = true;
+					}
+				} else if (t.isToken("*", TokenType.Symbol)) {
+					
+					context.nextToken();
+					
+					fqname += "*";
+					
+					f_end = true;
+				} else {
+					
+					l.error(t, java.util.PropertyResourceBundle.getBundle(
+							"org.scribble.parser.Messages").
+								getString("_EXPECTING_IDENTIFIER"), null);
+					
+					f_end = true;
+				}
+			} while (f_end == false);
+			
+			if (fqname.length() > 0) {
+				ret.setName(fqname);
+			}
+			
+			if (t.isToken("as", TokenType.Keyword)) {
+				context.nextToken();
+				
+				t = context.lookahead(0);
+				
+				if (t.getType() == TokenType.Identifier) {
+					
+					context.nextToken();
+					
+					ret.setAlias(t.getText());
+				} else {
+					l.error(t, java.util.PropertyResourceBundle.getBundle(
+							"org.scribble.parser.Messages").
+							getString("_EXPECTING_IDENTIFIER"), null);
+				}
+			}
+			*/
+			
+			ret.getSource().setEndPosition(t.getSource().getEndPosition());
+		}
+		
+		return(ret);
+	}
+	
+}

Added: trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/IfParserRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/IfParserRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/IfParserRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,223 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 1 Feb 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.parser;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.parser.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class provides the parser rule for the If construct.
+ * 
+ */
+ at RegistryInfo(extension=ParserRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class IfParserRule extends org.scribble.parser.AbstractParserRule {
+
+	/**
+	 * The default constructor.
+	 */
+	public IfParserRule() {
+		super(ParserRuleType.Group);
+	}
+	
+	/**
+	 * This method determines whether the parser rules is
+	 * appropriate to return a model object of the required
+	 * type.
+	 * 
+	 * @param type The required type
+	 * @return Whether the parser rule returns a
+	 * 				model object of the required type
+	 */
+	public boolean isSupported(Class<?> type) {
+		return(type.isAssignableFrom(If.class));
+	}
+
+	/**
+	 * This method parses the description to obtain
+	 * a model object of the appropriate type.
+	 * 
+	 * @param context The context
+	 * @param l The listener
+	 * @return The model object
+	 */
+	public Object parse(ParserContext context, ModelListener l) {
+		If ret=null;
+		
+		Token t=context.lookahead(0);
+		
+		if (t.isToken("if", TokenType.Keyword)) {
+			int startpos=t.getSource().getStartPosition();
+
+			// Consume token
+			context.nextToken();
+			
+			ret = new If();
+				
+			ret.getSource().setStartPosition(startpos);
+			
+			// Check for located roles
+			t = context.lookahead(0);
+			
+			if (t.isToken(ModelReference.LOCATED_REFERENCE_SEPARATOR,
+								TokenType.Symbol)) {
+				boolean f_error=false;
+				
+				// Work through list of roles
+				do {
+					// Consume token
+					context.nextToken();
+					
+					// Read next token, which should be an identifier
+					t = context.lookahead(0);
+				
+					if (t.getType() == TokenType.Identifier) {
+						
+						// Consume token
+						context.nextToken();
+					
+						// Locate the role definition
+						Object part=context.getState(t.getText());
+						
+						if (part == null) {
+							l.error(new ModelIssue(t,
+								org.scribble.util.MessageUtil.format(
+										java.util.PropertyResourceBundle.getBundle(
+												"org.scribble.parser.Messages"),
+										"_UNKNOWN_ROLE",
+										new String[]{t.getText()})));
+						} else if (part instanceof Role) {
+							ret.getRoles().add((Role)part);
+						} else {
+							l.error(new ModelIssue(t,
+								org.scribble.util.MessageUtil.format(
+										java.util.PropertyResourceBundle.getBundle(
+												"org.scribble.parser.Messages"),
+										"_REQUIRED_ROLE",
+										new String[]{t.getText()})));
+						}
+						
+						t = context.lookahead(0);
+					} else {
+						l.error(new ModelIssue(t, java.util.PropertyResourceBundle.getBundle(
+							"org.scribble.parser.Messages").
+							getString("_EXPECTING_ROLE_NAME")));
+						f_error = true;
+					}
+				} while (f_error == false &&
+						t.isToken(ParserConstants.LIST_SEPARATOR,
+								TokenType.Symbol));				
+			}
+			
+			boolean f_end=false;
+			boolean f_conditional=true;
+			
+			do {
+				f_end = true;
+				
+				Block block=null;
+				
+				if (f_conditional) {
+					ConditionalBlock cblock = new ConditionalBlock();
+					ret.getConditionalBlocks().add(cblock);
+					
+					block = cblock;
+					
+					block.getSource().setStartPosition(t.getSource().getStartPosition());
+
+					t = context.lookahead(0);
+
+					if (t.isToken("(", TokenType.Symbol)) {
+						// Consume symbol
+						context.nextToken();
+						
+						cblock.setExpression((Expression)
+								context.parse(Expression.class, l));
+						
+						// Check if end of expression symbol specified
+						t = context.lookahead(0);
+						
+						if (t.isToken(")", TokenType.Symbol)) {
+							context.nextToken();
+						} else {
+							
+							// Report 'expecting )' message
+							l.error(new ModelIssue(t, org.scribble.util.MessageUtil.format(
+									java.util.PropertyResourceBundle.getBundle(
+											"org.scribble.parser.Messages"),
+											"_EXPECTING_SYMBOL",
+											new String[]{")"})));
+						}
+					}
+				} else {
+					block = new Block();
+					ret.setElseBlock(block);
+					
+					//block.getSource().setStartPosition(t.getSource().getStartPosition());
+				}
+
+				// Parse group
+				parseGroup(context, l, block, true);
+				
+				// Parsing the group does not consume the final curly
+				// bracket, to ensure that other rules know that the
+				// block has completed, so need to look past this token
+				t = context.lookahead(0);
+				
+				//block.getSource().setEndPosition(t.getSource().getStartPosition());
+
+				ret.getSource().setEndPosition(t.getSource().getStartPosition());
+
+				if (t.isToken("else", TokenType.Keyword)) {
+					
+					if (f_conditional == false) {
+						l.error(new ModelIssue(t, java.util.PropertyResourceBundle.getBundle(
+								"org.scribble.conversation.parser.Messages").
+								getString("_INVALID_ELSE")));
+					} else {
+						f_end = false;
+
+						// Consume 'else'
+						context.nextToken();
+						
+						t = context.lookahead(0);
+						
+						if (t.isToken("if", TokenType.Keyword)) {
+							
+							context.nextToken();
+							
+						} else {							
+							f_conditional = false;
+						}
+					}
+				}
+				
+			} while (f_end == false);
+			
+			t = context.lookahead(-1);
+			ret.getSource().setEndPosition(t.getSource().getEndPosition());
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/InterruptBlockParserRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/InterruptBlockParserRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/InterruptBlockParserRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,170 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 18 Oct 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.parser;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.parser.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class provides the parser rule for the CatchBlock construct.
+ * 
+ */
+ at RegistryInfo(extension=ParserRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class InterruptBlockParserRule extends org.scribble.parser.AbstractParserRule {
+
+	/**
+	 * The default constructor.
+	 */
+	public InterruptBlockParserRule() {
+		super(ParserRuleType.Group);
+	}
+	
+	/**
+	 * This method determines whether the parser rules is
+	 * appropriate to return a model object of the required
+	 * type.
+	 * 
+	 * @param type The required type
+	 * @return Whether the parser rule returns a
+	 * 				model object of the required type
+	 */
+	public boolean isSupported(Class<?> type) {
+		return(type.isAssignableFrom(InterruptBlock.class));
+	}
+
+	/**
+	 * This method parses the description to obtain
+	 * a model object of the appropriate type.
+	 * 
+	 * @param context The context
+	 * @param l The listener
+	 * @return The model object
+	 */
+	public Object parse(ParserContext context, ModelListener l) {
+		InterruptBlock ret=null;
+		
+		Token t=context.lookahead(0);
+		
+		if (t.isToken("interrupt", TokenType.Keyword)) {
+			int startpos=t.getSource().getStartPosition();
+			
+			// Consume token
+			context.nextToken();
+			
+			ret = new InterruptBlock();
+			
+			ret.getSource().setStartPosition(startpos);
+			
+			// Check for located roles
+			t = context.lookahead(0);
+			
+			if (t.isToken(ModelReference.LOCATED_REFERENCE_SEPARATOR,
+								TokenType.Symbol)) {
+				boolean f_error=false;
+				
+				// Work through list of roles
+				do {
+					// Consume token
+					context.nextToken();
+					
+					// Read next token, which should be an identifier
+					t = context.lookahead(0);
+				
+					if (t.getType() == TokenType.Identifier) {
+						
+						// Consume token
+						context.nextToken();
+					
+						// Locate the role definition
+						Object part=context.getState(t.getText());
+						
+						if (part == null) {
+							l.error(new ModelIssue(t,
+								org.scribble.util.MessageUtil.format(
+										java.util.PropertyResourceBundle.getBundle(
+												"org.scribble.parser.Messages"),
+										"_UNKNOWN_ROLE",
+										new String[]{t.getText()})));
+						} else if (part instanceof Role) {
+							ret.getRoles().add((Role)part);
+						} else {
+							l.error(new ModelIssue(t,
+								org.scribble.util.MessageUtil.format(
+										java.util.PropertyResourceBundle.getBundle(
+												"org.scribble.parser.Messages"),
+										"_REQUIRED_ROLE",
+										new String[]{t.getText()})));
+						}
+						
+						t = context.lookahead(0);
+					} else {
+						l.error(new ModelIssue(t, java.util.PropertyResourceBundle.getBundle(
+							"org.scribble.parser.Messages").
+							getString("_EXPECTING_ROLE_NAME")));
+						f_error = true;
+					}
+				} while (f_error == false &&
+						t.isToken(ParserConstants.LIST_SEPARATOR,
+								TokenType.Symbol));				
+			}
+
+			t = context.lookahead(0);
+
+			if (t.isToken("(", TokenType.Symbol)) {
+				// Consume symbol
+				context.nextToken();
+				
+				ret.setExpression((Expression)
+						context.parse(Expression.class, l));
+				
+				// Check if end of expression symbol specified
+				t = context.lookahead(0);
+				
+				if (t.isToken(")", TokenType.Symbol)) {
+					context.nextToken();
+				} else {
+					
+					// Report 'expecting )' message
+					l.error(new ModelIssue(t, org.scribble.util.MessageUtil.format(
+							java.util.PropertyResourceBundle.getBundle(
+									"org.scribble.parser.Messages"),
+									"_EXPECTING_SYMBOL",
+									new String[]{")"})));
+				}
+			}
+
+			// Parse group
+			parseGroup(context, l, ret, true);
+			
+			// Parsing the group does not consume the final curly
+			// bracket, to ensure that other rules know that the
+			// block has completed, so need to look past this token
+			t = context.lookahead(0);
+			
+			ret.getSource().setEndPosition(t.getSource().getStartPosition());
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/Messages.properties
===================================================================
--- trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/Messages.properties	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/Messages.properties	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,26 @@
+# /*
+# * Copyright 2007-8 Pi4 Technologies Ltd
+# *
+# * 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.
+# *
+# *
+# * Change History:
+# * 10 Jan 2008 : Initial version created by gary
+# */
+
+_EXPECTING_VARIABLE_NAME=Expecting variable name
+_INVALID_ELSE=Not expecting an additional 'else' statement
+_REQUIRED_VARIABLE=Must specify a variable '{0}'
+_REQUIRED_VARIABLE_OR_ROLE=Must specify a variable or role '{0}'
+_UNKNOWN_VARIABLE=Unknown variable '{0}'
+_UNKNOWN_VARIABLE_OR_ROLE=Unknown variable or role '{0}'

Added: trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/ParallelParserRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/ParallelParserRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/ParallelParserRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 8 Mar 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.parser;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.parser.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class provides the parser rule for the Parallel construct.
+ * 
+ */
+ at RegistryInfo(extension=ParserRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class ParallelParserRule extends org.scribble.parser.AbstractParserRule {
+
+	/**
+	 * The default constructor.
+	 */
+	public ParallelParserRule() {
+		super(ParserRuleType.Group);
+	}
+	
+	/**
+	 * This method determines whether the parser rules is
+	 * appropriate to return a model object of the required
+	 * type.
+	 * 
+	 * @param type The required type
+	 * @return Whether the parser rule returns a
+	 * 				model object of the required type
+	 */
+	public boolean isSupported(Class<?> type) {
+		return(type.isAssignableFrom(Parallel.class));
+	}
+
+	/**
+	 * This method parses the description to obtain
+	 * a model object of the appropriate type.
+	 * 
+	 * @param context The context
+	 * @param l The listener
+	 * @return The model object
+	 */
+	public Object parse(ParserContext context, ModelListener l) {
+		Parallel ret=null;
+		
+		Token t=context.lookahead(0);
+		
+		if (t.isToken("parallel", TokenType.Keyword)) {
+			int startpos=t.getSource().getStartPosition();
+
+			// Consume token
+			context.nextToken();
+			
+			ret = new Parallel();
+				
+			ret.getSource().setStartPosition(startpos);
+			
+			// Check for located roles
+			t = context.lookahead(0);
+			
+			boolean f_end=false;
+			
+			do {
+				f_end = true;
+				
+				Block block=new Block();
+				
+				ret.getBlocks().add(block);
+
+				block.getSource().setStartPosition(t.getSource().getStartPosition());
+
+				// Parse group
+				parseGroup(context, l, block, true);
+				
+				t = context.lookahead(0);
+				
+				block.getSource().setEndPosition(t.getSource().getStartPosition());
+
+				if (t.isToken("and", TokenType.Keyword)) {
+					f_end = false;
+					
+					// Consume 'and'
+					context.nextToken();
+				}
+				
+			} while (f_end == false);
+			
+			t = context.lookahead(-1);
+			ret.getSource().setEndPosition(t.getSource().getEndPosition());
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/RaiseParserRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/RaiseParserRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/RaiseParserRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,147 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 10 Nov 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.parser;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.parser.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class provides the parser rule for the Raise construct.
+ * 
+ */
+ at RegistryInfo(extension=ParserRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class RaiseParserRule extends org.scribble.parser.AbstractParserRule {
+
+	/**
+	 * The default constructor.
+	 */
+	public RaiseParserRule() {
+		super(ParserRuleType.Line);
+	}
+	
+	/**
+	 * This method determines whether the parser rules is
+	 * appropriate to return a model object of the required
+	 * type.
+	 * 
+	 * @param type The required type
+	 * @return Whether the parser rule returns a
+	 * 				model object of the required type
+	 */
+	public boolean isSupported(Class<?> type) {
+		return(type.isAssignableFrom(Raise.class));
+	}
+
+	/**
+	 * This method parses the description to obtain
+	 * a model object of the appropriate type.
+	 * 
+	 * @param context The context
+	 * @param l The listener
+	 * @return The model object
+	 */
+	public Object parse(ParserContext context, ModelListener l) {
+		Raise ret=null;
+		
+		Token t=context.lookahead(0);
+		
+		if (t.isToken("raise", TokenType.Keyword)) {
+			int startpos=t.getSource().getStartPosition();
+			
+			// Consume token
+			context.nextToken();
+			
+			ret = new Raise();
+			
+			ret.getSource().setStartPosition(startpos);
+			
+			// Check for located roles
+			t = context.lookahead(0);
+			
+			if (t.isToken(ModelReference.LOCATED_REFERENCE_SEPARATOR,
+								TokenType.Symbol)) {
+				boolean f_error=false;
+				
+				// Work through list of roles
+				do {
+					// Consume token
+					context.nextToken();
+					
+					// Read next token, which should be an identifier
+					t = context.lookahead(0);
+				
+					if (t.getType() == TokenType.Identifier) {
+						
+						// Consume token
+						context.nextToken();
+					
+						// Locate the role definition
+						Object part=context.getState(t.getText());
+						
+						if (part == null) {
+							l.error(new ModelIssue(t,
+								org.scribble.util.MessageUtil.format(
+										java.util.PropertyResourceBundle.getBundle(
+												"org.scribble.parser.Messages"),
+										"_UNKNOWN_ROLE",
+										new String[]{t.getText()})));
+						} else if (part instanceof Role) {
+							ret.getRoles().add((Role)part);
+						} else {
+							l.error(new ModelIssue(t,
+								org.scribble.util.MessageUtil.format(
+										java.util.PropertyResourceBundle.getBundle(
+												"org.scribble.parser.Messages"),
+										"_REQUIRED_ROLE",
+										new String[]{t.getText()})));
+						}
+						
+						t = context.lookahead(0);
+					} else {
+						l.error(new ModelIssue(t, java.util.PropertyResourceBundle.getBundle(
+							"org.scribble.parser.Messages").
+							getString("_EXPECTING_ROLE_NAME")));
+						f_error = true;
+					}
+				} while (f_error == false &&
+						t.isToken(ParserConstants.LIST_SEPARATOR,
+								TokenType.Symbol));				
+			}
+
+			// Get the type reference
+			TypeReference typeRef=(TypeReference)
+						context.parse(TypeReference.class, l);
+			
+			// GPB: TO REMOVE resolveReference(context, l, typeRef, DependencyType.Uses);
+			
+			ret.setType(typeRef);
+			
+			t = context.lookahead(0);
+			
+			ret.getSource().setEndPosition(t.getSource().getEndPosition());
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/RunConversationParserRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/RunConversationParserRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/RunConversationParserRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,232 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 9 Mar 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.parser;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.parser.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class provides the parser rule for the Run construct.
+ * 
+ */
+ at RegistryInfo(extension=ParserRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class RunConversationParserRule extends org.scribble.parser.AbstractParserRule {
+
+	/**
+	 * The default constructor.
+	 */
+	public RunConversationParserRule() {
+		super(ParserRuleType.Group);
+	}
+	
+	/**
+	 * This method determines whether the parser rules is
+	 * appropriate to return a model object of the required
+	 * type.
+	 * 
+	 * @param type The required type
+	 * @return Whether the parser rule returns a
+	 * 				model object of the required type
+	 */
+	public boolean isSupported(Class<?> type) {
+		return(type.isAssignableFrom(Run.class));
+	}
+
+	/**
+	 * This method parses the description to obtain
+	 * a model object of the appropriate type.
+	 * 
+	 * @param context The context
+	 * @param l The listener
+	 * @return The model object
+	 */
+	public Object parse(ParserContext context, ModelListener l) {
+		Run ret=null;
+		
+		Token t=context.lookahead(0);
+		
+		if (t.isToken("run", TokenType.Keyword)) {
+			int startpos=t.getSource().getStartPosition();
+			
+			t = context.lookahead(1);
+			
+			// Need to locate a 'conversation' keyword
+			if (t.isToken("conversation", TokenType.Keyword)) {
+				String located=null;
+				
+				// Consume tokens
+				context.nextToken();
+				context.nextToken();
+				
+				ret = new Run();
+				
+				ret.getSource().setStartPosition(startpos);
+				ret.getSource().setEndPosition(t.getSource().getEndPosition());
+			
+				// Check for role bindings
+				t = context.lookahead(0);
+				
+				if (t.isToken(ModelReference.LOCATED_REFERENCE_SEPARATOR,
+									TokenType.Symbol)) {
+					context.nextToken();
+					
+					t = context.lookahead(0);
+					
+					if (t.getType() == TokenType.Identifier) {
+						context.nextToken();
+
+						located = t.getText();
+						
+						t = context.lookahead(0);
+						
+					} else {
+						l.error(new ModelIssue(t, java.util.PropertyResourceBundle.getBundle(
+							"org.scribble.parser.Messages").
+							getString("_EXPECTING_ROLE_NAME")));
+					}
+				}
+			
+				if (t.isToken("(", TokenType.Symbol)) {
+					boolean f_error=false;
+					
+					do {
+						// Consume token
+						context.nextToken();
+						
+						// Read next token, which should be an identifier
+						t = context.lookahead(0);
+					
+						if (t.getType() == TokenType.Identifier) {
+							Role role=null;
+							String binding=null;
+							int dbstartpos=t.getSource().getStartPosition();
+							
+							// Consume token
+							context.nextToken();
+						
+							// Locate the role definition
+							Object part=context.getState(t.getText());
+							
+							if (part == null) {
+								l.error(new ModelIssue(t,
+									org.scribble.util.MessageUtil.format(
+											java.util.PropertyResourceBundle.getBundle(
+													"org.scribble.parser.Messages"),
+											"_UNKNOWN_ROLE",
+											new String[]{t.getText()})));
+							} else if (part instanceof Role) {
+								role = (Role)part;
+							} else {
+								l.error(new ModelIssue(t,
+									org.scribble.util.MessageUtil.format(
+											java.util.PropertyResourceBundle.getBundle(
+													"org.scribble.parser.Messages"),
+											"_REQUIRED_ROLE",
+											new String[]{t.getText()})));
+							}
+							
+							t = context.lookahead(0);
+							
+							if (t.isToken("for", TokenType.Keyword)) {
+								
+								context.nextToken();
+								
+								t = context.lookahead(0);
+								
+								if (t.getType() == TokenType.Identifier) {
+									
+									context.nextToken();
+									
+									binding = t.getText();
+								} else {
+									l.error(new ModelIssue(t, java.util.PropertyResourceBundle.getBundle(
+											"org.scribble.parser.Messages").
+												getString("_EXPECTING_IDENTIFIER")));
+									f_error = true;
+								}
+							} else {
+								l.error(new ModelIssue(t,
+										org.scribble.util.MessageUtil.format(
+												java.util.PropertyResourceBundle.getBundle(
+														"org.scribble.parser.Messages"),
+												"_EXPECTING_KEYWORD",
+												new String[]{"for"})));
+								f_error = true;
+							}
+							
+							if (role != null && binding != null) {
+								DeclarationBinding db=new DeclarationBinding(role, binding);
+							
+								db.getSource().setStartPosition(dbstartpos);
+								db.getSource().setEndPosition(t.getSource().getEndPosition());
+								
+								ret.getBindings().add(db);
+							}
+						} else {
+							l.error(new ModelIssue(t, java.util.PropertyResourceBundle.getBundle(
+								"org.scribble.parser.Messages").
+								getString("_EXPECTING_ROLE_NAME")));
+							f_error = true;
+						}
+						
+						t = context.lookahead(0);
+						
+					} while (f_error == false &&
+							t.isToken(ParserConstants.LIST_SEPARATOR,
+									TokenType.Symbol));			
+					
+					if (t.isToken(")", TokenType.Symbol)) {
+						context.nextToken();
+					} else {
+						l.error(new ModelIssue(t, java.util.PropertyResourceBundle.getBundle(
+								"org.scribble.parser.Messages").
+								getString("_EXPECTING_PARAMETER_LIST_DELIMITER")));
+					}
+				}
+				
+				Conversation conversation=new Conversation();
+				
+				if (located != null) {
+					LocatedName modelName=new LocatedName();
+					Role role=new Role();
+					role.setName(located);
+					modelName.setRole(role);
+					conversation.setLocatedName(modelName);
+				}
+				
+				ret.setInlineDefinition(conversation);
+				
+				// Create new scope for the inline activities
+				context.pushScope();
+				
+				// Parse the inline activities
+				parseGroup(context, l, conversation.getBlock(), false);
+				
+				context.popScope();
+			}
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/RunParserRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/RunParserRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/RunParserRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,197 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 9 Mar 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.parser;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.parser.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class provides the parser rule for the Run construct.
+ * 
+ */
+ at RegistryInfo(extension=ParserRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class RunParserRule extends org.scribble.parser.AbstractParserRule {
+
+	/**
+	 * The default constructor.
+	 */
+	public RunParserRule() {
+		super(ParserRuleType.Line);
+	}
+	
+	/**
+	 * This method determines whether the parser rules is
+	 * appropriate to return a model object of the required
+	 * type.
+	 * 
+	 * @param type The required type
+	 * @return Whether the parser rule returns a
+	 * 				model object of the required type
+	 */
+	public boolean isSupported(Class<?> type) {
+		return(type.isAssignableFrom(Run.class));
+	}
+
+	/**
+	 * This method parses the description to obtain
+	 * a model object of the appropriate type.
+	 * 
+	 * @param context The context
+	 * @param l The listener
+	 * @return The model object
+	 */
+	public Object parse(ParserContext context, ModelListener l) {
+		Run ret=null;
+		
+		Token t=context.lookahead(0);
+		
+		if (t.isToken("run", TokenType.Keyword)) {
+			int startpos=t.getSource().getStartPosition();
+			
+			t = context.lookahead(1);
+			
+			// Need to locate an identifier
+			if (t.getType() == TokenType.Identifier) {
+				
+				// Consume tokens
+				context.nextToken();
+				
+				ConversationReference ref=(ConversationReference)
+						context.parse(ConversationReference.class, l);
+				
+				// GPB: TO REMOVE resolveReference(context, l, ref, DependencyType.Uses);
+
+				ret = new Run();
+				
+				ret.setReference(ref);
+					
+				ret.getSource().setStartPosition(startpos);
+				ret.getSource().setEndPosition(t.getSource().getEndPosition());
+			
+				// Check for role bindings
+				t = context.lookahead(0);
+			
+				if (t.isToken("(", TokenType.Symbol)) {
+					boolean f_error=false;
+					
+					do {
+						// Consume token
+						context.nextToken();
+						
+						// Read next token, which should be an identifier
+						t = context.lookahead(0);
+					
+						if (t.getType() == TokenType.Identifier) {
+							Declaration declaration=null;
+							String binding=null;
+							int dbstartpos=t.getSource().getStartPosition();
+							
+							// Consume token
+							context.nextToken();
+						
+							// Locate the declaration
+							Object decl=context.getState(t.getText());
+							
+							if (decl == null) {
+								l.error(new ModelIssue(t,
+									org.scribble.util.MessageUtil.format(
+											java.util.PropertyResourceBundle.getBundle(
+													"org.scribble.parser.Messages"),
+											"_UNKNOWN_DECLARATION",
+											new String[]{t.getText()})));
+							} else if (decl instanceof Declaration) {
+								declaration = (Declaration)decl;
+							} else {
+								l.error(new ModelIssue(t,
+									org.scribble.util.MessageUtil.format(
+											java.util.PropertyResourceBundle.getBundle(
+													"org.scribble.parser.Messages"),
+											"_REQUIRED_DECLARATION",
+											new String[]{t.getText()})));
+							}
+							
+							t = context.lookahead(0);
+							
+							if (t.isToken("for", TokenType.Keyword)) {
+								
+								context.nextToken();
+								
+								t = context.lookahead(0);
+								
+								if (t.getType() == TokenType.Identifier) {
+									
+									context.nextToken();
+									
+									binding = t.getText();
+								} else {
+									l.error(new ModelIssue(t, java.util.PropertyResourceBundle.getBundle(
+											"org.scribble.parser.Messages").
+												getString("_EXPECTING_IDENTIFIER")));
+									f_error = true;
+								}
+							} else {
+								l.error(new ModelIssue(t,
+										org.scribble.util.MessageUtil.format(
+												java.util.PropertyResourceBundle.getBundle(
+														"org.scribble.parser.Messages"),
+												"_EXPECTING_KEYWORD",
+												new String[]{"for"})));
+								f_error = true;
+							}
+							
+							if (declaration != null && binding != null) {
+								DeclarationBinding db=new DeclarationBinding(declaration, binding);
+								
+								db.getSource().setStartPosition(dbstartpos);
+								db.getSource().setEndPosition(t.getSource().getEndPosition());
+								
+								ret.getBindings().add(db);
+							}
+						} else {
+							l.error(new ModelIssue(t, java.util.PropertyResourceBundle.getBundle(
+								"org.scribble.parser.Messages").
+								getString("_EXPECTING_ROLE_NAME")));
+							f_error = true;
+						}
+						
+						t = context.lookahead(0);
+						
+					} while (f_error == false &&
+							t.isToken(ParserConstants.LIST_SEPARATOR,
+									TokenType.Symbol));			
+					
+					if (t.isToken(")", TokenType.Symbol)) {
+						context.nextToken();
+					} else {
+						l.error(new ModelIssue(t, java.util.PropertyResourceBundle.getBundle(
+								"org.scribble.parser.Messages").
+								getString("_EXPECTING_PARAMETER_LIST_DELIMITER")));
+					}
+				}
+			}
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/SpawnConversationParserRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/SpawnConversationParserRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/SpawnConversationParserRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,232 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 7 Aug 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.parser;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.parser.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class provides the parser rule for the Spawn construct.
+ * 
+ */
+ at RegistryInfo(extension=ParserRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class SpawnConversationParserRule extends org.scribble.parser.AbstractParserRule {
+
+	/**
+	 * The default constructor.
+	 */
+	public SpawnConversationParserRule() {
+		super(ParserRuleType.Group);
+	}
+	
+	/**
+	 * This method determines whether the parser rules is
+	 * appropriate to return a model object of the required
+	 * type.
+	 * 
+	 * @param type The required type
+	 * @return Whether the parser rule returns a
+	 * 				model object of the required type
+	 */
+	public boolean isSupported(Class<?> type) {
+		return(type.isAssignableFrom(Spawn.class));
+	}
+
+	/**
+	 * This method parses the description to obtain
+	 * a model object of the appropriate type.
+	 * 
+	 * @param context The context
+	 * @param l The listener
+	 * @return The model object
+	 */
+	public Object parse(ParserContext context, ModelListener l) {
+		Spawn ret=null;
+		
+		Token t=context.lookahead(0);
+		
+		if (t.isToken("spawn", TokenType.Keyword)) {
+			int startpos=t.getSource().getStartPosition();
+			
+			t = context.lookahead(1);
+			
+			// Need to locate a 'conversation' keyword
+			if (t.isToken("conversation", TokenType.Keyword)) {
+				String located=null;
+				
+				// Consume tokens
+				context.nextToken();
+				context.nextToken();
+				
+				ret = new Spawn();
+				
+				ret.getSource().setStartPosition(startpos);
+				ret.getSource().setEndPosition(t.getSource().getEndPosition());
+			
+				// Check for role bindings
+				t = context.lookahead(0);
+				
+				if (t.isToken(ModelReference.LOCATED_REFERENCE_SEPARATOR,
+									TokenType.Symbol)) {
+					context.nextToken();
+					
+					t = context.lookahead(0);
+					
+					if (t.getType() == TokenType.Identifier) {
+						context.nextToken();
+
+						located = t.getText();
+						
+						t = context.lookahead(0);
+						
+					} else {
+						l.error(new ModelIssue(t, java.util.PropertyResourceBundle.getBundle(
+							"org.scribble.parser.Messages").
+							getString("_EXPECTING_ROLE_NAME")));
+					}
+				}
+			
+				if (t.isToken("(", TokenType.Symbol)) {
+					boolean f_error=false;
+					
+					do {
+						// Consume token
+						context.nextToken();
+						
+						// Read next token, which should be an identifier
+						t = context.lookahead(0);
+					
+						if (t.getType() == TokenType.Identifier) {
+							Role role=null;
+							String binding=null;
+							int dbstartpos=t.getSource().getStartPosition();
+							
+							// Consume token
+							context.nextToken();
+						
+							// Locate the role definition
+							Object part=context.getState(t.getText());
+							
+							if (part == null) {
+								l.error(new ModelIssue(t,
+									org.scribble.util.MessageUtil.format(
+											java.util.PropertyResourceBundle.getBundle(
+													"org.scribble.parser.Messages"),
+											"_UNKNOWN_ROLE",
+											new String[]{t.getText()})));
+							} else if (part instanceof Role) {
+								role = (Role)part;
+							} else {
+								l.error(new ModelIssue(t,
+									org.scribble.util.MessageUtil.format(
+											java.util.PropertyResourceBundle.getBundle(
+													"org.scribble.parser.Messages"),
+											"_REQUIRED_ROLE",
+											new String[]{t.getText()})));
+							}
+							
+							t = context.lookahead(0);
+							
+							if (t.isToken("for", TokenType.Keyword)) {
+								
+								context.nextToken();
+								
+								t = context.lookahead(0);
+								
+								if (t.getType() == TokenType.Identifier) {
+									
+									context.nextToken();
+									
+									binding = t.getText();
+								} else {
+									l.error(new ModelIssue(t, java.util.PropertyResourceBundle.getBundle(
+											"org.scribble.parser.Messages").
+												getString("_EXPECTING_IDENTIFIER")));
+									f_error = true;
+								}
+							} else {
+								l.error(new ModelIssue(t,
+										org.scribble.util.MessageUtil.format(
+												java.util.PropertyResourceBundle.getBundle(
+														"org.scribble.parser.Messages"),
+												"_EXPECTING_KEYWORD",
+												new String[]{"for"})));
+								f_error = true;
+							}
+							
+							if (role != null && binding != null) {
+								DeclarationBinding db=new DeclarationBinding(role, binding);
+								
+								db.getSource().setStartPosition(dbstartpos);
+								db.getSource().setEndPosition(t.getSource().getEndPosition());
+								
+								ret.getBindings().add(db);
+							}
+						} else {
+							l.error(new ModelIssue(t, java.util.PropertyResourceBundle.getBundle(
+								"org.scribble.parser.Messages").
+								getString("_EXPECTING_ROLE_NAME")));
+							f_error = true;
+						}
+						
+						t = context.lookahead(0);
+						
+					} while (f_error == false &&
+							t.isToken(ParserConstants.LIST_SEPARATOR,
+									TokenType.Symbol));			
+					
+					if (t.isToken(")", TokenType.Symbol)) {
+						context.nextToken();
+					} else {
+						l.error(new ModelIssue(t, java.util.PropertyResourceBundle.getBundle(
+								"org.scribble.parser.Messages").
+								getString("_EXPECTING_PARAMETER_LIST_DELIMITER")));
+					}
+				}
+				
+				Conversation conversation=new Conversation();
+				
+				if (located != null) {
+					LocatedName modelName=new LocatedName();
+					Role role=new Role();
+					role.setName(located);
+					modelName.setRole(role);
+					conversation.setLocatedName(modelName);
+				}
+				
+				ret.setInlineDefinition(conversation);
+				
+				// Create new scope for the inline activities
+				context.pushScope();
+				
+				// Parse the inline activities
+				parseGroup(context, l, conversation.getBlock(),	false);
+				
+				context.popScope();
+			}
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/SpawnParserRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/SpawnParserRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/SpawnParserRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,197 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 7 Aug 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.parser;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.parser.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class provides the parser rule for the Spawn construct.
+ * 
+ */
+ at RegistryInfo(extension=ParserRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class SpawnParserRule extends org.scribble.parser.AbstractParserRule {
+
+	/**
+	 * The default constructor.
+	 */
+	public SpawnParserRule() {
+		super(ParserRuleType.Line);
+	}
+	
+	/**
+	 * This method determines whether the parser rules is
+	 * appropriate to return a model object of the required
+	 * type.
+	 * 
+	 * @param type The required type
+	 * @return Whether the parser rule returns a
+	 * 				model object of the required type
+	 */
+	public boolean isSupported(Class<?> type) {
+		return(type.isAssignableFrom(Spawn.class));
+	}
+
+	/**
+	 * This method parses the description to obtain
+	 * a model object of the appropriate type.
+	 * 
+	 * @param context The context
+	 * @param l The listener
+	 * @return The model object
+	 */
+	public Object parse(ParserContext context, ModelListener l) {
+		Spawn ret=null;
+		
+		Token t=context.lookahead(0);
+		
+		if (t.isToken("spawn", TokenType.Keyword)) {
+			int startpos=t.getSource().getStartPosition();
+			
+			t = context.lookahead(1);
+			
+			// Need to locate an identifier
+			if (t.getType() == TokenType.Identifier) {
+				
+				// Consume tokens
+				context.nextToken();
+				
+				ConversationReference ref=(ConversationReference)
+						context.parse(ConversationReference.class, l);
+				
+				// GPB: TO REMOVE resolveReference(context, l, ref, DependencyType.Uses);
+
+				ret = new Spawn();
+				
+				ret.setReference(ref);
+					
+				ret.getSource().setStartPosition(startpos);
+				ret.getSource().setEndPosition(t.getSource().getEndPosition());
+			
+				// Check for role bindings
+				t = context.lookahead(0);
+			
+				if (t.isToken("(", TokenType.Symbol)) {
+					boolean f_error=false;
+					
+					do {
+						// Consume token
+						context.nextToken();
+						
+						// Read next token, which should be an identifier
+						t = context.lookahead(0);
+					
+						if (t.getType() == TokenType.Identifier) {
+							Declaration declaration=null;
+							String binding=null;
+							int dbstartpos=t.getSource().getStartPosition();
+							
+							// Consume token
+							context.nextToken();
+						
+							// Locate the declaration
+							Object decl=context.getState(t.getText());
+							
+							if (decl == null) {
+								l.error(new ModelIssue(t,
+									org.scribble.util.MessageUtil.format(
+											java.util.PropertyResourceBundle.getBundle(
+													"org.scribble.parser.Messages"),
+											"_UNKNOWN_DECLARATION",
+											new String[]{t.getText()})));
+							} else if (decl instanceof Declaration) {
+								declaration = (Declaration)decl;
+							} else {
+								l.error(new ModelIssue(t,
+									org.scribble.util.MessageUtil.format(
+											java.util.PropertyResourceBundle.getBundle(
+													"org.scribble.parser.Messages"),
+											"_REQUIRED_DECLARATION",
+											new String[]{t.getText()})));
+							}
+							
+							t = context.lookahead(0);
+							
+							if (t.isToken("for", TokenType.Keyword)) {
+								
+								context.nextToken();
+								
+								t = context.lookahead(0);
+								
+								if (t.getType() == TokenType.Identifier) {
+									
+									context.nextToken();
+									
+									binding = t.getText();
+								} else {
+									l.error(new ModelIssue(t, java.util.PropertyResourceBundle.getBundle(
+											"org.scribble.parser.Messages").
+												getString("_EXPECTING_IDENTIFIER")));
+									f_error = true;
+								}
+							} else {
+								l.error(new ModelIssue(t,
+										org.scribble.util.MessageUtil.format(
+												java.util.PropertyResourceBundle.getBundle(
+														"org.scribble.parser.Messages"),
+												"_EXPECTING_KEYWORD",
+												new String[]{"for"})));
+								f_error = true;
+							}
+							
+							if (declaration != null && binding != null) {
+								DeclarationBinding db=new DeclarationBinding(declaration, binding);
+								
+								db.getSource().setStartPosition(dbstartpos);
+								db.getSource().setEndPosition(t.getSource().getEndPosition());
+								
+								ret.getBindings().add(db);
+							}
+						} else {
+							l.error(new ModelIssue(t, java.util.PropertyResourceBundle.getBundle(
+								"org.scribble.parser.Messages").
+								getString("_EXPECTING_ROLE_NAME")));
+							f_error = true;
+						}
+						
+						t = context.lookahead(0);
+						
+					} while (f_error == false &&
+							t.isToken(ParserConstants.LIST_SEPARATOR,
+									TokenType.Symbol));			
+					
+					if (t.isToken(")", TokenType.Symbol)) {
+						context.nextToken();
+					} else {
+						l.error(new ModelIssue(t, java.util.PropertyResourceBundle.getBundle(
+								"org.scribble.parser.Messages").
+								getString("_EXPECTING_PARAMETER_LIST_DELIMITER")));
+					}
+				}
+			}
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/TryEscapeParserRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/TryEscapeParserRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/TryEscapeParserRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 18 Oct 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.parser;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.parser.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class provides the parser rule for the TryEscape construct.
+ * 
+ */
+ at RegistryInfo(extension=ParserRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class TryEscapeParserRule extends org.scribble.parser.AbstractParserRule {
+
+	/**
+	 * The default constructor.
+	 */
+	public TryEscapeParserRule() {
+		super(ParserRuleType.Group);
+	}
+	
+	/**
+	 * This method determines whether the parser rules is
+	 * appropriate to return a model object of the required
+	 * type.
+	 * 
+	 * @param type The required type
+	 * @return Whether the parser rule returns a
+	 * 				model object of the required type
+	 */
+	public boolean isSupported(Class<?> type) {
+		return(type.isAssignableFrom(TryEscape.class));
+	}
+
+	/**
+	 * This method parses the description to obtain
+	 * a model object of the appropriate type.
+	 * 
+	 * @param context The context
+	 * @param l The listener
+	 * @return The model object
+	 */
+	public Object parse(ParserContext context, ModelListener l) {
+		TryEscape ret=null;
+		
+		Token t=context.lookahead(0);
+		
+		if (t.isToken("try", TokenType.Keyword)) {
+			int startpos=t.getSource().getStartPosition();
+
+			// Consume token
+			context.nextToken();
+			
+			ret = new TryEscape();
+				
+			ret.getSource().setStartPosition(startpos);
+			
+			ret.getBlock().getSource().setStartPosition(t.getSource().getStartPosition());
+				
+			// Parse group
+			parseGroup(context, l, ret.getBlock(), true);
+				
+			// Parsing the group does not consume the final curly
+			// bracket, to ensure that other rules know that the
+			// block has completed, so need to look past this token
+			t = context.lookahead(0);
+			
+			ret.getBlock().getSource().setEndPosition(t.getSource().getStartPosition());
+
+			// Configure zero or more escape blocks
+			EscapeBlock eb=null;
+			
+			while ((eb=(EscapeBlock)context.parse(EscapeBlock.class, l)) != null) {
+				ret.getEscapeBlocks().add(eb);
+			}
+			
+			// Find position of last block to set as end for try/escape
+			t = context.lookahead(0);
+
+			ret.getSource().setEndPosition(t.getSource().getStartPosition());
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/VariableListParserRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/VariableListParserRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/VariableListParserRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,146 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 10 Jan 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.parser;
+
+import org.scribble.extensions.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.parser.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class provides the parser rule for the Variable List
+ * declaration.
+ */
+ at RegistryInfo(extension=ParserRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class VariableListParserRule extends org.scribble.parser.AbstractParserRule {
+
+	/**
+	 * The default constructor.
+	 */
+	public VariableListParserRule() {
+		super(ParserRuleType.Line);
+	}
+	
+	/**
+	 * This method determines whether the parser rules is
+	 * appropriate to return a model object of the required
+	 * type.
+	 * 
+	 * @param type The required type
+	 * @return Whether the parser rule returns a
+	 * 				model object of the required type
+	 */
+	public boolean isSupported(Class<?> type) {
+		return(type.isAssignableFrom(VariableList.class));
+	}
+
+	/**
+	 * This method parses the description to obtain
+	 * a model object of the appropriate type.
+	 * 
+	 * @param context The context
+	 * @param l The listener
+	 * @return The model object
+	 */
+	public Object parse(ParserContext context, ModelListener l) {
+		VariableList ret=null;
+		
+		Token t=context.lookahead(0);
+		
+		if (t.getType() == TokenType.Identifier) {
+			boolean f_error=false;
+			
+			Token t2=context.lookahead(1);
+			
+			if (t2.getType() == TokenType.Identifier) {
+				boolean f_first=true;
+				
+				// Parse type reference related to initial identifier
+				TypeReference ref=(TypeReference)
+						context.parse(TypeReference.class, l);
+				
+				// GPB: TO REMOVE resolveReference(context, l, ref, DependencyType.Uses);
+				
+				ret = new VariableList();
+				
+				ret.setType(ref);
+				
+				ret.getSource().setStartPosition(t.getSource().getStartPosition());
+				
+				do {
+					if (f_first == false) {
+						context.nextToken();
+					}
+					
+					// Read next token, which should be an identifier
+					t = context.lookahead(0);
+				
+					if (t.getType() == TokenType.Identifier) {
+						
+						// Consume token
+						context.nextToken();
+					
+						Variable var=new Variable();
+						var.getSource().setStartPosition(t.getSource().getStartPosition());
+					
+						var.setName(t.getText());
+						
+						var.getSource().setEndPosition(t.getSource().getEndPosition());
+						
+						ret.getSource().setEndPosition(t.getSource().getEndPosition());
+						
+						ret.getVariables().add(var);
+						
+						// Check if name has already been defined in state
+						if (context.getState(t.getText()) != null) {
+							l.error(new ModelIssue(t,
+									org.scribble.util.MessageUtil.format(
+											java.util.PropertyResourceBundle.getBundle(
+													"org.scribble.parser.Messages"),
+											"_DUPLICATE_DECLARATION",
+											new String[]{t.getText()})));
+						} else {
+						
+							// Add to state
+							context.setState(var.getName(), var);
+						}
+						
+					} else {
+						l.error(new ModelIssue(t, java.util.PropertyResourceBundle.getBundle(
+									"org.scribble.conversation.parser.Messages").
+									getString("_EXPECTING_VARIABLE_NAME")));
+						f_error = true;
+					}
+					
+					t = context.lookahead(0);
+					
+					f_first = false;
+					
+				} while (f_error == false &&
+						t.isToken(ParserConstants.LIST_SEPARATOR,
+								TokenType.Symbol));				
+			}			
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/WhenParserRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/WhenParserRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/WhenParserRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,215 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 8 Mar 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.parser;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.parser.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class provides the parser rule for the When construct.
+ * 
+ */
+ at RegistryInfo(extension=ParserRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class WhenParserRule extends org.scribble.parser.AbstractParserRule {
+
+	/**
+	 * The default constructor.
+	 */
+	public WhenParserRule() {
+		super(ParserRuleType.Group);
+	}
+	
+	/**
+	 * This method determines whether the parser rules is
+	 * appropriate to return a model object of the required
+	 * type.
+	 * 
+	 * @param type The required type
+	 * @return Whether the parser rule returns a
+	 * 				model object of the required type
+	 */
+	public boolean isSupported(Class<?> type) {
+		return(type.isAssignableFrom(When.class));
+	}
+
+	/**
+	 * This method parses the description to obtain
+	 * a model object of the appropriate type.
+	 * 
+	 * @param context The context
+	 * @param l The listener
+	 * @return The model object
+	 */
+	public Object parse(ParserContext context, ModelListener l) {
+		When ret=null;
+		
+		Token t=context.lookahead(0);
+		
+		if (t.isToken("when", TokenType.Keyword)) {
+			int startpos=t.getSource().getStartPosition();
+
+			// Consume token
+			context.nextToken();
+			
+			ret = new When();
+				
+			ret.getSource().setStartPosition(startpos);
+			
+			// Check for located roles
+			t = context.lookahead(0);
+			
+			if (t.isToken(ModelReference.LOCATED_REFERENCE_SEPARATOR,
+								TokenType.Symbol)) {
+				boolean f_error=false;
+				
+				// Work through list of roles
+				do {
+					// Consume token
+					context.nextToken();
+					
+					// Read next token, which should be an identifier
+					t = context.lookahead(0);
+				
+					if (t.getType() == TokenType.Identifier) {
+						
+						// Consume token
+						context.nextToken();
+					
+						// Locate the role definition
+						Object part=context.getState(t.getText());
+						
+						if (part == null) {
+							l.error(new ModelIssue(t,
+								org.scribble.util.MessageUtil.format(
+										java.util.PropertyResourceBundle.getBundle(
+												"org.scribble.parser.Messages"),
+										"_UNKNOWN_ROLE",
+										new String[]{t.getText()})));
+						} else if (part instanceof Role) {
+							ret.getRoles().add((Role)part);
+						} else {
+							l.error(new ModelIssue(t,
+								org.scribble.util.MessageUtil.format(
+										java.util.PropertyResourceBundle.getBundle(
+												"org.scribble.parser.Messages"),
+										"_REQUIRED_ROLE",
+										new String[]{t.getText()})));
+						}
+						
+						t = context.lookahead(0);
+					} else {
+						l.error(new ModelIssue(t, java.util.PropertyResourceBundle.getBundle(
+							"org.scribble.parser.Messages").
+							getString("_EXPECTING_ROLE_NAME")));
+						f_error = true;
+					}
+				} while (f_error == false &&
+						t.isToken(ParserConstants.LIST_SEPARATOR,
+								TokenType.Symbol));				
+			}
+			
+			boolean f_end=false;
+			
+			do {
+				f_end = true;
+				
+				Block block=null;
+				
+				ConditionalBlock cblock = new ConditionalBlock();
+				ret.getConditionalBlocks().add(cblock);
+				
+				block = cblock;
+				
+				block.getSource().setStartPosition(t.getSource().getStartPosition());
+
+				t = context.lookahead(0);
+
+				if (t.isToken("(", TokenType.Symbol)) {
+					// Consume symbol
+					context.nextToken();
+					
+					cblock.setExpression((Expression)
+							context.parse(Expression.class, l));
+					
+					// Check if end of expression symbol specified
+					t = context.lookahead(0);
+					
+					if (t.isToken(")", TokenType.Symbol)) {
+						context.nextToken();
+					} else {
+						
+						// Report 'expecting )' message
+						l.error(new ModelIssue(t, org.scribble.util.MessageUtil.format(
+								java.util.PropertyResourceBundle.getBundle(
+										"org.scribble.parser.Messages"),
+										"_EXPECTING_SYMBOL",
+										new String[]{")"})));
+					}
+				}
+
+				// Parse group
+				parseGroup(context, l, block, true);
+				
+				// Parsing the group does not consume the final curly
+				// bracket, to ensure that other rules know that the
+				// block has completed, so need to look past this token
+				t = context.lookahead(0);
+				
+				block.getSource().setEndPosition(t.getSource().getStartPosition());
+
+				ret.getSource().setEndPosition(t.getSource().getStartPosition());
+
+				if (t.isToken("else", TokenType.Keyword)) {
+					
+					f_end = false;
+
+					// Consume 'else'
+					context.nextToken();
+					
+					t = context.lookahead(0);
+					
+					if (t.isToken("when", TokenType.Keyword)) {
+						
+						context.nextToken();
+						
+					} else {
+						
+						// Error
+						l.error(new ModelIssue(t, org.scribble.util.MessageUtil.format(
+								java.util.PropertyResourceBundle.getBundle(
+										"org.scribble.parser.Messages"),
+										"_EXPECTING_KEYWORD",
+										new String[]{"when"})));
+					}
+				}
+				
+			} while (f_end == false);
+			
+			t = context.lookahead(-1);
+			ret.getSource().setEndPosition(t.getSource().getEndPosition());
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/WhileParserRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/WhileParserRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/WhileParserRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,166 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 8 Mar 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.parser;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.parser.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class provides the parser rule for the While construct.
+ * 
+ */
+ at RegistryInfo(extension=ParserRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class WhileParserRule extends org.scribble.parser.AbstractParserRule {
+
+	/**
+	 * The default constructor.
+	 */
+	public WhileParserRule() {
+		super(ParserRuleType.Group);
+	}
+	
+	/**
+	 * This method determines whether the parser rules is
+	 * appropriate to return a model object of the required
+	 * type.
+	 * 
+	 * @param type The required type
+	 * @return Whether the parser rule returns a
+	 * 				model object of the required type
+	 */
+	public boolean isSupported(Class<?> type) {
+		return(type.isAssignableFrom(While.class));
+	}
+
+	/**
+	 * This method parses the description to obtain
+	 * a model object of the appropriate type.
+	 * 
+	 * @param context The context
+	 * @param l The listener
+	 * @return The model object
+	 */
+	public Object parse(ParserContext context, ModelListener l) {
+		While ret=null;
+		
+		Token t=context.lookahead(0);
+		
+		if (t.isToken("while", TokenType.Keyword)) {
+			int startpos=t.getSource().getStartPosition();
+
+			// Consume token
+			context.nextToken();
+			
+			ret = new While();
+				
+			ret.getSource().setStartPosition(startpos);
+			
+			// Check for located roles
+			t = context.lookahead(0);
+			
+			if (t.isToken(ModelReference.LOCATED_REFERENCE_SEPARATOR,
+								TokenType.Symbol)) {
+				boolean f_error=false;
+				
+				// Work through list of roles
+				do {
+					// Consume token
+					context.nextToken();
+					
+					// Read next token, which should be an identifier
+					t = context.lookahead(0);
+				
+					if (t.getType() == TokenType.Identifier) {
+						
+						// Consume token
+						context.nextToken();
+					
+						// Locate the role definition
+						Object part=context.getState(t.getText());
+						
+						if (part == null) {
+							l.error(new ModelIssue(t,
+								org.scribble.util.MessageUtil.format(
+										java.util.PropertyResourceBundle.getBundle(
+												"org.scribble.parser.Messages"),
+										"_UNKNOWN_ROLE",
+										new String[]{t.getText()})));
+						} else if (part instanceof Role) {
+							ret.getRoles().add((Role)part);
+						} else {
+							l.error(new ModelIssue(t,
+								org.scribble.util.MessageUtil.format(
+										java.util.PropertyResourceBundle.getBundle(
+												"org.scribble.parser.Messages"),
+										"_REQUIRED_ROLE",
+										new String[]{t.getText()})));
+						}
+						
+						t = context.lookahead(0);
+					} else {
+						l.error(new ModelIssue(t, java.util.PropertyResourceBundle.getBundle(
+							"org.scribble.parser.Messages").
+							getString("_EXPECTING_ROLE_NAME")));
+						f_error = true;
+					}
+				} while (f_error == false &&
+						t.isToken(ParserConstants.LIST_SEPARATOR,
+								TokenType.Symbol));				
+			}
+			
+			t = context.lookahead(0);
+
+			if (t.isToken("(", TokenType.Symbol)) {
+				// Consume symbol
+				context.nextToken();
+				
+				ret.getBlock().setExpression((Expression)
+						context.parse(Expression.class, l));
+				
+				// Check if end of expression symbol specified
+				t = context.lookahead(0);
+				
+				if (t.isToken(")", TokenType.Symbol)) {
+					context.nextToken();
+				} else {
+					
+					// Report 'expecting )' message
+					l.error(new ModelIssue(t, org.scribble.util.MessageUtil.format(
+							java.util.PropertyResourceBundle.getBundle(
+									"org.scribble.parser.Messages"),
+									"_EXPECTING_SYMBOL",
+									new String[]{")"})));
+				}
+			}
+
+			// Parse group
+			parseGroup(context, l, ret.getBlock(), true);
+			
+			t = context.lookahead(-1);
+			ret.getSource().setEndPosition(t.getSource().getEndPosition());
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/osgi/Activator.java
===================================================================
--- trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/osgi/Activator.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.parser/src/main/java/org/scribble/conversation/parser/osgi/Activator.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 9 Jan 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.parser.osgi;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator implements BundleActivator {
+
+	// The plug-in ID
+	public static final String PLUGIN_ID = "org.scribble.conversation.parser";
+
+	// The shared instance
+	private static Activator plugin;
+	
+	/**
+	 * The constructor
+	 */
+	public Activator() {
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
+	 */
+	public void start(BundleContext context) throws Exception {
+		plugin = this;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
+	 */
+	public void stop(BundleContext context) throws Exception {
+		plugin = null;
+	}
+
+	/**
+	 * Returns the shared instance
+	 *
+	 * @return the shared instance
+	 */
+	public static Activator getDefault() {
+		return plugin;
+	}
+
+}

Added: trunk/bundles/org.scribble.conversation.projector/.classpath
===================================================================
--- trunk/bundles/org.scribble.conversation.projector/.classpath	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.projector/.classpath	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src/main/java"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="output" path="classes"/>
+</classpath>

Added: trunk/bundles/org.scribble.conversation.projector/.project
===================================================================
--- trunk/bundles/org.scribble.conversation.projector/.project	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.projector/.project	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.scribble.conversation.projector</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.ManifestBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.SchemaBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.pde.PluginNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

Added: trunk/bundles/org.scribble.conversation.projector/LICENSE.txt
===================================================================
--- trunk/bundles/org.scribble.conversation.projector/LICENSE.txt	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.projector/LICENSE.txt	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,201 @@
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   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.

Added: trunk/bundles/org.scribble.conversation.projector/META-INF/MANIFEST.MF
===================================================================
--- trunk/bundles/org.scribble.conversation.projector/META-INF/MANIFEST.MF	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.projector/META-INF/MANIFEST.MF	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,30 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Scribble Conversation Projector Plug-in
+Bundle-SymbolicName: org.scribble.conversation.projector;singleton:=true
+Bundle-Version: 1.2.0.qualifier
+Bundle-Activator: org.scribble.conversation.projector.osgi.Activator
+Bundle-Vendor: www.scribble.org
+Import-Package: org.osgi.framework;version="1.3.0"
+Require-Bundle: org.scribble.core;bundle-version="[1.0.0,2.0.0)",
+ org.scribble.conversation.model;bundle-version="[1.0.0,2.0.0)"
+Bundle-ActivationPolicy: lazy
+Scribble-Extensions: org.scribble.conversation.projector.ConversationModelProjectorRule,
+  org.scribble.conversation.projector.IdentityLocatorProjectorRule,
+  org.scribble.conversation.projector.IdentityProjectorRule,
+  org.scribble.conversation.projector.ConversationProjectorRule,
+  org.scribble.conversation.projector.ConversationInteractionProjectorRule,
+  org.scribble.conversation.projector.ConversationReferenceProjectorRule,
+  org.scribble.conversation.projector.IfProjectorRule,
+  org.scribble.conversation.projector.ConditionalBlockProjectorRule,
+  org.scribble.conversation.projector.ParallelProjectorRule,
+  org.scribble.conversation.projector.WhenProjectorRule,
+  org.scribble.conversation.projector.WhileProjectorRule,
+  org.scribble.conversation.projector.RunProjectorRule,
+  org.scribble.conversation.projector.SpawnProjectorRule,
+  org.scribble.conversation.projector.TryEscapeProjectorRule,
+  org.scribble.conversation.projector.CatchBlockProjectorRule,
+  org.scribble.conversation.projector.InterruptBlockProjectorRule,
+  org.scribble.conversation.projector.RaiseProjectorRule,
+  org.scribble.conversation.projector.VariableListProjectorRule
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6

Added: trunk/bundles/org.scribble.conversation.projector/build.properties
===================================================================
--- trunk/bundles/org.scribble.conversation.projector/build.properties	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.projector/build.properties	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,5 @@
+source.. = src/main/java/
+output.. = classes/
+bin.includes = META-INF/,\
+               .,\
+               plugin.xml

Added: trunk/bundles/org.scribble.conversation.projector/pom.xml
===================================================================
--- trunk/bundles/org.scribble.conversation.projector/pom.xml	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.projector/pom.xml	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,33 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  	<modelVersion>4.0.0</modelVersion>
+	<groupId>org.savara.bundles</groupId>
+	<artifactId>org.scribble.conversation.projector</artifactId> 
+	<version>1.2.0-SNAPSHOT</version>
+	<packaging>jar</packaging>
+	<name>Savara::Bundles::ScribbleConversationProjector</name>
+
+	<parent>
+		<groupId>org.savara</groupId>
+		<artifactId>bundles</artifactId>
+		<version>1.2.0-SNAPSHOT</version>
+	</parent>
+
+	<dependencies>
+		<dependency>
+			<groupId>org.savara.bundles</groupId>
+			<artifactId>org.scribble.core</artifactId>
+			<version>1.2.0-SNAPSHOT</version>
+		</dependency>
+		<dependency>
+			<groupId>org.savara.bundles</groupId>
+			<artifactId>org.scribble.conversation.model</artifactId>
+			<version>1.2.0-SNAPSHOT</version>
+		</dependency>
+	    <dependency>
+	      <groupId>org.apache.felix</groupId>
+	      <artifactId>org.osgi.core</artifactId>
+	      <version>${osgi.version}</version>
+	    </dependency>
+	</dependencies>
+</project>

Added: trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/CatchBlockProjectorRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/CatchBlockProjectorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/CatchBlockProjectorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 19 Oct 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.projector;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.projector.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class provides the CatchBlock implementation of the
+ * projector rule.
+ */
+ at RegistryInfo(extension=ProjectorRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class CatchBlockProjectorRule extends AbstractBlockProjectorRule {
+
+	/**
+	 * This method determines whether the projection rule is
+	 * appropriate for the supplied model object.
+	 * 
+	 * @param obj The model object to be projected
+	 * @return Whether the rule is relevant for the
+	 * 				model object
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj.getClass() == CatchBlock.class);
+	}
+	
+	/**
+	 * This method creates a new block of the appropriate
+	 * type.
+	 * 
+	 * @return The block
+	 */
+	protected Block createBlock() {
+		return(new CatchBlock());
+	}
+	
+	/**
+	 * This method projects the supplied model object based on the
+	 * specified role.
+	 * 
+	 * @param model The model object
+	 * @param role The role
+	 * @param l The model listener
+	 * @return The projected model object
+	 */
+	public ModelObject project(ProjectorContext context, ModelObject model,
+					Role role, ModelListener l) {
+		CatchBlock ret=(CatchBlock)super.project(context,
+				model, role, l);
+		CatchBlock source=(CatchBlock)model;
+
+		// If block not projected, then if projected role is in
+		// the list, the re-instate
+		if (ret == null && source.getRoles().contains(role)) {
+			ret = new CatchBlock();
+			
+			ret.derivedFrom(source);
+		}
+		
+		if (ret != null) {
+			
+			// Project the list of roles
+			for (int i=0; i < source.getRoles().size(); i++) {
+				ret.getRoles().add(new Role(source.getRoles().get(i)));
+			}
+			
+			if (source.getType() != null) {
+		
+				// Project the type reference
+				ret.setType((TypeReference)
+						context.project(source.getType(),
+								role, l));
+			}
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/ComposeProjectorRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/ComposeProjectorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/ComposeProjectorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 19 Augs 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.projector;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.projector.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class provides the abstract Compose implementation of the
+ * projector rule.
+ */
+public abstract class ComposeProjectorRule extends ModelIncludeProjectorRule {
+
+	/**
+	 * This method projects the supplied model object based on the
+	 * specified role.
+	 * 
+	 * @param model The model object
+	 * @param role The role
+	 * @param l The model listener
+	 * @return The projected model object
+	 */
+	public ModelObject project(ProjectorContext context, ModelObject model,
+					Role role, ModelListener l) {
+		Compose ret=(Compose)super.project(context, model, role,
+							l);
+		Compose source=(Compose)model;
+
+		Role mappedRole=role;
+		
+		// Determine whether role name has been mapped
+		DeclarationBinding db=null;
+		if ((db=source.getDeclarationBinding(role)) != null) {
+			String rename=db.getBoundName();
+			
+			if (rename != null) {
+				mappedRole = new Role();
+				mappedRole.setName(rename);
+			}
+		}
+				
+		if (source.getInlineDefinition() != null) {
+			ret.setInlineDefinition((Conversation)context.project(source.getInlineDefinition(),
+							mappedRole, l));
+		}
+		
+		if (source.getReference() != null) {
+						
+			// Store conversation against mapped role
+			Definition defn=source.getDefinition();
+			
+			if (defn != null &&
+					defn.getRoles().contains(mappedRole)) {
+				
+				// If inner reference, then record interest
+				// in project of definition against this mapped
+				// role
+				if (source.getReference().isInner()) {
+					context.registerInterest(defn, mappedRole);
+				}
+				
+				ret.setReference((ConversationReference)context.project(
+							source.getReference(), mappedRole, l));
+			} else {
+				ret = null;
+			}
+		}
+
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/ConditionalBlockProjectorRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/ConditionalBlockProjectorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/ConditionalBlockProjectorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 19 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.conversation.projector;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.conversation.model.*;
+import org.scribble.projector.*;
+
+/**
+ * This class provides the Block implementation of the
+ * projector rule.
+ */
+ at RegistryInfo(extension=ProjectorRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class ConditionalBlockProjectorRule extends AbstractBlockProjectorRule {
+
+	/**
+	 * This method determines whether the projection rule is
+	 * appropriate for the supplied model object.
+	 * 
+	 * @param obj The model object to be projected
+	 * @return Whether the rule is relevant for the
+	 * 				model object
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj.getClass() == ConditionalBlock.class);
+	}
+	
+	/**
+	 * This method creates a new block of the appropriate
+	 * type.
+	 * 
+	 * @return The block
+	 */
+	protected Block createBlock() {
+		return(new ConditionalBlock());
+	}
+	
+	/**
+	 * This method projects the supplied model object based on the
+	 * specified role.
+	 * 
+	 * @param model The model object
+	 * @param role The role
+	 * @param l The model listener
+	 * @return The projected model object
+	 */
+	public ModelObject project(ProjectorContext context, ModelObject model,
+					Role role, ModelListener l) {
+		ConditionalBlock ret=(ConditionalBlock)super.project(context,
+									model, role, l);
+		ConditionalBlock source=(ConditionalBlock)model;
+
+		if (ret != null && source.getExpression() != null) {
+			
+			// Project the expression
+			ret.setExpression((Expression)
+					context.project(source.getExpression(),
+								role, l));
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/ConversationInteractionProjectorRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/ConversationInteractionProjectorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/ConversationInteractionProjectorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 25 Jan, 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.projector;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.conversation.model.*;
+import org.scribble.projector.*;
+
+/**
+ * This class provides the ConversationInteraction implementation of the
+ * projector rule.
+ */
+ at RegistryInfo(extension=ProjectorRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class ConversationInteractionProjectorRule extends InteractionProjectorRule {
+
+	/**
+	 * This method determines whether the projection rule is
+	 * appropriate for the supplied model object.
+	 * 
+	 * @param obj The model object to be projected
+	 * @return Whether the rule is relevant for the
+	 * 				model object
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj.getClass() == ConversationInteraction.class);
+	}
+	
+	/**
+	 * This method returns a new instance of the interaction model
+	 * object.
+	 * 
+	 * @return The new interaction
+	 */
+	protected Interaction createInteraction() {
+		return(new ConversationInteraction());
+	}
+	
+	/**
+	 * This method projects the supplied model object based on the
+	 * specified role.
+	 * 
+	 * @param model The model object
+	 * @param role The role
+	 * @param l The model listener
+	 * @return The projected model object
+	 */
+	public ModelObject project(ProjectorContext context, ModelObject model,
+					Role role, ModelListener l) {
+		ConversationInteraction ret=(ConversationInteraction)
+					super.project(context, model, role, l);
+		
+		if (ret != null) {
+			ConversationInteraction source=(ConversationInteraction)model;
+			
+			// Only project variable if associated with local role
+			if (source.getFromVariable() != null) {
+				
+				// Find variable in state
+				Object state=context.getState(source.getFromVariable().getName());
+				
+				if (state instanceof Variable) {
+					ret.setFromVariable((Variable)state);
+				}
+			}
+			
+			if (source.getToVariable() != null) {
+				
+				// Find variable in state
+				Object state=context.getState(source.getToVariable().getName());
+				
+				if (state instanceof Variable) {
+					ret.setToVariable((Variable)state);
+				}
+			}
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/ConversationModelProjectorRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/ConversationModelProjectorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/ConversationModelProjectorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,124 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 11 Jan 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.projector;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.projector.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class provides the ConversationModel implementation of the
+ * projector rule.
+ */
+ at RegistryInfo(extension=ProjectorRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class ConversationModelProjectorRule extends ModelProjectorRule {
+
+	/**
+	 * This method creates the model instance being projected.
+	 * 
+	 * @return The new model
+	 */
+	protected Model createModel() {
+		return(new ConversationModel());
+	}
+		
+	/**
+	 * This method determines whether the projection rule is
+	 * appropriate for the supplied model object.
+	 * 
+	 * @param obj The model object to be projected
+	 * @return Whether the rule is relevant for the
+	 * 				model object
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj.getClass() == ConversationModel.class);
+	}
+	
+	/**
+	 * This method projects the supplied model object based on the
+	 * specified role.
+	 * 
+	 * @param model The model object
+	 * @param role The role
+	 * @param l The model listener
+	 * @return The projected model object
+	 */
+	public ModelObject project(ProjectorContext context, ModelObject model,
+					Role role, ModelListener l) {
+		ConversationModel ret=(ConversationModel)super.project(context,
+						model, role, l);
+		ConversationModel source=(ConversationModel)model;
+		
+		ret.derivedFrom(source);
+		
+		// Project the identity locators
+		for (int i=0; i < source.getIdentityLocators().size(); i++) {
+			IdentityLocator locator=(IdentityLocator)
+					context.project(source.getIdentityLocators().get(i),
+							role, l);
+			
+			if (locator != null) {
+				ret.getIdentityLocators().add(locator);
+			}
+		}
+		
+		Conversation conversation=null;
+		
+		if (source.getConversation() != null) {
+			Conversation conv=source.getConversation();
+			
+			// Check if sub-definition should be projected
+			if (context.getSubDefinitionPath() != null) {
+				conv = (Conversation)conv.getSubDefinition(context.getSubDefinitionPath());
+			}
+			
+			/*
+			for (int i=0; conv != null && 
+					i < context.getSubDefinitionPath().getPathElementCount(); i++) {
+				Definition defn=conv.getSubDefinition(context.getSubDefinitionPath().getPathElement(i));
+				
+				if (defn instanceof Conversation) {
+					conv = (Conversation)defn;
+				}
+			}
+			*/
+			
+			if (conv != null) {
+				conversation = (Conversation)context.project(conv,
+					role, l);
+			}
+			
+			if (conversation != null && context.getSubDefinitionPath().getPathElementCount() > 0) {
+				// Add sub-definition path to projected conversation name
+				String name=conversation.getLocatedName().getName();
+				
+				for (int i=0; i < context.getSubDefinitionPath().getPathElementCount(); i++) {
+					name += "$"+context.getSubDefinitionPath().getPathElement(i);
+				}
+			}
+		}
+		
+		ret.setConversation(conversation);
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/ConversationProjectorRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/ConversationProjectorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/ConversationProjectorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,152 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 11 Jan 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.projector;
+
+//import java.util.logging.Logger;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.projector.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class provides the Conversation implementation of the
+ * projector rule.
+ */
+ at RegistryInfo(extension=ProjectorRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class ConversationProjectorRule implements ProjectorRule {
+
+	/**
+	 * This method determines whether the projection rule is
+	 * appropriate for the supplied model object.
+	 * 
+	 * @param obj The model object to be projected
+	 * @return Whether the rule is relevant for the
+	 * 				model object
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj.getClass() == Conversation.class);
+	}
+	
+	/**
+	 * This method projects the supplied model object based on the
+	 * specified role.
+	 * 
+	 * @param model The model object
+	 * @param role The role
+	 * @param l The model listener
+	 * @return The projected model object
+	 */
+	public ModelObject project(ProjectorContext context, ModelObject model,
+					Role role, ModelListener l) {
+		Activity ret=null;
+		Conversation source=(Conversation)model;
+		java.util.List<Role> roles=null;
+		
+		if (context.isOuterScope() ||
+				(roles=context.getRolesOfInterestForDefinition(source)) != null) {
+			
+			if (roles == null) {
+				roles = new java.util.Vector<Role>();
+				roles.add(role);
+			}
+			
+			for (int j=0; j < roles.size(); j++) {
+				Conversation conv = new Conversation();
+				
+				// Set current role
+				role = roles.get(j);
+				
+				conv.derivedFrom(source);
+				conv.setStateless(source.isStateless());
+				
+				// Project model name
+				LocatedName modelName=(LocatedName)
+						context.project(source.getLocatedName(),
+								role, l);
+				conv.setLocatedName(modelName);
+				
+				// Project 'implements' references
+				for (int i=0; i < source.getImplements().size(); i++) {
+					ImplementsReference ref=source.getImplements().get(i);
+					
+					ImplementsReference projectedRef=
+						(ImplementsReference)context.project(ref,
+								role, l);
+					
+					if (projectedRef != null) {
+						conv.getImplements().add(projectedRef);
+					}
+				}
+				
+				// Project 'conforms to' references
+				for (int i=0; i < source.getConformsTo().size(); i++) {
+					ConformanceReference ref=source.getConformsTo().get(i);
+					
+					ConformanceReference projectedRef=
+						(ConformanceReference)context.project(ref,
+								role, l);
+					
+					if (projectedRef != null) {
+						conv.getConformsTo().add(projectedRef);
+					}
+				}
+				
+				// Project 'identities' references
+				for (int i=0; i < source.getIdentities().size(); i++) {
+					Identity id=source.getIdentities().get(i);
+					
+					Identity projectedId=
+						(Identity)context.project(id, role,
+								l);
+					
+					if (projectedId != null) {
+						conv.getIdentities().add(projectedId);
+					}
+				}
+				
+				// Project activities
+				context.pushScope();
+				
+				conv.setBlock((Block)context.project(source.getBlock(),
+							role, l));
+				conv.getBlock().setParent(conv);
+						
+				context.popScope();
+				
+				if (ret == null) {
+					ret = conv;
+				} else if (ret instanceof Block) {
+					((Block)ret).getContents().add(conv);
+				} else {
+					Block b=new Block();
+					b.getContents().add(ret);
+					b.getContents().add(conv);
+					ret = b;
+				}
+			}
+		}
+
+		return(ret);
+	}
+	
+	//private static Logger logger = Logger.getLogger("org.scribble.conversation.projector");
+}

Added: trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/ConversationReferenceProjectorRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/ConversationReferenceProjectorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/ConversationReferenceProjectorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 19 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.conversation.projector;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.projector.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class provides the ConversationReference implementation of the
+ * projector rule.
+ */
+ at RegistryInfo(extension=ProjectorRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class ConversationReferenceProjectorRule extends ModelReferenceProjectorRule {
+
+	/**
+	 * This is the default constructor.
+	 */
+	public ConversationReferenceProjectorRule() {
+		super(true);
+	}
+	
+	/**
+	 * This method determines whether the projection rule is
+	 * appropriate for the supplied model object.
+	 * 
+	 * @param obj The model object to be projected
+	 * @return Whether the rule is relevant for the
+	 * 				model object
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj.getClass() == ConversationReference.class);
+	}
+	
+	/**
+	 * This method returns the new reference instance.
+	 * 
+	 * @param source The source reference
+	 * @return The model reference
+	 */
+	protected ModelReference createReference(ModelReference source) {
+		return(new ConversationReference());
+	}
+	
+	/**
+	 * This method projects the supplied model object based on the
+	 * specified role.
+	 * 
+	 * @param model The model object
+	 * @param role The role
+	 * @param l The model listener
+	 * @return The projected model object
+	 */
+	public ModelObject project(ProjectorContext context, ModelObject model,
+					Role role, ModelListener l) {
+		ConversationReference ret=(ConversationReference)super.project(context,
+									model, role, l);
+		
+		if (ret != null) {
+			ret.setInner(((ConversationReference)model).isInner());
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/IdentityLocatorProjectorRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/IdentityLocatorProjectorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/IdentityLocatorProjectorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 31 Jul 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.projector;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.projector.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class provides the IdentityLocator implementation of the
+ * projector rule.
+ */
+ at RegistryInfo(extension=ProjectorRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class IdentityLocatorProjectorRule implements ProjectorRule {
+
+	/**
+	 * This method determines whether the projection rule is
+	 * appropriate for the supplied model object.
+	 * 
+	 * @param obj The model object to be projected
+	 * @return Whether the rule is relevant for the
+	 * 				model object
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj.getClass() == IdentityLocator.class);
+	}
+	
+	/**
+	 * This method projects the supplied model object based on the
+	 * specified role.
+	 * 
+	 * @param model The model object
+	 * @param role The role
+	 * @param l The model listener
+	 * @return The projected model object
+	 */
+	public ModelObject project(ProjectorContext context, ModelObject model,
+					Role role, ModelListener l) {
+		IdentityLocator ret=new IdentityLocator();
+		IdentityLocator source=(IdentityLocator)model;
+		
+		ret.derivedFrom(source);
+
+		ret.setType((TypeReference)context.project(
+				source.getType(), role, l));
+		
+		for (int i=0; i < source.getNumberOfLocators(); i++) {
+			ret.setLocator(source.getIdentity(i),
+					source.getLocator(i));
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/IdentityProjectorRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/IdentityProjectorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/IdentityProjectorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 31 Jul 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.projector;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.projector.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class provides the Identity implementation of the
+ * projector rule.
+ */
+ at RegistryInfo(extension=ProjectorRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class IdentityProjectorRule implements ProjectorRule {
+
+	/**
+	 * This method determines whether the projection rule is
+	 * appropriate for the supplied model object.
+	 * 
+	 * @param obj The model object to be projected
+	 * @return Whether the rule is relevant for the
+	 * 				model object
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj.getClass() == Identity.class);
+	}
+	
+	/**
+	 * This method projects the supplied model object based on the
+	 * specified role.
+	 * 
+	 * @param model The model object
+	 * @param role The role
+	 * @param l The model listener
+	 * @return The projected model object
+	 */
+	public ModelObject project(ProjectorContext context, ModelObject model,
+					Role role, ModelListener l) {
+		Identity ret=new Identity();
+		Identity source=(Identity)model;
+		
+		ret.derivedFrom(source);
+
+		ret.setIdentityType(source.getIdentityType());
+		ret.getNames().addAll(source.getNames());
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/IfProjectorRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/IfProjectorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/IfProjectorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 1 Feb 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.projector;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.projector.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class provides the If implementation of the
+ * projector rule.
+ */
+ at RegistryInfo(extension=ProjectorRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class IfProjectorRule implements ProjectorRule {
+
+	/**
+	 * This method determines whether the projection rule is
+	 * appropriate for the supplied model object.
+	 * 
+	 * @param obj The model object to be projected
+	 * @return Whether the rule is relevant for the
+	 * 				model object
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj.getClass() == If.class);
+	}
+	
+	/**
+	 * This method projects the supplied model object based on the
+	 * specified role.
+	 * 
+	 * @param model The model object
+	 * @param role The role
+	 * @param l The model listener
+	 * @return The projected model object
+	 */
+	public ModelObject project(ProjectorContext context, ModelObject model,
+					Role role, ModelListener l) {
+		If ret=new If();
+		If source=(If)model;
+
+		ret.derivedFrom(source);
+		
+		// Project the list of roles
+		for (int i=0; i < source.getRoles().size(); i++) {
+			ret.getRoles().add(new Role(source.getRoles().get(i)));
+		}
+		
+		for (int i=0; i < source.getConditionalBlocks().size(); i++) {
+			ConditionalBlock block=(ConditionalBlock)
+					context.project(source.getConditionalBlocks().get(i),
+							role, l);
+			
+			if (block != null) {
+				ret.getConditionalBlocks().add(block);
+			}
+		}
+		
+		if (source.getElseBlock() != null) {
+			ret.setElseBlock((Block)
+					context.project(source.getElseBlock(),
+							role, l));
+		}
+		
+		// Check if choice has atleast one path
+		if (ret.getConditionalBlocks().size() == 0 &&
+				ret.getElseBlock() == null) {
+			ret = null;
+		}
+		
+		// TODO: Need to cater for optional paths
+
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/InterruptBlockProjectorRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/InterruptBlockProjectorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/InterruptBlockProjectorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 19 Oct 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.projector;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.projector.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class provides the InterruptBlock implementation of the
+ * projector rule.
+ */
+ at RegistryInfo(extension=ProjectorRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class InterruptBlockProjectorRule extends AbstractBlockProjectorRule {
+
+	/**
+	 * This method determines whether the projection rule is
+	 * appropriate for the supplied model object.
+	 * 
+	 * @param obj The model object to be projected
+	 * @return Whether the rule is relevant for the
+	 * 				model object
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj.getClass() == InterruptBlock.class);
+	}
+	
+	/**
+	 * This method creates a new block of the appropriate
+	 * type.
+	 * 
+	 * @return The block
+	 */
+	protected Block createBlock() {
+		return(new InterruptBlock());
+	}
+	
+	/**
+	 * This method projects the supplied model object based on the
+	 * specified role.
+	 * 
+	 * @param model The model object
+	 * @param role The role
+	 * @param l The model listener
+	 * @return The projected model object
+	 */
+	public ModelObject project(ProjectorContext context, ModelObject model,
+					Role role, ModelListener l) {
+		InterruptBlock ret=(InterruptBlock)super.project(context,
+				model, role, l);
+		InterruptBlock source=(InterruptBlock)model;
+
+		// If block not projected, then if projected role is in
+		// the list, the re-instate
+		if (ret == null && source.getRoles().contains(role)) {
+			ret = new InterruptBlock();
+			
+			ret.derivedFrom(source);
+		}
+		
+		if (ret != null) {
+			
+			// Project the list of roles
+			for (int i=0; i < source.getRoles().size(); i++) {
+				ret.getRoles().add(new Role(source.getRoles().get(i)));
+			}
+			
+			if (source.getExpression() != null) {
+				ret.setExpression((Expression)
+						context.project(source.getExpression(),
+								role, l));
+			}
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/ParallelProjectorRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/ParallelProjectorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/ParallelProjectorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 9 Mar 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.projector;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.projector.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class provides the Parallel implementation of the
+ * projector rule.
+ */
+ at RegistryInfo(extension=ProjectorRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class ParallelProjectorRule implements ProjectorRule {
+
+	/**
+	 * This method determines whether the projection rule is
+	 * appropriate for the supplied model object.
+	 * 
+	 * @param obj The model object to be projected
+	 * @return Whether the rule is relevant for the
+	 * 				model object
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj.getClass() == Parallel.class);
+	}
+	
+	/**
+	 * This method projects the supplied model object based on the
+	 * specified role.
+	 * 
+	 * @param model The model object
+	 * @param role The role
+	 * @param l The model listener
+	 * @return The projected model object
+	 */
+	public ModelObject project(ProjectorContext context, ModelObject model,
+					Role role, ModelListener l) {
+		ModelObject ret=null;
+		Parallel parallel=new Parallel();
+		Parallel source=(Parallel)model;
+		
+		parallel.derivedFrom(source);
+
+		for (int i=0; i < source.getBlocks().size(); i++) {
+			Block block=(Block)
+					context.project(source.getBlocks().get(i),
+							role, l);
+			
+			if (block != null) {
+				parallel.getBlocks().add(block);
+			}
+		}
+		
+		// Check if parallel has atleast one path
+		if (parallel.getBlocks().size() > 0) {
+			ret = parallel;
+			
+			// If parallel only has one path, then
+			// return block
+			if (parallel.getBlocks().size() == 1) {
+				ret = parallel.getBlocks().get(0);
+			}
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/RaiseProjectorRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/RaiseProjectorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/RaiseProjectorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 10 Nov 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.projector;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.projector.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class provides the Raise implementation of the
+ * projector rule.
+ */
+ at RegistryInfo(extension=ProjectorRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class RaiseProjectorRule implements ProjectorRule {
+
+	/**
+	 * This method determines whether the projection rule is
+	 * appropriate for the supplied model object.
+	 * 
+	 * @param obj The model object to be projected
+	 * @return Whether the rule is relevant for the
+	 * 				model object
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj.getClass() == Raise.class);
+	}
+
+	/**
+	 * This method projects the supplied model object based on the
+	 * specified role.
+	 * 
+	 * @param model The model object
+	 * @param role The role
+	 * @param l The model listener
+	 * @return The projected model object
+	 */
+	public ModelObject project(ProjectorContext context, ModelObject model,
+					Role role, ModelListener l) {
+		Raise ret=null;
+		Raise raise=(Raise)model;
+		
+		if (raise.getRoles().contains(role)) {
+			ret = new Raise();
+			
+			ret.derivedFrom(raise);
+			
+			ret.getRoles().add(new Role(role));
+			
+			ret.setType((TypeReference)context.project(raise.getType(),
+					role, l));
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/RunProjectorRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/RunProjectorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/RunProjectorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 9 Mar 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.projector;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.projector.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class provides the Run implementation of the
+ * projector rule.
+ */
+ at RegistryInfo(extension=ProjectorRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class RunProjectorRule extends ComposeProjectorRule {
+
+	/**
+	 * This method determines whether the projection rule is
+	 * appropriate for the supplied model object.
+	 * 
+	 * @param obj The model object to be projected
+	 * @return Whether the rule is relevant for the
+	 * 				model object
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj.getClass() == Run.class);
+	}
+	
+	/**
+	 * This method creates the model include object being projected.
+	 * 
+	 * @return The model include
+	 */
+	protected ModelInclude createModelInclude() {
+		return(new Run());
+	}
+}

Added: trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/SpawnProjectorRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/SpawnProjectorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/SpawnProjectorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 7 Aug 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.projector;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.projector.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class provides the Spawn implementation of the
+ * projector rule.
+ */
+ at RegistryInfo(extension=ProjectorRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class SpawnProjectorRule extends ComposeProjectorRule {
+
+	/**
+	 * This method determines whether the projection rule is
+	 * appropriate for the supplied model object.
+	 * 
+	 * @param obj The model object to be projected
+	 * @return Whether the rule is relevant for the
+	 * 				model object
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj.getClass() == Spawn.class);
+	}
+	
+	/**
+	 * This method creates the model include object being projected.
+	 * 
+	 * @return The model include
+	 */
+	protected ModelInclude createModelInclude() {
+		return(new Spawn());
+	}
+}

Added: trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/TryEscapeProjectorRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/TryEscapeProjectorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/TryEscapeProjectorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 19 Oct 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.projector;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.projector.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class provides the TryEscape implementation of the
+ * projector rule.
+ */
+ at RegistryInfo(extension=ProjectorRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class TryEscapeProjectorRule implements ProjectorRule {
+
+	/**
+	 * This method determines whether the projection rule is
+	 * appropriate for the supplied model object.
+	 * 
+	 * @param obj The model object to be projected
+	 * @return Whether the rule is relevant for the
+	 * 				model object
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj.getClass() == TryEscape.class);
+	}
+	
+	/**
+	 * This method projects the supplied model object based on the
+	 * specified role.
+	 * 
+	 * @param model The model object
+	 * @param role The role
+	 * @param l The model listener
+	 * @return The projected model object
+	 */
+	public ModelObject project(ProjectorContext context, ModelObject model,
+					Role role, ModelListener l) {
+		TryEscape ret=new TryEscape();
+		TryEscape source=(TryEscape)model;
+
+		ret.derivedFrom(source);
+
+		// Project the try block
+		Block tryBlock=(Block)
+				context.project(source.getBlock(), role, l);
+		
+		if (tryBlock != null && tryBlock.getContents().size() > 0) {
+			ret.setBlock(tryBlock);
+		}
+		
+		for (int i=0; i < source.getEscapeBlocks().size(); i++) {
+			EscapeBlock block=(EscapeBlock)
+					context.project(source.getEscapeBlocks().get(i),
+							role, l);
+			
+			if (block != null) {
+				ret.getEscapeBlocks().add(block);
+			}
+		}
+		
+		// Check if choice has atleast one path
+		if (ret.getBlock().getContents().size() == 0 &&
+				ret.getEscapeBlocks().size() == 0) {
+			ret = null;
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/VariableListProjectorRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/VariableListProjectorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/VariableListProjectorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 25 Jan, 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.projector;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.conversation.model.*;
+import org.scribble.projector.*;
+
+/**
+ * This class provides the VariableList implementation of the
+ * projector rule.
+ */
+ at RegistryInfo(extension=ProjectorRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class VariableListProjectorRule extends InteractionProjectorRule {
+
+	/**
+	 * This method determines whether the projection rule is
+	 * appropriate for the supplied model object.
+	 * 
+	 * @param obj The model object to be projected
+	 * @return Whether the rule is relevant for the
+	 * 				model object
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj.getClass() == VariableList.class);
+	}
+	
+	/**
+	 * This method projects the supplied model object based on the
+	 * specified role.
+	 * 
+	 * @param model The model object
+	 * @param role The role
+	 * @param l The model listener
+	 * @return The projected model object
+	 */
+	public ModelObject project(ProjectorContext context, ModelObject model,
+					Role role, ModelListener l) {
+		VariableList ret=new VariableList();
+		VariableList source=(VariableList)model;
+
+		ret.setType(source.getType());
+
+		for (int i=0; i < source.getVariables().size(); i++) {
+			Variable var=source.getVariables().get(i);
+			
+			Variable newVar=new Variable();
+			newVar.setName(var.getName());
+			
+			if (var.getType() != null) {
+				TypeReference ref=new TypeReference();
+				ref.setLocalpart(var.getType().getLocalpart());
+				ref.setNamespace(var.getType().getNamespace());
+			}
+			
+			ret.getVariables().add(newVar);
+			
+			context.setState(newVar.getName(), newVar);
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/WhenProjectorRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/WhenProjectorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/WhenProjectorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 9 Mar 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.projector;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.projector.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class provides the When implementation of the
+ * projector rule.
+ */
+ at RegistryInfo(extension=ProjectorRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class WhenProjectorRule implements ProjectorRule {
+
+	/**
+	 * This method determines whether the projection rule is
+	 * appropriate for the supplied model object.
+	 * 
+	 * @param obj The model object to be projected
+	 * @return Whether the rule is relevant for the
+	 * 				model object
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj.getClass() == When.class);
+	}
+	
+	/**
+	 * This method projects the supplied model object based on the
+	 * specified role.
+	 * 
+	 * @param model The model object
+	 * @param role The role
+	 * @param l The model listener
+	 * @return The projected model object
+	 */
+	public ModelObject project(ProjectorContext context, ModelObject model,
+					Role role, ModelListener l) {
+		When ret=new When();
+		When source=(When)model;
+
+		ret.derivedFrom(source);
+		
+		// Project the list of roles
+		for (int i=0; i < source.getRoles().size(); i++) {
+			ret.getRoles().add(new Role(source.getRoles().get(i)));
+		}
+		
+		for (int i=0; i < source.getConditionalBlocks().size(); i++) {
+			ConditionalBlock block=(ConditionalBlock)
+					context.project(source.getConditionalBlocks().get(i),
+							role, l);
+			
+			if (block != null) {
+				ret.getConditionalBlocks().add(block);
+			}
+		}
+		
+		// Check if choice has atleast one path
+		if (ret.getConditionalBlocks().size() == 0) {
+			ret = null;
+		}
+		
+		// TODO: Need to cater for optional paths
+
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/WhileProjectorRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/WhileProjectorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/WhileProjectorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 9 Mar 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.projector;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.conversation.model.*;
+import org.scribble.projector.*;
+
+/**
+ * This class provides the While implementation of the
+ * projector rule.
+ */
+ at RegistryInfo(extension=ProjectorRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class WhileProjectorRule implements ProjectorRule {
+
+	/**
+	 * This method determines whether the projection rule is
+	 * appropriate for the supplied model object.
+	 * 
+	 * @param obj The model object to be projected
+	 * @return Whether the rule is relevant for the
+	 * 				model object
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj.getClass() == While.class);
+	}
+	
+	/**
+	 * This method projects the supplied model object based on the
+	 * specified role.
+	 * 
+	 * @param model The model object
+	 * @param role The role
+	 * @param l The model listener
+	 * @return The projected model object
+	 */
+	public ModelObject project(ProjectorContext context, ModelObject model,
+					Role role, ModelListener l) {
+		While ret=new While();
+		While source=(While)model;
+
+		ret.derivedFrom(source);
+		
+		// Project the list of roles
+		for (int i=0; i < source.getRoles().size(); i++) {
+			ret.getRoles().add(new Role(source.getRoles().get(i)));
+		}
+		
+		if (ret != null && source.getBlock() != null) {
+			
+			// Project the conditional block
+			ret.setBlock((ConditionalBlock)
+					context.project(source.getBlock(),
+								role, l));
+			
+			// If block is null, then no activities, so don't
+			// project the while
+			if (ret.getBlock() == null) {
+				ret = null;
+			} else {
+				ret.getBlock().setParent(ret);
+			}
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/osgi/Activator.java
===================================================================
--- trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/osgi/Activator.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.projector/src/main/java/org/scribble/conversation/projector/osgi/Activator.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,48 @@
+package org.scribble.conversation.projector.osgi;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator implements BundleActivator {
+
+	// The plug-in ID
+	public static final String PLUGIN_ID = "org.scribble.conversation.projector";
+
+	// The shared instance
+	private static Activator plugin;
+	
+	/**
+	 * The constructor
+	 */
+	public Activator() {
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
+	 */
+	public void start(BundleContext context) throws Exception {
+		plugin = this;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
+	 */
+	public void stop(BundleContext context) throws Exception {
+		plugin = null;
+	}
+
+	/**
+	 * Returns the shared instance
+	 *
+	 * @return the shared instance
+	 */
+	public static Activator getDefault() {
+		return plugin;
+	}
+
+}

Added: trunk/bundles/org.scribble.conversation.validation/.classpath
===================================================================
--- trunk/bundles/org.scribble.conversation.validation/.classpath	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.validation/.classpath	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src/main/java"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="output" path="classes"/>
+</classpath>

Added: trunk/bundles/org.scribble.conversation.validation/.project
===================================================================
--- trunk/bundles/org.scribble.conversation.validation/.project	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.validation/.project	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.scribble.conversation.validation</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.ManifestBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.SchemaBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.pde.PluginNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

Added: trunk/bundles/org.scribble.conversation.validation/LICENSE.txt
===================================================================
--- trunk/bundles/org.scribble.conversation.validation/LICENSE.txt	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.validation/LICENSE.txt	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,201 @@
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   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.

Added: trunk/bundles/org.scribble.conversation.validation/META-INF/MANIFEST.MF
===================================================================
--- trunk/bundles/org.scribble.conversation.validation/META-INF/MANIFEST.MF	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.validation/META-INF/MANIFEST.MF	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,26 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Scribble Conversation Validation Plug-in
+Bundle-SymbolicName: org.scribble.conversation.validation;singleton:=true
+Bundle-Version: 1.2.0.qualifier
+Bundle-Activator: org.scribble.conversation.validation.osgi.Activator
+Bundle-Vendor: www.scribble.org
+Import-Package: org.osgi.framework;version="1.3.0"
+Require-Bundle: org.scribble.core;bundle-version="[1.0.0,2.0.0)",
+ org.scribble.conversation.model;bundle-version="[1.0.0,2.0.0)"
+Bundle-ActivationPolicy: lazy
+Scribble-Extensions: org.scribble.conversation.validation.ConversationModelValidationRule,
+  org.scribble.conversation.validation.BehaviourValidationRule,
+  org.scribble.conversation.validation.ConversationValidationRule,
+  org.scribble.conversation.validation.ConversationInteractionValidationRule,
+  org.scribble.conversation.validation.ConditionalBlockValidationRule,
+  org.scribble.conversation.validation.IfValidationRule,
+  org.scribble.conversation.validation.ParallelValidationRule,
+  org.scribble.conversation.validation.WhenValidationRule,
+  org.scribble.conversation.validation.WhileValidationRule,
+  org.scribble.conversation.validation.VariableListValidationRule,
+  org.scribble.conversation.validation.VariableValidationRule,
+  org.scribble.conversation.validation.TryEscapeValidationRule,
+  org.scribble.conversation.validation.RaiseValidationRule,
+  org.scribble.conversation.validation.ComposeValidationRule
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6

Added: trunk/bundles/org.scribble.conversation.validation/build.properties
===================================================================
--- trunk/bundles/org.scribble.conversation.validation/build.properties	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.validation/build.properties	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,5 @@
+source.. = src/main/java/
+output.. = classes/
+bin.includes = META-INF/,\
+               .,\
+               plugin.xml

Added: trunk/bundles/org.scribble.conversation.validation/pom.xml
===================================================================
--- trunk/bundles/org.scribble.conversation.validation/pom.xml	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.validation/pom.xml	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,33 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  	<modelVersion>4.0.0</modelVersion>
+	<groupId>org.savara.bundles</groupId>
+	<artifactId>org.scribble.conversation.validation</artifactId> 
+	<version>1.2.0-SNAPSHOT</version>
+	<packaging>jar</packaging>
+	<name>Savara::Bundles::ScribbleConversationValidation</name>
+
+	<parent>
+		<groupId>org.savara</groupId>
+		<artifactId>bundles</artifactId>
+		<version>1.2.0-SNAPSHOT</version>
+	</parent>
+  
+	<dependencies>
+		<dependency>
+			<groupId>org.savara.bundles</groupId>
+			<artifactId>org.scribble.core</artifactId>
+			<version>1.2.0-SNAPSHOT</version>
+		</dependency>
+		<dependency>
+			<groupId>org.savara.bundles</groupId>
+			<artifactId>org.scribble.conversation.model</artifactId>
+			<version>1.2.0-SNAPSHOT</version>
+		</dependency>
+	    <dependency>
+	      <groupId>org.apache.felix</groupId>
+	      <artifactId>org.osgi.core</artifactId>
+	      <version>${osgi.version}</version>
+	    </dependency>
+	</dependencies>
+</project>

Added: trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/BehaviourValidationRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/BehaviourValidationRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/BehaviourValidationRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,117 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 14 Nov 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.validation;
+
+import org.scribble.validation.*;
+import org.scribble.extensions.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class implements the validation rule for the
+ * Behaviour abstract entity.
+ */
+ at RegistryInfo(extension=ValidationRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class BehaviourValidationRule extends AbstractValidationRule {
+
+	/**
+	 * This is the default constructor.
+	 */
+	public BehaviourValidationRule() {
+	}
+
+	/**
+	 * This method determines whether the rule is appropriate for
+	 * the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @return Whether the rule is appropriate
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj instanceof Behaviour);
+	}
+
+	/**
+	 * This method validates the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @param context The context
+	 * @param l The listener
+	 */
+	public void validate(ModelObject obj, ValidationContext context,
+			ModelListener l) {
+		Behaviour behaviour=(Behaviour)obj;
+
+		Definition enclosing=behaviour.getEnclosingDefinition();
+		
+		if (enclosing != null) {
+			Definition toplevel=enclosing.getTopLevelDefinition();
+			
+			// Check if the behaviour is a wait state in
+			// a stateless conversation
+			if (toplevel != null &&
+					toplevel.isStateless() &&
+					behaviour.isWaitState()) {
+				boolean f_error=false;
+				
+				// Make sure the behaviour is the first behaviour
+				// in one of the stateless conversation paths
+				if (behaviour.getParent() instanceof Block &&
+						behaviour.getParent().getParent()
+								instanceof If &&
+						behaviour.getParent().getParent().getParent()
+								instanceof Block &&
+						behaviour.getParent().getParent().getParent().getParent()
+								== toplevel) {
+					
+					// Find position
+					Block block=(Block)behaviour.getParent();
+					
+					int pos=block.getContents().indexOf(behaviour);
+					
+					for (int i=0; f_error == false && i < pos; i++) {
+						if (block.getContents().get(i) instanceof Behaviour) {
+							f_error = true;
+						}
+					}
+					
+				// Make sure behaviour being referred to is not the
+				// 'if' construct contained directly within the
+				// stateless conversation
+				} else if ((behaviour.getParent() instanceof Block)
+									== false ||
+						behaviour.getParent().getParent()
+									!= toplevel) {
+					f_error = true;
+				}
+				
+				if (f_error) {
+					l.error(new ModelIssue(behaviour, org.scribble.util.MessageUtil.format(
+							java.util.PropertyResourceBundle.getBundle(
+							"org.scribble.conversation.validation.Messages"),
+								"_STATELESS_WAIT_STATE_NOT_FIRST_BEHAVIOUR",
+								new String[]{})));					
+				}
+			}
+		}
+	}
+}

Added: trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/ComposeValidationRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/ComposeValidationRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/ComposeValidationRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 9 Mar 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.validation;
+
+import org.scribble.validation.*;
+import org.scribble.extensions.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class implements the validation rule for the
+ * compose construct.
+ */
+ at RegistryInfo(extension=ValidationRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class ComposeValidationRule extends AbstractValidationRule {
+
+	/**
+	 * This is the default constructor.
+	 */
+	public ComposeValidationRule() {
+	}
+
+	/**
+	 * This method determines whether the rule is appropriate for
+	 * the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @return Whether the rule is appropriate
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj instanceof Compose);
+	}
+
+	/**
+	 * This method validates the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @param context The context
+	 * @param l The listener
+	 */
+	public void validate(ModelObject obj, ValidationContext context,
+			ModelListener l) {
+		Compose compose=(Compose)obj;
+		
+		Conversation conv=compose.getDefinition();
+		
+		// Validate bound parameters
+		java.util.Iterator<DeclarationBinding> iter=
+					compose.getBindings().iterator();
+		
+		while (iter.hasNext()) {
+			DeclarationBinding db=iter.next();
+			
+			// Check if bound declaration exists
+			Declaration other=conv.getDeclaration(db.getBoundName());
+			
+			if (other == null) {
+				String name=compose.getReference().getAlias();
+				
+				if (compose.getReference().getLocatedRole() != null) {
+					name += ModelReference.LOCATED_REFERENCE_SEPARATOR+
+								compose.getReference().getLocatedRole();
+				}
+								
+				l.error(new ModelIssue(db, org.scribble.util.MessageUtil.format(
+						java.util.PropertyResourceBundle.getBundle(
+						"org.scribble.validation.Messages"),
+							"_NOT_FOUND_BOUND_DECLARATION",
+							new String[]{db.getBoundName(), name})));
+			} else {
+				// TODO:
+				// Check if the two declarations are compatible
+				// types
+			}
+		}
+	}
+}

Added: trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/ConditionalBlockValidationRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/ConditionalBlockValidationRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/ConditionalBlockValidationRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 13 Mar 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.validation;
+
+import org.scribble.validation.*;
+import org.scribble.extensions.*;
+import org.scribble.model.*;
+import org.scribble.model.types.*;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class implements the validation rule for the
+ * ConditionalBlock construct.
+ */
+ at RegistryInfo(extension=ValidationRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class ConditionalBlockValidationRule extends AbstractValidationRule {
+
+	/**
+	 * This is the default constructor.
+	 */
+	public ConditionalBlockValidationRule() {
+	}
+
+	/**
+	 * This method determines whether the rule is appropriate for
+	 * the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @return Whether the rule is appropriate
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj instanceof ConditionalBlock);
+	}
+
+	/**
+	 * This method validates the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @param context The context
+	 * @param l The listener
+	 */
+	public void validate(ModelObject obj, ValidationContext context,
+			ModelListener l) {
+		ConditionalBlock elem=(ConditionalBlock)obj;
+
+		// Only need to validate the expression, as the
+		// validation of the contained activities will be
+		// handled by the Block validation rule
+		
+		/* TODO: UNCOMMENT WHEN SUITABLE TYPE RESOLVERS
+		 * ARE AVAILABLE FOR CDM (CDL Expressions)
+		 *
+		if (elem.getExpression() != null) {
+			java.util.Set<TypeInformation> typeInfos=null;
+		
+			// Validate expression
+			context.validate(elem.getExpression(), l);
+			
+			TypeResolver typeResolver=(TypeResolver)
+				org.scribble.extensions.RegistryFactory.getRegistry().getExtension(
+							TypeResolver.class, null);
+
+			if (typeResolver != null) {
+				typeInfos = typeResolver.getTypeInformation(elem.getExpression());
+			}
+
+			// Validate that expression's type is a boolean
+			if (typeInfos == null || typeInfos.size() == 0) {
+				l.error(new ModelIssue(elem, org.scribble.util.MessageUtil.format(
+						java.util.PropertyResourceBundle.getBundle(
+							"org.scribble.conversation.validation.Messages"),
+								"_EXPRESSION_BOOLEAN", new String[]{})));
+			} else {
+				
+				java.util.Iterator<TypeInformation> iter=typeInfos.iterator();
+				
+				while (iter.hasNext()) {
+					TypeInformation ti=iter.next();
+					
+					if (ti.isBoolean() == false) {
+						l.error(new ModelIssue(elem, org.scribble.util.MessageUtil.format(
+							java.util.PropertyResourceBundle.getBundle(
+									"org.scribble.conversation.validation.Messages"),
+										"_EXPRESSION_TYPE_NOT_BOOLEAN",
+										new String[]{ti.getTypeSystem().getName()})));
+					}
+				}
+			}
+		}
+		*/
+	}
+}

Added: trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/ConversationInteractionValidationRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/ConversationInteractionValidationRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/ConversationInteractionValidationRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 13 Mar 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.validation;
+
+import org.scribble.validation.*;
+import org.scribble.extensions.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class implements the validation rule for the
+ * ConversationInteraction construct.
+ */
+ at RegistryInfo(extension=ValidationRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class ConversationInteractionValidationRule extends AbstractValidationRule {
+
+	/**
+	 * This is the default constructor.
+	 */
+	public ConversationInteractionValidationRule() {
+	}
+
+	/**
+	 * This method determines whether the rule is appropriate for
+	 * the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @return Whether the rule is appropriate
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj instanceof ConversationInteraction);
+	}
+
+	/**
+	 * This method validates the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @param context The context
+	 * @param l The listener
+	 */
+	public void validate(ModelObject obj, ValidationContext context,
+			ModelListener l) {
+		ConversationInteraction interaction=(ConversationInteraction)obj;
+		
+		// NOTE: Roles will be validated by the generic interaction
+		// rule
+		
+		// Validate variables:
+		// Check they are the appropriate type
+	}
+}

Added: trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/ConversationModelValidationRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/ConversationModelValidationRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/ConversationModelValidationRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 11 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.conversation.validation;
+
+import org.scribble.validation.*;
+import org.scribble.extensions.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class implements the validation rule for the
+ * conversation.
+ */
+ at RegistryInfo(extension=ValidationRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class ConversationModelValidationRule extends AbstractValidationRule {
+
+	/**
+	 * This is the default constructor.
+	 */
+	public ConversationModelValidationRule() {
+	}
+
+	/**
+	 * This method determines whether the rule is appropriate for
+	 * the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @return Whether the rule is appropriate
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj instanceof ConversationModel);
+	}
+
+	/**
+	 * This method validates the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @param context The context
+	 * @param l The listener
+	 */
+	public void validate(ModelObject obj, ValidationContext context,
+			ModelListener l) {
+		ConversationModel model=(ConversationModel)obj;
+		
+		context.validate(model.getConversation(), l);
+	}
+}

Added: trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/ConversationValidationRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/ConversationValidationRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/ConversationValidationRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,165 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 11 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.conversation.validation;
+
+import org.scribble.validation.*;
+import org.scribble.extensions.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class implements the validation rule for the
+ * conversation.
+ */
+ at RegistryInfo(extension=ValidationRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class ConversationValidationRule extends AbstractValidationRule {
+
+	/**
+	 * This is the default constructor.
+	 */
+	public ConversationValidationRule() {
+	}
+
+	/**
+	 * This method determines whether the rule is appropriate for
+	 * the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @return Whether the rule is appropriate
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj instanceof Conversation);
+	}
+
+	/**
+	 * This method validates the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @param context The context
+	 * @param l The listener
+	 */
+	public void validate(ModelObject obj, ValidationContext context,
+			ModelListener l) {
+		Conversation conversation=(Conversation)obj;
+		
+		// Initialize the located role for the scope
+		if (conversation.getLocatedName() != null &&
+				conversation.getLocatedName().getRole() != null) {
+			context.setLocatedRole(
+					conversation.getLocatedName().getRole().getName());
+		}
+		
+		org.scribble.model.admin.ModelRepository mrep=
+			(org.scribble.model.admin.ModelRepository)
+			RegistryFactory.getRegistry().getExtension(
+					org.scribble.model.admin.ModelRepository.class, null);
+	
+		// Validate that implemented protocols can be located
+		/* GPB: TO REMOVE
+		for (int i=0; i < conversation.getImplements().size(); i++) {
+			ImplementsReference ref=conversation.getImplements().get(i);
+			
+			if (mrep.exists(ref, context.getSource()) == false) {
+				boolean f_error=true;
+				
+				// Check if reference is located, and if so, check whether
+				// global model exists
+				if (ref.getLocatedRole() != null) {
+					ModelReference globalRef=new ModelReference(ref.getNamespace(),
+							ref.getLocalpart(), null, ref.getNotation());
+				
+					mrep.locate(globalRef, ref);
+					
+					// If global model exists, then clear the error
+					if (mrep.exists(globalRef, context.getSource())) {
+						f_error = false;
+					}
+				}
+					
+				if (f_error) {
+					l.error(new ModelIssue(ref, org.scribble.util.MessageUtil.format(
+						java.util.PropertyResourceBundle.getBundle(
+						"org.scribble.conversation.validation.Messages"),
+							"_NOT_FOUND_PROTOCOL_REFERENCE",
+							new String[]{ref.toString()})));
+				}
+			}
+		}
+		*/
+		
+		// Check if conversation is stateless
+		if (conversation.isStateless()) {
+			
+			// Check if top level conversation
+			if (conversation.getParent() instanceof Model) {
+				
+				// Check that conversation is located
+				if (conversation.getLocatedName() == null ||
+						conversation.getLocatedName().getRole() == null) {
+					l.error(new ModelIssue(conversation, org.scribble.util.MessageUtil.format(
+							java.util.PropertyResourceBundle.getBundle(
+							"org.scribble.conversation.validation.Messages"),
+								"_STATELESS_LOCAL_MODEL",
+								new String[]{})));
+				}
+				
+				// Ensure only contains a choice behaviour
+				boolean f_choiceFound=false;
+				
+				java.util.List<Activity> children=
+					conversation.getBlock().getContents();
+				
+				for (int i=0; i < children.size(); i++) {
+					if (children.get(i) instanceof Behaviour) {
+						
+						if (children.get(i) instanceof If) {
+							
+							if (f_choiceFound) {						
+								l.error(new ModelIssue(children.get(i), org.scribble.util.MessageUtil.format(
+										java.util.PropertyResourceBundle.getBundle(
+										"org.scribble.conversation.validation.Messages"),
+											"_STATELESS_CONV_SINGLE_IF",
+											new String[]{})));
+							}
+							
+							f_choiceFound = true;
+						} else {
+							l.error(new ModelIssue(children.get(i), org.scribble.util.MessageUtil.format(
+									java.util.PropertyResourceBundle.getBundle(
+									"org.scribble.conversation.validation.Messages"),
+										"_STATELESS_CONV_SINGLE_IF",
+										new String[]{})));
+						}
+					}
+				}
+			} else {
+				l.error(new ModelIssue(conversation, org.scribble.util.MessageUtil.format(
+						java.util.PropertyResourceBundle.getBundle(
+						"org.scribble.conversation.validation.Messages"),
+							"_STATELESS_ONLY_TOP_LEVEL",
+							new String[]{})));
+			}
+		}
+		
+		context.validate(conversation.getBlock(), l);
+	}
+}

Added: trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/IfValidationRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/IfValidationRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/IfValidationRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 13 Mar 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.validation;
+
+import org.scribble.validation.*;
+import org.scribble.extensions.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class implements the validation rule for the
+ * If construct.
+ */
+ at RegistryInfo(extension=ValidationRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class IfValidationRule extends AbstractValidationRule {
+
+	/**
+	 * This is the default constructor.
+	 */
+	public IfValidationRule() {
+	}
+
+	/**
+	 * This method determines whether the rule is appropriate for
+	 * the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @return Whether the rule is appropriate
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj instanceof If);
+	}
+
+	/**
+	 * This method validates the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @param context The context
+	 * @param l The listener
+	 */
+	public void validate(ModelObject obj, ValidationContext context,
+			ModelListener l) {
+		If elem=(If)obj;
+
+		for (int i=0; i < elem.getConditionalBlocks().size(); i++) {
+			context.validate(elem.getConditionalBlocks().get(i), l);
+		}
+		
+		if (elem.getElseBlock() != null) {
+			context.validate(elem.getElseBlock(), l);
+		}
+	}
+}

Added: trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/Messages.properties
===================================================================
--- trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/Messages.properties	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/Messages.properties	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,28 @@
+# /*
+# * Copyright 2007-8 Pi4 Technologies Ltd
+# *
+# * 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.
+# *
+# *
+# * Change History:
+# * 19 Mar 2008 : Initial version created by gary
+# */
+
+_EXPRESSION_BOOLEAN=Expression must be of type 'boolean'
+_EXPRESSION_TYPE_NOT_BOOLEAN=Expression type, for type system '{0}', is not of type 'boolean'
+_NOT_FOUND_PROTOCOL_REFERENCE=Unable to find description with protocol reference '{0}'
+_RAISED_TYPE_NOT_CAUGHT=Raised type '{0}' is not caught within the enclosing definition
+_STATELESS_CONV_SINGLE_IF=Stateless conversations can only have a single top level If construct defining the alternate paths
+_STATELESS_LOCAL_MODEL=Stateless conversations must be located at a role
+_STATELESS_ONLY_TOP_LEVEL=Only top level conversations can be stateless
+_STATELESS_WAIT_STATE_NOT_FIRST_BEHAVIOUR=Waiting behaviour can only be defined as first in stateless path

Added: trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/ParallelValidationRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/ParallelValidationRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/ParallelValidationRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 13 Mar 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.validation;
+
+import org.scribble.validation.*;
+import org.scribble.extensions.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class implements the validation rule for the
+ * Parallel construct.
+ */
+ at RegistryInfo(extension=ValidationRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class ParallelValidationRule extends AbstractValidationRule {
+
+	/**
+	 * This is the default constructor.
+	 */
+	public ParallelValidationRule() {
+	}
+
+	/**
+	 * This method determines whether the rule is appropriate for
+	 * the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @return Whether the rule is appropriate
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj instanceof Parallel);
+	}
+
+	/**
+	 * This method validates the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @param context The context
+	 * @param l The listener
+	 */
+	public void validate(ModelObject obj, ValidationContext context,
+			ModelListener l) {
+		Parallel elem=(Parallel)obj;
+
+		for (int i=0; i < elem.getBlocks().size(); i++) {
+			context.validate(elem.getBlocks().get(i), l);
+		}
+	}
+}

Added: trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/RaiseValidationRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/RaiseValidationRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/RaiseValidationRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 11 Nov 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.validation;
+
+import org.scribble.validation.*;
+import org.scribble.extensions.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class implements the validation rule for the
+ * Raise construct.
+ */
+ at RegistryInfo(extension=ValidationRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class RaiseValidationRule extends AbstractValidationRule {
+
+	/**
+	 * This is the default constructor.
+	 */
+	public RaiseValidationRule() {
+	}
+
+	/**
+	 * This method determines whether the rule is appropriate for
+	 * the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @return Whether the rule is appropriate
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj instanceof Raise);
+	}
+
+	/**
+	 * This method validates the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @param context The context
+	 * @param l The listener
+	 */
+	public void validate(ModelObject obj, ValidationContext context,
+			ModelListener l) {
+		Raise elem=(Raise)obj;
+
+		if (elem.getType() != null) {
+			boolean f_found=false;
+			
+			// Check that a 'catch' for this type
+			ModelObject act=elem.getParent();
+			
+			while (f_found == false && act != null &&
+					(act instanceof Definition) == false) {
+			
+				if (act instanceof TryEscape) {
+					TryEscape te=(TryEscape)act;
+					
+					for (int i=0; f_found == false &&
+							i < te.getEscapeBlocks().size(); i++) {
+						
+						if (te.getEscapeBlocks().get(i) instanceof CatchBlock &&
+								elem.getType().equals(((CatchBlock)
+									te.getEscapeBlocks().get(i)).getType())) {
+							f_found = true;
+						}
+					}
+				}
+				
+				act = act.getParent();
+			}
+			
+			if (f_found == false) {
+				String text=elem.getType().getAlias();
+				
+				if (elem.getType().getNamespace() != null) {
+					text = "{"+elem.getType().getNamespace()+"}"+text;
+				}
+
+				l.error(new ModelIssue(elem, org.scribble.util.MessageUtil.format(
+						java.util.PropertyResourceBundle.getBundle(
+						"org.scribble.conversation.validation.Messages"),
+							"_RAISED_TYPE_NOT_CAUGHT",
+							new String[]{text})));
+			}
+		}
+	}
+}

Added: trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/TryEscapeValidationRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/TryEscapeValidationRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/TryEscapeValidationRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 11 Nov 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.validation;
+
+import org.scribble.validation.*;
+import org.scribble.extensions.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class implements the validation rule for the
+ * TryEscape construct.
+ */
+ at RegistryInfo(extension=ValidationRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class TryEscapeValidationRule extends AbstractValidationRule {
+
+	/**
+	 * This is the default constructor.
+	 */
+	public TryEscapeValidationRule() {
+	}
+
+	/**
+	 * This method determines whether the rule is appropriate for
+	 * the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @return Whether the rule is appropriate
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj instanceof TryEscape);
+	}
+
+	/**
+	 * This method validates the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @param context The context
+	 * @param l The listener
+	 */
+	public void validate(ModelObject obj, ValidationContext context,
+			ModelListener l) {
+		TryEscape elem=(TryEscape)obj;
+		
+		if (elem.getBlock() != null) {
+			context.validate(elem.getBlock(), l);
+		}
+
+		for (int i=0; i < elem.getEscapeBlocks().size(); i++) {
+			context.validate(elem.getEscapeBlocks().get(i), l);
+		}
+	}
+}

Added: trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/VariableListValidationRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/VariableListValidationRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/VariableListValidationRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 9 Mar 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.validation;
+
+import org.scribble.validation.*;
+import org.scribble.extensions.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class implements the validation rule for the
+ * VariableList construct.
+ */
+ at RegistryInfo(extension=ValidationRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class VariableListValidationRule extends AbstractValidationRule {
+
+	/**
+	 * This is the default constructor.
+	 */
+	public VariableListValidationRule() {
+	}
+
+	/**
+	 * This method determines whether the rule is appropriate for
+	 * the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @return Whether the rule is appropriate
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj instanceof VariableList);
+	}
+
+	/**
+	 * This method validates the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @param context The context
+	 * @param l The listener
+	 */
+	public void validate(ModelObject obj, ValidationContext context,
+			ModelListener l) {
+		VariableList elem=(VariableList)obj;
+
+		if (elem.getType() != null) {
+			context.validate(elem.getType(), l);
+		}
+		
+		for (int i=0; i < elem.getVariables().size(); i++) {
+			context.validate(elem.getVariables().get(i), l);
+		}
+	}
+}

Added: trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/VariableValidationRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/VariableValidationRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/VariableValidationRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 9 Mar 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.validation;
+
+import org.scribble.validation.*;
+import org.scribble.extensions.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class implements the validation rule for the
+ * Variable construct.
+ */
+ at RegistryInfo(extension=ValidationRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class VariableValidationRule extends AbstractValidationRule {
+
+	/**
+	 * This is the default constructor.
+	 */
+	public VariableValidationRule() {
+	}
+
+	/**
+	 * This method determines whether the rule is appropriate for
+	 * the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @return Whether the rule is appropriate
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj instanceof Variable);
+	}
+
+	/**
+	 * This method validates the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @param context The context
+	 * @param l The listener
+	 */
+	public void validate(ModelObject obj, ValidationContext context,
+			ModelListener l) {
+		Variable elem=(Variable)obj;
+
+		// Validate variable
+	}
+}

Added: trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/WhenValidationRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/WhenValidationRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/WhenValidationRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 13 Mar 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.validation;
+
+import org.scribble.validation.*;
+import org.scribble.extensions.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class implements the validation rule for the
+ * When construct.
+ */
+ at RegistryInfo(extension=ValidationRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class WhenValidationRule extends AbstractValidationRule {
+
+	/**
+	 * This is the default constructor.
+	 */
+	public WhenValidationRule() {
+	}
+
+	/**
+	 * This method determines whether the rule is appropriate for
+	 * the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @return Whether the rule is appropriate
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj instanceof When);
+	}
+
+	/**
+	 * This method validates the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @param context The context
+	 * @param l The listener
+	 */
+	public void validate(ModelObject obj, ValidationContext context,
+			ModelListener l) {
+		When elem=(When)obj;
+
+		for (int i=0; i < elem.getConditionalBlocks().size(); i++) {
+			context.validate(elem.getConditionalBlocks().get(i), l);
+		}
+	}
+}

Added: trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/WhileValidationRule.java
===================================================================
--- trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/WhileValidationRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/WhileValidationRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 13 Mar 2008 : Initial version created by gary
+ */
+package org.scribble.conversation.validation;
+
+import org.scribble.validation.*;
+import org.scribble.extensions.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class implements the validation rule for the
+ * While construct.
+ */
+ at RegistryInfo(extension=ValidationRule.class,notation=ConversationNotation.NOTATION_CODE)
+public class WhileValidationRule extends AbstractValidationRule {
+
+	/**
+	 * This is the default constructor.
+	 */
+	public WhileValidationRule() {
+	}
+
+	/**
+	 * This method determines whether the rule is appropriate for
+	 * the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @return Whether the rule is appropriate
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj instanceof While);
+	}
+
+	/**
+	 * This method validates the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @param context The context
+	 * @param l The listener
+	 */
+	public void validate(ModelObject obj, ValidationContext context,
+			ModelListener l) {
+		While elem=(While)obj;
+
+		context.validate(elem.getBlock(), l);
+	}
+}

Added: trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/osgi/Activator.java
===================================================================
--- trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/osgi/Activator.java	                        (rev 0)
+++ trunk/bundles/org.scribble.conversation.validation/src/main/java/org/scribble/conversation/validation/osgi/Activator.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,48 @@
+package org.scribble.conversation.validation.osgi;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator implements BundleActivator {
+
+	// The plug-in ID
+	public static final String PLUGIN_ID = "org.scribble.conversation.validation";
+
+	// The shared instance
+	private static Activator plugin;
+	
+	/**
+	 * The constructor
+	 */
+	public Activator() {
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+	 */
+	public void start(BundleContext context) throws Exception {
+		plugin = this;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+	 */
+	public void stop(BundleContext context) throws Exception {
+		plugin = null;
+	}
+
+	/**
+	 * Returns the shared instance
+	 *
+	 * @return the shared instance
+	 */
+	public static Activator getDefault() {
+		return plugin;
+	}
+
+}

Added: trunk/bundles/org.scribble.core/.classpath
===================================================================
--- trunk/bundles/org.scribble.core/.classpath	                        (rev 0)
+++ trunk/bundles/org.scribble.core/.classpath	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src/test"/>
+	<classpathentry kind="src" path="src/main/java"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
+	<classpathentry kind="output" path="classes"/>
+</classpath>

Added: trunk/bundles/org.scribble.core/.project
===================================================================
--- trunk/bundles/org.scribble.core/.project	                        (rev 0)
+++ trunk/bundles/org.scribble.core/.project	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.scribble.core</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.ManifestBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.SchemaBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.pde.PluginNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

Added: trunk/bundles/org.scribble.core/Issues.txt
===================================================================
--- trunk/bundles/org.scribble.core/Issues.txt	                        (rev 0)
+++ trunk/bundles/org.scribble.core/Issues.txt	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,595 @@
+TODO:
+
+JUnit tests?
+
+Documentation?
+
+Finished protocol notation
+
+Conversation model language - constructs mapped from protocol.
+
+Conformance checking - need to deal with order change on different same role but different channels. Order may only be irrelevant when two interactions to same channel are in sequence?
+
+Type analysis from paper as research or experimental
+
+Java receive on channel - use it in conformance with name mapping
+- channel name mapping should be done in the definition - so language mapping may
+need an annotation. Conversation to protocol could use bind parameters. This was
+is predicatable - just adding name maps adhoc is risky.
+- need to remove the pushNameMap from conformance context interface - issue is how
+this can be kept protected, unless have a secondary (internal) interface derived
+from the context that can be cast?
+
+Handle inline conversation paths defined in spawn and other methods
+Handle receives on declaration lines
+
+
+Mapping of role names -- when 'implements' used between two local notations,
+should be able to use the name mapping between the located roles. e.g.
+conv X at Buyer3 implements Y at Buyer2 should be able to map Buyer3 to Buyer2 without
+having a 'for' clause.
+
+Receives on different channels being in parallel:
+-from conformance point of view, think they should still be handled in sequence
+-just means that the underlying transports can receive and buffer the messages
+ in any order, but would be too complex for user to understand implications if
+ the statements also occurred in parallel?
+
+Conformance checking of channel - need to deal with name mapping.
+
+Local projection of receive - should be based only on local role: e.g.
+BuyerSeller at Buyer should have
+Invoice to Buyer;
+rather than: Invoice from Seller
+as local receiver should not need to know which role it is receiving from?
+So receive is determined by the fact that the 'to' role is the same as
+the local projected role.
+
+
+Need to decide how to manage references for Java files - should really use
+the Java classpath. Then the dependency between the BuyerApp classes and
+the ConversationState based classes can be 'uses' dependency, with the
+reference based on the namespace of the Java class.
+
+
+Need to see if scope/state can be managed by the context in
+projector, as it is in validation, rather than rules having to
+do it.
+
+Need to replace validation control by rule driven guidance, so
+different rules can be invoked in different states, as appropriate.
+For example, when the conversations contained within a JavaLangModel
+are validated, need to set the validation context to be located
+at whatever role is associated with the conversation, before
+validating the conversation.
+
+
+Language idea:
+Perhaps the conversation name (+location) could be associated with a data container
+class that provides the access to the state. The instance of this class could then
+be passed between paths that is executing the activities. Then issues to do
+with synchronization can be controlled by the developer. Means that local variables
+do not need to be used, which could not be persisted, and would be a problem passing
+between concurrently executed paths, unless made final, which is not ideal.
+- also the contents of the data container could be verified against the endpoint
+projection to ensure that all 'observable' and 'silent' variables are available.
+Silent variables are those that do not have a set method. However annotations
+could also be used to enable validation to ensure that methods are not changing
+state unnecessarily.
+- these containers may need references to session instances (which is what they
+effectively represent) related to bound information. Need to determine whether
+changes to a bound variable are visible in the calling session, and whether there
+are any synchronisation issues to deal with
+- allow Conversation to be typed to the container class, as well as the container
+class identifying the conversation name (and role) through an annotation
+- state can also provide the roles
+- issue - if the same state or role name are used in different scopes within a
+conversation definition, then they will need to be distinguished as separate values
+so may need to add a numerical suffix - but then also need to check from a consistency
+perspective that they represent the same thing. Name binding? possibly another
+annotation? Just need to ensure the modified name is consistently used within the
+separate scopes.
+
+
+Need to look at different ways to extend the notations to see if supported
+- may lead to guidelines for others to follow
+
+'when' is like a sequence with a synchronization point - so from a conformance
+perspective it should not be treated as conditional, like an 'if'.
+
+If Java class does not have an annotation to record its scribble type, then
+could make assumption that its scribble type has the same namespace as the
+package and same name as the class/interface.
+
+
+When project opened, appears to validate based on added order - so was not finding
+types, but this should be resolved when the type files are added? May be due to
+detachment with no actual interface file (i.e. stp file).
+
+
+
+Issue - if model rep requested with particular notation, then looks in details
+for that notation - however if the implementation is not associated with a
+notation, then it should share the one associated with the NotationDetails
+for the 'null' notation
+
+
+Conformance checking:
+1) when dealing with a reference description, need to be able to check for
+sub-contract conformance (i.e. where decision is taken on main description,
+but fewer options are decided - however if default option is available then
+this makes the other options relevant).
+
+Checking between different structures:
+interaction A->B;
+interaction B->C;
+// other interactions
+
+against
+parallel {
+   interaction A->B;
+} and {
+   interaction B->C;
+}
+// other interactions
+
+or
+interaction A->B;
+choice {
+	interaction B->C;
+} or {
+	interaction B->C;
+}
+// other interactions
+
+
+
+==================================================================
+
+
+Need to provide quickfix processor for link between global and local models
+
+
+** move refactor problem - but test other refactoring aswell
+
+- need to start example project
+- see about doing comparison between protocol and conversation?
+
+DefaultComparator - when a local model is requested from MRep.getModel,
+but does not exist, so it returns a projection of a persisted global model,
+what reference should be passed to the comparator context - what is
+it used for? Gets stored, but not sure where used.
+
+
+dependency notification - if a global model is updated, then need to notify any
+model ref that is dependent upon one of its conformsTo references. Similarly, if
+a 'useImplementation' type reference is updated, then need to notify any
+model refs that are dependent upon the generic type that is implemented by the
+changed ref.
+- done for global->local models, but still need to do for 'implements'
+where useImplementations is involved
+- issue is that references appear to be cleared and built up one
+by one, so need to see how can deal with this - plus when Type
+annotation removed, it does not realise link has gone
+
+
+
+if comformance to local model, and only global model is persisted,
+then do projection to get local model - but need to see how this
+would be reported.
+
+
+Need to associate condition with ConditionBlock - should
+probably be separate parser rule to enable reuse.
+
+
+
+
+Need to change isSupported methods to put class first- e.g. Model.class.isAssignableFrom(type)
+
+Project based references
+conformsTo link between global and local models where not same name or roles
+text projection possibly make generic with rules checking if output types supported?
+inner model projection may result in multiple projections for different roles
+
+ConformsTo mechanism - global model links to local model, the local model name
+identifies the located role in that model, but the issue is that the construct
+does not indicate which role in the global model maps onto that local model role.
+Could be done by including the mapping in the bind list - but this would mean
+duplication in the role in the 'conformsTo' construct. If it is not specified,
+then it may indicate that the roles were the same in both models, but just the
+model names are different. Other approach is to make the conforms statement
+on the global model role,
+role Buyer2 conformsTo example2b at Buyer(Seller2 for Seller);
+- doesn't look right??
+
+
+
+ISSUE:
+Need to sort out how Run and ProtocolReference relate to inner and inline protocols.
+At the moment ProtocolReference has an inner protocol, but so has Run. Really the
+reference should just be that, and the Run should have an inline protocol and
+some way to indicate whether a reference is to an inner protocol.
+
+
+Modelling project - could use the classes in the generic scribble.model
+package to define language independent 'super structure' for conversations.
+
+TODO:
+1) mapping of roles between run protocols - use in comparator
+2) explicit relationship between local and global models, based on 'implements' or
+'conforms' statement - use mapping information in comparator
+3) Refactoring move - need to update dependent references as namespace would have
+changed
+
+Need to deal with files, in the same namespace, across different projects.
+Potentially need to partition dependency manager by project? or possibly the
+model reference needs to be qualified by project?
+
+Refactoring problem - appears to be where description is renamed and then
+renamed back.
+
+
+
+
+
+Name mapping between compared definitions and also as moving through sub-behaviour lists
+
+Text generation from model
+
+
+
+
+
+
+Split protocol areas into separate plugins, so model, parsing, validation,
+comparison, projection etc are all separately installed (and can be replaced).
+
+
+
+-> refactoring - if name change, then could change the names of normal
+references. However if the name is related to a global or local model, and
+the alternate global/local model is also present, then need to handle in
+a different way? Should all of the global and local names change consistently?
+Should the link between global and local be made explicit, rather than implicit
+based on name?
+
+
+
+
+Define some example plugin projects that show extending the notations and adding
+new notations as examples. And also projects for analysis tools.
+- if role list and role move to the core plugin, have an example
+derived participant parsing rule that overrides the standard rule, to include
+additional information.
+
+
+
+
+ParserContext:
+
+Currently has a 'located role' property that returns the role
+name. Should it return the role object?
+
+
+
+
+ProtocolModel/Protocol - currently Protocol validates that same name as
+file - but if inner protocols, then would not work - but would be better if
+generic approach that works for all notations.
+
+
+
+DOCUMENTATION:
+
+Need to make copy of scope for background validation tasks, so is not affected
+by foreground validation - but also means any changes will only be
+relevant in scope of current background task
+
+
+
+
+
+CONVERSATION/LANGUAGE:
+
+if @ Buyer () {
+
+} else {
+
+} else {
+
+}
+
+(at buyer)
+if (c1.decision(val < 100)) {
+
+} else if (c1.decision(val < 200)) {
+
+} else {
+
+}
+
+(at seller)
+if (c1.decisionAt(buyer)) {
+
+} else if (c1.decisionAt(buyer)) {
+
+} else {
+
+}
+
+or 
+
+switch(c1.decisionAt(buyer)) {
+case 0:
+case 1:
+default:
+}
+
+
+
+JAVA: 
+		// If decision is communicated, then each endpoint will be in sync,
+		// otherwise decision needs to be inferred based on knowledge of
+		// which message is received at each path - means also that the
+		// conversation state must be maintained within the conversation -
+		// which also means that the conversation state may need to have
+		// a persistence engine behind it?
+		
+		/*
+		c1.concurrent(new ConcurrentPath[]{
+				new ConcurrentPath() {
+					public void run() {
+					}
+				},
+				new ConcurrentPath() {
+					public void run() {
+					}
+				}
+		}, null);
+		*/
+
+
+
+============================================================================
+GLOBAL ESCAPE:
+
+In protocol,
+
+try {
+	....
+} catch(Confirmed from Seller to Buyer) {
+	...
+} catch(...) {
+	...
+}
+
+The signature indicates that if the interaction occurs while inside the
+try block, then it should interrupt any activities in that block and perform
+the activities in the catch block instead.
+
+Initially thought of this as similar to throwing exceptions, so thought the
+conversation and implementations would have the actual interaction in the
+try block, and when it occurred it would be similar to an exception being
+thrown.
+
+However in a cris-cross situation, this would require the activities in the
+try block to have a choice located at different roles for each path, as this
+is the only way that the cross over could occur - i.e. each role making an
+independent decision to enact their path before being informed that the other
+role has enacted a different path.
+
+Therefore we don't have a construct to support this type of choice, as
+all decisions must be located at one or more roles, but those roles are
+consistent across all paths of the choice.
+
+The other way to view the conversation/implementation of this construct is
+in a similar way to the protocol. The 'try' block is the initial path
+being executed, but each catch block is a separate thread that is waiting
+for a communication to occur, and if it does, then the initial path is
+interrupted.
+
+In one respect, the use of the try/catch syntax is appropriate, as it implies
+that something will cause the execution of the 'try' activities to terminate
+abruptly, executing a suitable handler (catch) block to deal with the issue.
+However a try block may deal with exceptions with any of the activities it
+contains, whereas this construct can only be interrupted if the first interaction
+does not fully complete. However after the first interaction is sent and
+received by the target role, then the interrupt handlers are no longer relevant.
+So it has different semantics to a try/catch block.
+
+May be better to model as:
+
+do {
+	Cancel from Buyer to Seller;
+	CancelDelivery from Seller to Shipper;
+	CancelConfirmed from Seller to Buyer; // must ack back to potential
+										// interrupted role, so that knows
+										// can complete block
+} interrupt {
+	channel ch1 at Buyer, ch2 at Shipper;
+	Confirmed from Seller to Buyer via ch1; // can't use same channel
+	DeliveryInstructions from Seller to Shipper via ch2; // can't use same channel
+}
+
+benefit of this approach, defined in the conversation, is that it could be
+conformance checked against:
+
+choice {
+	...
+} or {
+	Confirmed from Seller to Buyer;
+	DeliveryInstructions from Seller to Shipper;
+}
+
+although there is the issue of location of the choice - possibly located at both
+roles? and then the conversation refines this locatedness?
+
+Rather than making the interrupting interaction part of the definition of the
+interrupt, it can be inferred as the first interaction in the block. The benefit
+is that its possible then to locally define the channels that may be required.
+Downside is that it is not so explicit. However if explicit is required, then
+possibly the relevant interaction in the 'try/do' block should also be made
+explicit?
+
+Could also have a 'timeout' instead of interrupt - possibly both the interrupt
+and timeout should be located.
+
+Is there a better word the 'do' which may be linked to 'do/while'?
+
+Issue - when does the scope of the 'do' finish, and therefore cause the interrupts
+to be de-installed? Need to understand any constraints that need to be satisfied
+for the mechanism to work.
+
+NOTE 1: Cris-cross is only on the first interaction in each block, and can only
+be between two roles. Once this interaction has occurred at both roles, then the
+interrupts should be disabled.
+
+NOTE 2: The role sending the first message in the 'do' must also receive a message
+from the other role, to act as an acknowledgement so that it knows the interrupt
+handlers can be de-installed and won't occur. The message can actually come from
+any role, as long as their is a direct or indirect causal link to the message
+that was first sent out.
+
+NOTE 3: Timeout applies between the first and last interaction associated with the
+role at which the timeout is located - so the 'do' block must have atleast two
+interactions for that role, although potential an interaction to start the 'do'
+block followed by a 'when' may be enough - but something needs to modify the state
+on which the 'when' is blocking, which would tend to be an interaction.
+
+NOTE 4: First sending role in try/do block should not be able to send another
+message until it has received a message from another role that was directly or
+indirectly caused by the message it sent. This is to prevent other interactions
+occurring that would need to be "unwound" if the interrupt (cris-cross) occurred. 
+
+
+Issue with this mechanism - the 'catch/interrupt' blocks need to use separate
+channels. The problem is that if there are activities following the whole
+activity, then which channel does it use. If it uses the default channels, then
+there is no causality with the interactions in the interrupt block (I believe) -
+i.e. it lacks synchronisation with the completion of the interrupt block.
+
+
+Maybe the 'interrupt' section should be similar to timeout - being able to
+interrupt the main section at any point - as this is more general. But still
+have problem (as with interrupt) of knowing when the main block should be
+considered finished and therefore the interrupt/timeout should be disabled.
+Also means that all participants in the main block have to be aware of the
+interaction to them, that would cause the interrupt/timeout to become relevant.
+
+However, the cancel pattern situation (or cris-cross) is more specific, it is
+based on two alternative sets of actions that could occur depending on which
+interaction occurs. Possibly have another aspect to the do-interrupt-timeout
+block, which enables these alternate outcomes to be listed:
+
+do {
+	Cancel from Buyer to Seller;
+	Cancelled from Seller to Buyer
+} or {
+	Confirm from Seller to Buyer;
+} interrupt {
+	....
+} timeout(...) {
+	...
+}
+
+Maybe its just the case that each interrupt or timeout block will have a
+decision maker. This role will know that the interrupt or timeout has
+occurred - however the other roles may not. To address this, the interactions
+within the interrupt/timeout must inform each other role, and also the
+interactions following the 'do' must also inform those roles that the interrupt/
+timeout blocks have not occurred.
+
+This seems to suggest that if the 'do' block has multiple interrupt or
+timeout blocks, that they are all located at the same role.
+
+Then the issue is, what is the contents of the do? Does it matter? Don't
+think so, as the end of the 'do' block at each role will wait pending the
+occurrence of an interaction to the role, whether from one of the blocks,
+or from the following interactions.
+
+The other approach is that, if the final interaction in the 'do' block is
+back to the interrupting/timeout role, then this could be used to stop
+the interrupts/timeout. However the cris-cross situation could occur, where
+the sending role sends the final interaction in the do block, but the
+interrupt/timeout could occur after this send, before it has been received
+by the interrupting role. Still does not guarantee other roles know whether
+the blocks have completed anyway - so best approach is the subsequent
+interactions. Issue is that it may not be approach to define these following
+interactions for a protocol - but they may be the only way to know that
+the conversation has finished in a normal way.
+
+Or possibly the use the 'finally' approach to indicate where the interrupt/timeout
+are no longer relevant, although this is the same as having the interactions
+after the do construct. The only different situation would be if the 'finally'
+block did not have exactly the same semantics as in the Java try/catch construct -
+so the contents of the 'finally' block are only performed if the do block contents
+are not interrupted/timedout. So if the interrupt/timeout occurs, they will
+not invoke the 'finally' block contents.
+- would have same constaint - that all roles in the do block must be notified
+by the decision maker (directly or indirectly) that in the 'finally' block
+
+
+============================================================================
+
+
+From BuyerApp2:
+
+	// Issue - they can't be message handlers, as more than
+	// one message may occur during a selection? Unless the
+	// select has a path per message? Problem is that other
+	// activities may be defined before the message(s), which
+	// may be common to multiple messages in the same
+	// path.
+	
+	// What about where there are no activities for a role in
+	// one of the paths, so the choice may be optional - how
+	// do we know when to do the join path? Possibly the
+	// optional path becomes associated with the messages that
+	// are actually in the join path, and the optional path
+	// does nothing.
+	
+	// Need to consider what can be achieved with these
+	// descriptions.
+	// - can extract endpoint behaviour from the source code
+	// - what about runtime?
+	// - if runtime is monitoring state, along with the
+	//   execution, and has access to the behaviour description
+	//   of the role, then it would know which path is appropriate
+	//   for a message type being received. Same as Ray's
+	//   idea of defining the protocol and using it to configure
+	//   the socket?
+	// - with Ray's approach, the path selection is explicit.
+	//   However it requires communication of that decision
+	//   token, and requires that those tokens be common
+	//   across the implementations.
+	// - Documented approach does not require the additional
+	//   control message, although at implementation time it
+	//   could be generated, but using the message type as the
+	//   selector - does not require additional values with
+	//   the potential mapping problems.
+	// - Concept of the tokens is not present in the protocol
+	//   or (so far) in the conversation notation
+	
+	
+From SellerApp1.java:
+
+
+
+// External choice represents complete set of options, with
+// positional information, or an understanding of the messages
+// that may occur to select a path.
+
+// The other possibility is that if path selected, then maybe
+// it enables each path to observe the same channel and still
+// be linear. However, if the message type is used as the
+// selector, then it would still work?
+
+// Sending control signals could deal with situations where
+// there are no messages going to the role in that path. However
+// this would not deal with situations where the control signal
+// could not be sent
+
+
+
+

Added: trunk/bundles/org.scribble.core/LICENSE.txt
===================================================================
--- trunk/bundles/org.scribble.core/LICENSE.txt	                        (rev 0)
+++ trunk/bundles/org.scribble.core/LICENSE.txt	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,201 @@
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   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.

Added: trunk/bundles/org.scribble.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/bundles/org.scribble.core/META-INF/MANIFEST.MF	                        (rev 0)
+++ trunk/bundles/org.scribble.core/META-INF/MANIFEST.MF	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,98 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Scribble Plug-in
+Bundle-SymbolicName: org.scribble.core;singleton:=true
+Bundle-Version: 1.2.0.qualifier
+Bundle-Activator: org.scribble.osgi.Activator
+Bundle-Vendor: www.scribble.org
+Bundle-ActivationPolicy: lazy
+Import-Package: org.osgi.framework;version="1.3.0"
+Export-Package: org.scribble.comparator,
+ org.scribble.editor,
+ org.scribble.export,
+ org.scribble.export.stream,
+ org.scribble.export.text,
+ org.scribble.extensions,
+ org.scribble.model,
+ org.scribble.model.admin,
+ org.scribble.model.analysis,
+ org.scribble.model.change,
+ org.scribble.model.resolutions,
+ org.scribble.model.types,
+ org.scribble.model.util,
+ org.scribble.parser,
+ org.scribble.projector,
+ org.scribble.util,
+ org.scribble.validation
+Scribble-Extensions: org.scribble.model.TypeNotation,
+  org.scribble.parser.DefaultTokenizer,
+  org.scribble.parser.DefaultParser,
+  org.scribble.parser.NamespaceParserRule,
+  org.scribble.parser.ImportParserRule,
+  org.scribble.parser.ModelNameParserRule,
+  org.scribble.parser.RoleListParserRule,
+  org.scribble.parser.ConformanceReferenceParserRule,
+  org.scribble.parser.TypeReferenceParserRule,
+  org.scribble.parser.ChannelListParserRule,
+  org.scribble.parser.MessageSignatureParserRule,
+  org.scribble.parser.InteractionParserRule,
+  org.scribble.model.change.DefaultModelGenerator,
+  org.scribble.model.analysis.DefaultLookaheadAnalyser,
+  org.scribble.model.analysis.BlockLookaheadRule,
+  org.scribble.model.analysis.InteractionLookaheadRule,
+  org.scribble.model.analysis.SinglePathBehaviourLookaheadRule,
+  org.scribble.model.analysis.MultiPathBehaviourLookaheadRule,
+  org.scribble.model.analysis.ModelIncludeLookaheadRule,
+  org.scribble.model.filter.DefaultModelFilter,
+  org.scribble.model.types.DefaultTypeResolver,
+  org.scribble.validation.DefaultValidator,
+  org.scribble.validation.InteractionValidationRule,
+  org.scribble.validation.MessageSignatureValidationRule,
+  org.scribble.validation.ModelValidationRule,
+  org.scribble.validation.BlockValidationRule,
+  org.scribble.validation.ModelReferenceValidationRule,
+  org.scribble.validation.ChannelListValidationRule,
+  org.scribble.validation.ChannelValidationRule,
+  org.scribble.validation.RoleListValidationRule,
+  org.scribble.validation.RoleValidationRule,
+  org.scribble.validation.TypeReferenceValidationRule,
+  org.scribble.comparator.BlockComparatorRule,
+  org.scribble.comparator.DefaultComparator,
+  org.scribble.comparator.GlobalToLocalModelComparatorRule,
+  org.scribble.comparator.LocalToLocalModelComparatorRule,
+  org.scribble.comparator.RoleComparatorRule,
+  org.scribble.comparator.ChannelComparatorRule,
+  org.scribble.comparator.NamespaceComparatorRule,
+  org.scribble.comparator.InteractionComparatorRule,
+  org.scribble.comparator.MessageSignatureComparatorRule,
+  org.scribble.comparator.TypeReferenceComparatorRule,
+  org.scribble.projector.DefaultProjector,
+  org.scribble.projector.NamespaceProjectorRule,
+  org.scribble.projector.ImportProjectorRule,
+  org.scribble.projector.ConformanceReferenceProjectorRule,
+  org.scribble.projector.ImplementsReferenceProjectorRule,
+  org.scribble.projector.TypeReferenceProjectorRule,
+  org.scribble.projector.LocatedNameProjectorRule,
+  org.scribble.projector.BlockProjectorRule,
+  org.scribble.projector.RoleListProjectorRule,
+  org.scribble.projector.RoleProjectorRule,
+  org.scribble.projector.ChannelListProjectorRule,
+  org.scribble.projector.InteractionProjectorRule,
+  org.scribble.projector.MessageSignatureProjectorRule,
+  org.scribble.export.DefaultExporter,
+  org.scribble.export.text.NamespaceTextExportRule,
+  org.scribble.export.text.ImportTextExportRule,
+  org.scribble.export.text.ChannelListTextExportRule,
+  org.scribble.export.text.ChannelTextExportRule,
+  org.scribble.export.text.RoleListTextExportRule,
+  org.scribble.export.text.RoleTextExportRule,
+  org.scribble.export.text.ConformanceReferenceTextExportRule,
+  org.scribble.export.text.ImplementsReferenceTextExportRule,
+  org.scribble.export.text.TypeReferenceTextExportRule,
+  org.scribble.export.text.BlockTextExportRule,
+  org.scribble.export.text.MessageSignatureTextExportRule,
+  org.scribble.export.text.InteractionTextExportRule,
+  org.scribble.export.text.ModelNameTextExportRule
+Require-Bundle: org.scribble.monitor;resolution:=optional
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+

Added: trunk/bundles/org.scribble.core/build.properties
===================================================================
--- trunk/bundles/org.scribble.core/build.properties	                        (rev 0)
+++ trunk/bundles/org.scribble.core/build.properties	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,5 @@
+source.. = src/main/java/
+output.. = classes/
+bin.includes = META-INF/,\
+               .,\
+               plugin.xml

Added: trunk/bundles/org.scribble.core/pom.xml
===================================================================
--- trunk/bundles/org.scribble.core/pom.xml	                        (rev 0)
+++ trunk/bundles/org.scribble.core/pom.xml	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,23 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  	<modelVersion>4.0.0</modelVersion>
+	<groupId>org.savara.bundles</groupId>
+	<artifactId>org.scribble.core</artifactId> 
+	<version>1.2.0-SNAPSHOT</version>
+	<packaging>jar</packaging>
+	<name>Savara::Bundles::ScribbleCore</name>
+
+	<parent>
+		<groupId>org.savara</groupId>
+		<artifactId>bundles</artifactId>
+		<version>1.2.0-SNAPSHOT</version>
+	</parent>
+  
+	<dependencies>
+	    <dependency>
+	      <groupId>org.apache.felix</groupId>
+	      <artifactId>org.osgi.core</artifactId>
+	      <version>${osgi.version}</version>
+	    </dependency>
+	</dependencies>
+</project>

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/BlockComparatorRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/BlockComparatorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/BlockComparatorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 10 Nov 2008 : Initial version created by gary
+ */
+package org.scribble.comparator;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This class provides the Block comparator rule.
+ */
+ at RegistryInfo(extension=ComparatorRule.class)
+public class BlockComparatorRule implements ComparatorRule {
+
+	/**
+	 * This method determines whether the comparison rule is
+	 * associated with the supplied type.
+	 * 
+	 * @param obj The object to check
+	 * @return Whether the object is of a type supported by the
+	 * 					comparison rule
+	 */
+	public boolean isTypeSupported(ModelObject obj) {
+		return(obj instanceof Block);
+	}
+	
+	/**
+	 * This method determines whether the comparison rule is
+	 * appropriate for the supplied model objects.
+	 * 
+	 * @param main The main model object to be compared
+	 * @param ref The reference model object to be compared against
+	 * @return Whether the rule is relevant for the
+	 * 				model objects
+	 */
+	public boolean isComparisonSupported(ModelObject main, ModelObject ref) {
+		return(main.getClass() == Block.class &&
+				ref.getClass() == Block.class);
+	}
+	
+	/**
+	 * This method compares a model object against a reference
+	 * component to determine if they are equal.
+	 * 
+	 * @param context The context
+	 * @param main The main model object
+	 * @param reference The reference model object
+	 * @param l The model listener
+	 * @param deep Perform a deep compare
+	 * @return Whether the model objects are comparable
+	 */
+	public boolean compare(ComparatorContext context, ModelObject main,
+					ModelObject reference, ModelListener l, boolean deep) {
+		boolean ret=false;
+
+		if (deep == false) {
+			ret = true;
+		}
+		
+		return(ret);
+	}
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/ChannelComparatorRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/ChannelComparatorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/ChannelComparatorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 1 April 2008 : Initial version created by gary
+ */
+package org.scribble.comparator;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This class provides the Channel comparator rule.
+ */
+ at RegistryInfo(extension=ComparatorRule.class)
+public class ChannelComparatorRule implements ComparatorRule {
+
+	/**
+	 * This method determines whether the comparison rule is
+	 * associated with the supplied type.
+	 * 
+	 * @param obj The object to check
+	 * @return Whether the object is of a type supported by the
+	 * 					comparison rule
+	 */
+	public boolean isTypeSupported(ModelObject obj) {
+		return(obj instanceof Channel);
+	}
+	
+	/**
+	 * This method determines whether the comparison rule is
+	 * appropriate for the supplied model objects.
+	 * 
+	 * @param main The main model object to be compared
+	 * @param ref The reference model object to be compared against
+	 * @return Whether the rule is relevant for the
+	 * 				model objects
+	 */
+	public boolean isComparisonSupported(ModelObject main, ModelObject ref) {
+		return(main instanceof Channel &&
+				ref instanceof Channel);
+	}
+	
+	/**
+	 * This method compares a model object against a reference
+	 * component to determine if they are equal.
+	 * 
+	 * @param context The context
+	 * @param main The main model object
+	 * @param reference The reference model object
+	 * @param l The model listener
+	 * @param deep Perform a deep compare
+	 * @return Whether the model objects are comparable
+	 */
+	public boolean compare(ComparatorContext context, ModelObject main,
+					ModelObject reference, ModelListener l, boolean deep) {
+		boolean ret=false;
+		Channel mainch=(Channel)main;
+		Channel refch=(Channel)reference;
+
+		String mainName=context.getMainName(mainch.getName());
+		String refName=context.getReferenceName(refch.getName());
+		
+		ret = mainName.equals(refName);
+		
+		if (ret == false) {
+			String mesg=org.scribble.util.MessageUtil.format(
+					java.util.PropertyResourceBundle.getBundle(
+					"org.scribble.comparator.Messages").
+					getString("_CHANNEL_MISMATCH"),
+							new String[]{mainName, refName});
+			
+			l.error(new ModelIssue(main, mesg));
+		}
+
+		return(ret);
+	}
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/Comparator.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/Comparator.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/Comparator.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 18 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.comparator;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This interface represents the component responsible for
+ * comparing two model components for equality
+ */
+public interface Comparator {
+
+	/**
+	 * This method compares a main model against a reference
+	 * model, to determine if the main model is equivalent.
+	 * If not, then it reports differences to the model
+	 * listener.
+	 * 
+	 * @param mainModelObject The main model component being checked
+	 * @param mainSource The main model source
+	 * @param refModelObject The reference model component
+	 * @param refSource The reference model source
+	 * @param l The model listener
+	 * @return Whether the model objects are comparable
+	 */
+	public boolean compare(ModelObject mainModelObject, ModelReference mainSource,
+			ModelObject refModelObject,	ModelReference refSource, ModelListener l);
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/ComparatorContext.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/ComparatorContext.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/ComparatorContext.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,137 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 18 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.comparator;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This interface represents the comparator context.
+ */
+public interface ComparatorContext {
+	
+	// TODO: Need to make role mappings available, where the
+	// reference local model is using different role names
+	// to the projection from the global model - may need to make
+	// mapping information generic, as comparator will be used in
+	// other situations than comparing global and local models
+
+	/**
+	 * This method returns the model reference associated with
+	 * the source for the main description being compared
+	 * against.
+	 * 
+	 * @return The main source
+	 */
+	public ModelReference getMainSource();
+	
+	/**
+	 * This method returns the model reference associated with
+	 * the source for the reference description being compared
+	 * against.
+	 * 
+	 * @return The reference source
+	 */
+	public ModelReference getReferenceSource();
+	
+	/**
+	 * This method determines if the supplied model object has
+	 * any comparison rules associated with it.
+	 * 
+	 * @param obj The model object
+	 * @return Whether the type is supported by any comparator rules
+	 */
+	public boolean isTypeSupported(ModelObject obj);
+	
+	/**
+	 * This method determines whether a comparison rule exists that is
+	 * appropriate for the supplied model objects.
+	 * 
+	 * @param main The main model object to be compared
+	 * @param ref The reference model object to be compared against
+	 * @return Whether a rule is relevant for the
+	 * 				model objects
+	 */
+	public boolean isComparisonSupported(ModelObject main, ModelObject ref);
+
+	/**
+	 * This method compares a main model object against a reference
+	 * model object, to determine if the main model object is equivalent.
+	 * If not, then it reports differences to the model
+	 * listener.
+	 * 
+	 * @param main The model object being checked
+	 * @param reference The reference model object
+	 * @param l The model listener
+	 * @param deep Perform a deep compare
+	 * @return Whether the model objects are comparable
+	 */
+	public boolean compare(ModelObject main, ModelObject reference,
+						ModelListener l, boolean deep);
+	
+	/**
+	 * This method pushes the main name map on to the stack.
+	 * 
+	 * @param map The main name map
+	 */
+	public void pushMainNameMap(NameMap map);
+	
+	/**
+	 * This method pushes the reference name map on to the stack.
+	 * 
+	 * @param map The reference name map
+	 */
+	public void pushReferenceNameMap(NameMap map);
+
+	/**
+	 * This method returns the main name that has been mapped
+	 * to the supplied name. If the supplied name has
+	 * no mapping, then the same main name will be returned.
+	 * 
+	 * @param name The current main name
+	 * @return The original main name
+	 */
+	public String getMainName(String name);
+	
+	/**
+	 * This method returns the reference name that has been mapped
+	 * to the supplied name. If the supplied name has
+	 * no mapping, then the same reference name will be returned.
+	 * 
+	 * @param name The current reference name
+	 * @return The original reference name
+	 */
+	public String getReferenceName(String name);
+	
+	/**
+	 * This method pops the main name map from the stack.
+	 * 
+	 * @return The main name map
+	 */
+	public NameMap popMainNameMap();
+	
+	/**
+	 * This method pops the reference name map from the stack.
+	 * 
+	 * @return The reference name map
+	 */
+	public NameMap popReferenceNameMap();
+
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/ComparatorRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/ComparatorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/ComparatorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 18 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.comparator;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This interface represents the comparison rule used by the
+ * comparator to check whether a main model conforms to a
+ * reference model.
+ */
+public interface ComparatorRule {
+
+	/**
+	 * This method determines whether the comparison rule is
+	 * associated with the supplied type.
+	 * 
+	 * @param obj The object to check
+	 * @return Whether the object is of a type supported by the
+	 * 					comparison rule
+	 */
+	public boolean isTypeSupported(ModelObject obj);
+	
+	/**
+	 * This method determines whether the comparison rule is
+	 * appropriate for the supplied model objects.
+	 * 
+	 * @param main The main model object to be compared
+	 * @param ref The reference model object to be compared against
+	 * @return Whether the rule is relevant for the
+	 * 				model objects
+	 */
+	public boolean isComparisonSupported(ModelObject main, ModelObject ref);
+	
+	/**
+	 * This method compares a model object against a reference
+	 * component to determine if they are equal.
+	 * 
+	 * @param context The context
+	 * @param main The main model object
+	 * @param reference The reference model object
+	 * @param l The model listener
+	 * @param deep Perform a deep compare
+	 * @return Whether the model objects are comparable
+	 */
+	public boolean compare(ComparatorContext context, ModelObject main,
+					ModelObject reference, ModelListener l, boolean deep);
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/DefaultComparator.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/DefaultComparator.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/DefaultComparator.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 18 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.comparator;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class provides the default implementation
+ * of the Comparator interface.
+ */
+ at RegistryInfo(extension=Comparator.class,isService=true)
+public class DefaultComparator implements Comparator {
+
+	/**
+	 * This is the default constructor for the comparator.
+	 */
+	public DefaultComparator() {
+	}
+	
+	/**
+	 * This method compares a main model against a reference
+	 * model, to determine if the main model is equivalent.
+	 * If not, then it reports differences to the model
+	 * listener.
+	 * 
+	 * @param mainModelObject The main model component being checked
+	 * @param mainSource The main model source
+	 * @param refModelObject The reference model component
+	 * @param refSource The reference model source
+	 * @param l The model listener
+	 * @return Whether the model objects are comparable
+	 */
+	public boolean compare(ModelObject mainModelObject, ModelReference mainSource,
+			ModelObject refModelObject,	ModelReference refSource, ModelListener l) {
+		boolean ret=false;
+	
+		// Only perform conformance checking if reference model
+		// is supplied. Otherwise, it is the validation rules 
+		// responsibility to report the error.
+		if (refModelObject != null) {
+			
+			DefaultComparatorContext context=
+				new DefaultComparatorContext(mainSource, refSource);
+			
+			if (refSource instanceof NameMappingReference) {
+				context.pushReferenceNameMap(new DefaultNameMap(
+						((NameMappingReference)refSource).getNameMapping()));
+			}
+			
+			ret = context.compare(mainModelObject, refModelObject, l, true);
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/DefaultComparatorContext.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/DefaultComparatorContext.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/DefaultComparatorContext.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,311 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 18 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.comparator;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.model.resolutions.DeleteFromModel;
+
+/**
+ * This class represents the default comparator context.
+ */
+public class DefaultComparatorContext implements ComparatorContext {
+
+	/**
+	 * This is the constructor for use in testing using a set
+	 * of comparator rules.
+	 * 
+	 * @param mainSource The main model source reference
+	 * @param refSource The reference model source reference
+	 * @param rules The rules
+	 */
+	public DefaultComparatorContext(ModelReference mainSource,
+			ModelReference refSource, java.util.List<ComparatorRule> rules) {
+		m_mainSource = mainSource;
+		m_refSource = refSource;
+		m_rules = rules;
+	}
+	
+	/**
+	 * This is the default constructor for the comparator context.
+	 * 
+	 * @param mainSource The main model source reference
+	 * @param refSource The reference model source reference
+	 */
+	public DefaultComparatorContext(ModelReference mainSource,
+						ModelReference refSource) {
+		m_mainSource = mainSource;
+		m_refSource = refSource;
+		
+		java.util.List<Object> rules=
+			org.scribble.extensions.RegistryFactory.getRegistry().
+						getExtensions(ComparatorRule.class, null);
+		
+		// Transfer to typed list
+		for (int i=0; i < rules.size(); i++) {
+			if (rules.get(i) instanceof ComparatorRule) {
+				m_rules.add((ComparatorRule)rules.get(i));
+			}
+		}
+	}
+	
+	/**
+	 * This method returns the model reference associated with
+	 * the source for the main description being compared
+	 * against.
+	 * 
+	 * @return The main source
+	 */
+	public ModelReference getMainSource() {
+		return(m_mainSource);
+	}
+	
+	/**
+	 * This method returns the model reference associated with
+	 * the source for the reference description being compared
+	 * against.
+	 * 
+	 * @return The reference source
+	 */
+	public ModelReference getReferenceSource() {
+		return(m_refSource);
+	}
+	
+	/**
+	 * This method determines if the supplied model object has
+	 * any comparison rules associated with it.
+	 * 
+	 * @param obj The model object
+	 * @return Whether the type is supported by any comparator rules
+	 */
+	public boolean isTypeSupported(ModelObject obj) {
+		boolean ret=false;
+		
+		for (int i=0; ret == false && i < getRules().size(); i++) {
+			ret = getRules().get(i).isTypeSupported(obj);
+		}
+
+		return(ret);
+	}
+	
+	/**
+	 * This method determines whether a comparison rule exists that is
+	 * appropriate for the supplied model objects.
+	 * 
+	 * @param main The main model object to be compared
+	 * @param ref The reference model object to be compared against
+	 * @return Whether a rule is relevant for the
+	 * 				model objects
+	 */
+	public boolean isComparisonSupported(ModelObject main, ModelObject ref) {
+		boolean ret=false;
+		
+		for (int i=0; ret == false && i < getRules().size(); i++) {
+			ret = getRules().get(i).isComparisonSupported(main, ref);
+		}
+
+		return(ret);
+	}
+
+	/**
+	 * This method compares a main model object against a reference
+	 * model object, to determine if the main model object is equivalent.
+	 * If not, then it reports differences to the model
+	 * listener.
+	 * 
+	 * @param main The model object being checked
+	 * @param reference The reference model object
+	 * @param l The model listener
+	 * @param deep Perform a deep compare
+	 * @return Whether the model objects are comparable
+	 */
+	public boolean compare(ModelObject main, ModelObject reference,
+						ModelListener l, boolean deep) {
+		boolean ret=true;
+		boolean f_ruleApplied=false;
+		
+		if (logger.isLoggable(Level.FINEST)) {
+			logger.finest("Compare: main="+main+" reference="+reference);
+		}
+		
+		// Add rules appropriate for the comparison must return true,
+		// for the compare to return true
+		for (int i=0; ret == true && i < getRules().size(); i++) {
+			if (getRules().get(i).isComparisonSupported(main, reference)) {
+				f_ruleApplied = true;
+				
+				if (logger.isLoggable(Level.FINEST)) {
+					logger.finest("Invoking rule: "+getRules().get(i));
+				}
+				
+				ret = getRules().get(i).compare(this, main,
+							reference, l, deep);
+				
+				if (logger.isLoggable(Level.FINEST)) {
+					logger.finest("Result from rule: "+getRules().get(i)+" = "+ret);
+				}
+			}
+		}
+
+		// GPB (10/11/08) have removed check for main being behaviour
+		// as compare should only be called on behaviours now - but
+		// was not checking 'block'
+		if (f_ruleApplied == false /*&& main instanceof Behaviour*/) {
+			
+			// TODO:
+			// Record reference object location and
+			// start/end position with error, so they
+			// can be navigated
+			String mesg=org.scribble.util.MessageUtil.format(
+					java.util.PropertyResourceBundle.getBundle(
+					"org.scribble.comparator.Messages").
+					getString("_UNEXPECTED_BEHAVIOUR"), null);
+			
+			ModelIssue issue=new ModelIssue(main, mesg);
+			
+			issue.getResolutions().add(new DeleteFromModel());
+			
+			l.error(issue);
+			
+			ret = false;
+		}
+		
+		/*
+		 * For now, if no comparison rule is found, then should be
+		 * considered ok - so only if rule is broken should a
+		 * problem be reported.
+		 *
+		if (ret == false && f_ruleApplied == false) {
+			
+			// Need to report fact that no comparison rule could be found
+			l.error(main, "Unable to find equivalent model object", null);
+		}
+		*/
+		
+		return(ret);
+	}
+		
+	/**
+	 * This method returns a list of comparison rules.
+	 * 
+	 * @return The list of comparison rules
+	 */
+	public java.util.List<ComparatorRule> getRules() {
+		return(m_rules);
+	}
+	
+	/**
+	 * This method pushes the main name map on to the stack.
+	 * 
+	 * @param map The main name map
+	 */
+	public void pushMainNameMap(NameMap map) {
+		m_mainNameMapStack.add(0, map);
+	}
+	
+	/**
+	 * This method pushes the reference name map on to the stack.
+	 * 
+	 * @param map The reference name map
+	 */
+	public void pushReferenceNameMap(NameMap map) {
+		m_referenceNameMapStack.add(0, map);
+	}
+
+	/**
+	 * This method returns the main name that has been mapped
+	 * to the supplied name. If the supplied name has
+	 * no mapping, then the same main name will be returned.
+	 * 
+	 * @param name The current main name
+	 * @return The original main name
+	 */
+	public String getMainName(String name) {
+		String ret=name;
+		
+		for (int i=0; i < m_mainNameMapStack.size(); i++) {
+			NameMap map=m_mainNameMapStack.get(i);
+			ret = map.getName(name);
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the reference name that has been mapped
+	 * to the supplied name. If the supplied name has
+	 * no mapping, then the same reference name will be returned.
+	 * 
+	 * @param name The current reference name
+	 * @return The original reference name
+	 */
+	public String getReferenceName(String name) {
+		String ret=name;
+		
+		for (int i=0; i < m_referenceNameMapStack.size(); i++) {
+			NameMap map=m_referenceNameMapStack.get(i);
+			ret = map.getName(name);
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method pops the main name map from the stack.
+	 * 
+	 * @return The main name map
+	 */
+	public NameMap popMainNameMap() {
+		NameMap ret=null;
+		
+		if (m_mainNameMapStack.size() > 0) {
+			ret = m_mainNameMapStack.remove(0);
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method pops the reference name map from the stack.
+	 * 
+	 * @return The reference name map
+	 */
+	public NameMap popReferenceNameMap() {
+		NameMap ret=null;
+		
+		if (m_referenceNameMapStack.size() > 0) {
+			ret = m_referenceNameMapStack.remove(0);
+		}
+		
+		return(ret);
+	}
+	
+	private static Logger logger = Logger.getLogger("org.scribble.comparator");
+
+	private ModelReference m_mainSource=null;
+	private ModelReference m_refSource=null;
+	private java.util.List<ComparatorRule> m_rules=new java.util.Vector<ComparatorRule>();
+	private java.util.List<NameMap> m_mainNameMapStack=new java.util.Vector<NameMap>();
+	private java.util.List<NameMap> m_referenceNameMapStack=new java.util.Vector<NameMap>();
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/DefaultNameMap.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/DefaultNameMap.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/DefaultNameMap.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 18 Feb 2008 : Initial version created by gary
+ */
+package org.scribble.comparator;
+
+public class DefaultNameMap implements NameMap {
+
+	/**
+	 * This constructor is initialized with the name map.
+	 * 
+	 * @param map The map
+	 */
+	public DefaultNameMap(java.util.Map<String,String> map) {
+		m_map = map;
+	}
+	
+	/**
+	 * This method returns the name that has been mapped
+	 * to the supplied name. If the supplied name has
+	 * no mapping, then the same name will be returned.
+	 * 
+	 * @param name The current name
+	 * @return The original name
+	 */
+	public String getName(String name) {
+		return(m_map.containsKey(name) ? m_map.get(name) : name);
+	}
+
+	private java.util.Map<String,String> m_map=null;
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/GlobalToLocalModelComparatorRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/GlobalToLocalModelComparatorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/GlobalToLocalModelComparatorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 25 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.comparator;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.extensions.RegistryFactory;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This class provides the comparator rule for checking
+ * the conformance of an endpoint projection associated
+ * with a global model against an available local model.
+ */
+ at RegistryInfo(extension=ComparatorRule.class)
+public class GlobalToLocalModelComparatorRule implements ComparatorRule {
+
+	/**
+	 * This method determines whether the comparison rule is
+	 * associated with the supplied type.
+	 * 
+	 * @param obj The object to check
+	 * @return Whether the object is of a type supported by the
+	 * 					comparison rule
+	 */
+	public boolean isTypeSupported(ModelObject obj) {
+		return(obj instanceof Model);
+	}
+	
+	/**
+	 * This method determines whether the comparison rule is
+	 * appropriate for the supplied model objects.
+	 * 
+	 * @param main The main model object to be compared
+	 * @param ref The reference model object to be compared against
+	 * @return Whether the rule is relevant for the
+	 * 				model objects
+	 */
+	public boolean isComparisonSupported(ModelObject main, ModelObject ref) {
+		// Check if main is global model and ref is a local
+		// model
+		
+		// TODO:
+		// NOTE: It is assumed that the comparator rule has been called
+		// because there is a relationship between the two models, and
+		// the comparator context will have any mapping (renaming)
+		// information relevant to the comparison
+		return(main instanceof Model &&
+				ref instanceof Model &&
+				((Model)main).isLocated() == false &&
+				((Model)ref).isLocated());
+	}
+	
+	/**
+	 * This method compares a model object against a reference
+	 * component to determine if they are equal.
+	 * 
+	 * @param context The context
+	 * @param main The main model object
+	 * @param reference The reference model object
+	 * @param l The model listener
+	 * @param deep Perform a deep compare
+	 * @return Whether the model objects are comparable
+	 */
+	public boolean compare(ComparatorContext context, ModelObject main,
+					ModelObject reference, ModelListener l, boolean deep) {
+		boolean ret=true;
+		Model mainpm=(Model)main;
+		Model refpm=(Model)reference;
+		
+		org.scribble.projector.Projector projector=
+			(org.scribble.projector.Projector)
+			RegistryFactory.getRegistry().getExtension(
+					org.scribble.projector.Projector.class, null);
+
+		if (projector != null) {
+			
+			java.util.List<Definition> refdefns=refpm.getDefinitions();
+			java.util.List<String> rolesProjected=new java.util.Vector<String>();
+			
+			for (int i=0; i < refdefns.size(); i++) {
+				// Obtain projection for this role
+				// TODO: Take into account mapping between ref located role
+				// and name used in global model
+				String roleName=context.getReferenceName(
+						refdefns.get(i).getLocatedName().getRole().getName());
+				
+				if (rolesProjected.contains(roleName) == false) {
+					Model localModel=
+						projector.project(context.getMainSource(), mainpm,
+							new Role(roleName), l);
+								//refpm.getModelName().getLocatedRole(), l);
+					
+					if (localModel != null) {
+						ret = context.compare(localModel, refpm, l, deep);
+					}
+					
+					rolesProjected.add(roleName);
+				}
+			}
+		}
+		
+		return(ret);
+	}
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/InteractionComparatorRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/InteractionComparatorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/InteractionComparatorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,242 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 24 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.comparator;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This class provides the Interaction comparator rule.
+ */
+ at RegistryInfo(extension=ComparatorRule.class)
+public class InteractionComparatorRule implements ComparatorRule {
+
+	/**
+	 * This method determines whether the comparison rule is
+	 * associated with the supplied type.
+	 * 
+	 * @param obj The object to check
+	 * @return Whether the object is of a type supported by the
+	 * 					comparison rule
+	 */
+	public boolean isTypeSupported(ModelObject obj) {
+		return(obj instanceof Interaction);
+	}
+	
+	/**
+	 * This method determines whether the comparison rule is
+	 * appropriate for the supplied model objects.
+	 * 
+	 * @param main The main model object to be compared
+	 * @param ref The reference model object to be compared against
+	 * @return Whether the rule is relevant for the
+	 * 				model objects
+	 */
+	public boolean isComparisonSupported(ModelObject main, ModelObject ref) {
+		return(main instanceof Interaction &&
+				ref instanceof Interaction);
+	}
+	
+	/**
+	 * This method compares a model object against a reference
+	 * component to determine if they are equal.
+	 * 
+	 * @param context The context
+	 * @param main The main model object
+	 * @param reference The reference model object
+	 * @param l The model listener
+	 * @param deep Perform a deep compare
+	 * @return Whether the model objects are comparable
+	 */
+	public boolean compare(ComparatorContext context, ModelObject main,
+					ModelObject reference, ModelListener l, boolean deep) {
+		boolean ret=false;
+		Interaction maini=(Interaction)main;
+		Interaction refi=(Interaction)reference;
+		//boolean f_roleCompared=false;
+		
+		// Check for compatible message signatures
+		ret = context.compare(maini.getMessageSignature(),
+						refi.getMessageSignature(), l, deep);
+		
+		if (ret) {
+
+			Role fromRoleMain=findRole(maini, true);
+			Role fromRoleRef=findRole(refi, true);
+			Role toRoleMain=findRole(maini, false);
+			Role toRoleRef=findRole(refi, false);
+			
+			// Check if 'to' and 'from' roles are compatible			
+			if (ret && fromRoleMain != null &&
+					fromRoleRef != null) {
+				
+				ret = context.compare(fromRoleMain,
+						fromRoleRef, l, deep);
+				
+				if (logger.isLoggable(Level.FINE)) {
+					logger.fine("Interaction "+this+": compare 'from' roles: "+
+						fromRoleMain+" against "+fromRoleRef+" = "+ret);
+				}
+
+				//f_roleCompared = true;
+			}
+			
+			if (ret && toRoleMain != null &&
+							toRoleRef != null) {
+				ret = context.compare(toRoleMain,
+						toRoleRef, l, deep);
+				
+				if (logger.isLoggable(Level.FINE)) {
+					logger.fine("Interaction "+this+": compare 'to' roles: "+
+						toRoleMain+" against "+toRoleRef+" = "+ret);
+				}
+				
+				//f_roleCompared = true;
+			}
+			
+			/* TODO: Determine if mismatch direction is still
+			 * required
+			 * 
+			// Check if 'to' and 'from' roles are compatible			
+			if (ret && maini.getFromRole() != null &&
+					refi.getFromRole() != null) {
+				ret = context.compare(maini.getFromRole(),
+						refi.getFromRole(), l, deep);
+				
+				f_roleCompared = true;
+			}
+			
+			if (ret && maini.getToRole() != null &&
+							refi.getToRole() != null) {
+				ret = context.compare(maini.getToRole(),
+						refi.getToRole(), l, deep);
+				
+				f_roleCompared = true;
+			}
+			
+			if (f_roleCompared == false) {
+				boolean f_directionMismatch=false;
+				
+				if (maini.getFromRole() != null &&
+						refi.getToRole() != null) {
+					f_directionMismatch = context.compare(maini.getFromRole(),
+							refi.getToRole(), l, deep);
+				}
+				
+				if (!f_directionMismatch && maini.getToRole() != null &&
+						refi.getFromRole() != null) {
+					f_directionMismatch = context.compare(maini.getToRole(),
+							refi.getFromRole(), l, deep);
+				}
+				
+				if (f_directionMismatch) {
+					String mesg=org.scribble.util.MessageUtil.format(
+							java.util.PropertyResourceBundle.getBundle(
+							"org.scribble.comparator.Messages").
+							getString("_INTERACTION_DIRECTION_MISMATCH"),
+									new String[]{});
+					
+					l.error(new ModelIssue(main, mesg));
+		
+					ret = false;
+				}
+			}
+			*/
+		}
+
+		return(ret);
+	}
+	
+	protected Role findRole(Interaction interaction, boolean from) {
+		Role ret=null;
+
+		if (from) {
+			ret = interaction.getFromRole();
+			
+			if (ret == null && interaction.getChannel() != null) {
+				ret = interaction.getChannel().getFromRole();
+			}
+			
+			// If no 'from' role found, and if a 'to' role has
+			// been explicitly defined, then check if 'from' role
+			// can be inferred from the definition's located role
+			if (ret == null) {
+				Role other=interaction.getToRole();
+
+				if (other == null && interaction.getChannel() != null) {
+					other = interaction.getChannel().getToRole();
+				}
+				
+				if (other != null) {
+					Definition defn=interaction.getEnclosingDefinition();
+					
+					if (defn != null && defn.getLocatedName() != null) {
+						ret = defn.getLocatedName().getRole();
+						
+						// Check that role is not the same as the 'to'
+						// role
+						if (ret != null && ret.equals(other)) {
+							ret = null;
+						}
+					}
+				}
+			}
+		} else {
+			ret = interaction.getToRole();
+			
+			if (ret == null && interaction.getChannel() != null) {
+				ret = interaction.getChannel().getToRole();
+			}
+			
+			// If no 'to' role found, and if a 'from' role has
+			// been explicitly defined, then check if 'to' role
+			// can be inferred from the definition's located role
+			if (ret == null) {
+				Role other=interaction.getFromRole();
+
+				if (other == null && interaction.getChannel() != null) {
+					other = interaction.getChannel().getFromRole();
+				}
+				
+				if (other != null) {
+					Definition defn=interaction.getEnclosingDefinition();
+					
+					if (defn != null && defn.getLocatedName() != null) {
+						ret = defn.getLocatedName().getRole();
+						
+						// Check that role is not the same as the 'from'
+						// role
+						if (ret != null && ret.equals(other)) {
+							ret = null;
+						}
+					}
+				}
+			}
+		}
+
+		return(ret);
+	}
+
+	private static Logger logger = Logger.getLogger("org.scribble.comparator");
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/LocalToLocalModelComparatorRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/LocalToLocalModelComparatorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/LocalToLocalModelComparatorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 24 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.comparator;
+
+import java.util.logging.Logger;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This class provides the protocol model comparator rule,
+ * for comparing a local protocol model for conformance
+ * against another reference local protocol model.
+ */
+ at RegistryInfo(extension=ComparatorRule.class)
+public class LocalToLocalModelComparatorRule implements ComparatorRule {
+
+	/**
+	 * This method determines whether the comparison rule is
+	 * associated with the supplied type.
+	 * 
+	 * @param obj The object to check
+	 * @return Whether the object is of a type supported by the
+	 * 					comparison rule
+	 */
+	public boolean isTypeSupported(ModelObject obj) {
+		return(obj instanceof Model);
+	}
+	
+	/**
+	 * This method determines whether the comparison rule is
+	 * appropriate for the supplied model objects.
+	 * 
+	 * @param main The main model object to be compared
+	 * @param ref The reference model object to be compared against
+	 * @return Whether the rule is relevant for the
+	 * 				model objects
+	 */
+	public boolean isComparisonSupported(ModelObject main, ModelObject ref) {
+		return(main instanceof Model &&
+				ref instanceof Model &&
+				((Model)main).isLocated() &&
+				((Model)ref).isLocated());
+	}
+	
+	/**
+	 * This method compares a model object against a reference
+	 * component to determine if they are equal.
+	 * 
+	 * @param context The context
+	 * @param main The main model object
+	 * @param reference The reference model object
+	 * @param l The model listener
+	 * @param deep Perform a deep compare
+	 * @return Whether the model objects are comparable
+	 */
+	public boolean compare(ComparatorContext context, ModelObject main,
+					ModelObject reference, ModelListener l, boolean deep) {
+		boolean ret=true;
+		Model mainpm=(Model)main;
+		Model refpm=(Model)reference;
+		
+		java.util.List<Definition> mdefns=mainpm.getDefinitions();
+		java.util.List<Definition> rdefns=refpm.getDefinitions();
+		
+		// TODO:
+		// If multiple models on either the main or reference side,
+		// then need to work through each pair to determine if they share
+		// common model references (implements/conformsTo).
+		
+		if (mdefns.size() == 1 && rdefns.size() == 1) {	
+			ret = context.compare(mdefns.get(0),
+					rdefns.get(0), l, deep);
+		} else {
+			logger.severe("CURRENTLY NOT MATCHING MULTIPLE DEFINITIONS PER MODEL");
+		}
+		
+		return(ret);
+	}
+		
+	private static Logger logger = Logger.getLogger("org.scribble.comparator");
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/MessageSignatureComparatorRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/MessageSignatureComparatorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/MessageSignatureComparatorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,117 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 24 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.comparator;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.model.resolutions.UpdateFromReferencedDescription;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This class provides the MessageSignature comparator rule.
+ */
+ at RegistryInfo(extension=ComparatorRule.class)
+public class MessageSignatureComparatorRule implements ComparatorRule {
+
+	/**
+	 * This method determines whether the comparison rule is
+	 * associated with the supplied type.
+	 * 
+	 * @param obj The object to check
+	 * @return Whether the object is of a type supported by the
+	 * 					comparison rule
+	 */
+	public boolean isTypeSupported(ModelObject obj) {
+		return(obj instanceof MessageSignature);
+	}
+	
+	/**
+	 * This method determines whether the comparison rule is
+	 * appropriate for the supplied model objects.
+	 * 
+	 * @param main The main model object to be compared
+	 * @param ref The reference model object to be compared against
+	 * @return Whether the rule is relevant for the
+	 * 				model objects
+	 */
+	public boolean isComparisonSupported(ModelObject main, ModelObject ref) {
+		return(main instanceof MessageSignature &&
+				ref instanceof MessageSignature);
+	}
+	
+	/**
+	 * This method compares a model object against a reference
+	 * component to determine if they are equal.
+	 * 
+	 * @param context The context
+	 * @param main The main model object
+	 * @param reference The reference model object
+	 * @param l The model listener
+	 * @param deep Perform a deep compare
+	 * @return Whether the model objects are comparable
+	 */
+	public boolean compare(ComparatorContext context, ModelObject main,
+					ModelObject reference, ModelListener l, boolean deep) {
+		boolean ret=false;
+		MessageSignature m=(MessageSignature)main;
+		MessageSignature r=(MessageSignature)reference;
+		
+		if (m.getOperation() == null &&
+				r.getOperation() == null) {
+			ret = true;
+		} else if (m.getOperation() != null &&
+				r.getOperation() != null &&
+				m.getOperation().equals(r.getOperation())) {
+			ret = true;
+		} else if (m.getOperation() == null) {
+			ret = true;
+		}
+		
+		if (ret && m.getTypes().size() == r.getTypes().size()) {
+			
+			for (int i=0; ret && i < m.getTypes().size(); i++) {
+				
+				ret = context.compare(m.getTypes().get(i),
+							r.getTypes().get(i), l, deep);
+			}
+		} else {
+			String mesg=org.scribble.util.MessageUtil.format(
+					java.util.PropertyResourceBundle.getBundle(
+					"org.scribble.comparator.Messages").
+					getString("_MSIG_MISMATCH"),
+					new String[]{r.toString()});
+			
+			ModelIssue issue=new ModelIssue(m, mesg);
+			
+			UpdateFromReferencedDescription res=
+					new UpdateFromReferencedDescription();
+			res.setModel(context.getReferenceSource());
+			res.setSourceReference(r.getSource());
+			
+			issue.getResolutions().add(res);
+			
+			l.error(issue);
+		}
+		
+		return(ret);
+	}
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/Messages.properties
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/Messages.properties	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/Messages.properties	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,26 @@
+# /*
+# * Copyright 2007 Pi4 Technologies Ltd
+# *
+# * 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.
+# *
+# *
+# * Change History:
+# * 27 Nov 2007 : Initial version created by gary
+# */
+
+_CHANNEL_MISMATCH=Channel mismatch, found '{0}' but expecting '{1}'
+_INTERACTION_DIRECTION_MISMATCH=Interactions have incompatible directions
+_MSIG_MISMATCH=Message signature mismatch with referenced description, was expecting '{0}'
+_ROLE_MISMATCH=Role mismatch, found '{0}' but expecting '{1}'
+_TYPE_MISMATCH=Type mismatch with referenced description, was expecting '{0}'
+_UNEXPECTED_BEHAVIOUR=Behaviour not present in referenced description

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/NameMap.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/NameMap.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/NameMap.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 7 Dec 2007 : Initial version created by gary
+ */
+package org.scribble.comparator;
+
+/**
+ * This interface represents a component that maps names
+ * to other previously used names.
+ */
+public interface NameMap {
+
+	/**
+	 * This method returns the name that has been mapped
+	 * to the supplied name. If the supplied name has
+	 * no mapping, then the same name will be returned.
+	 * 
+	 * @param name The current name
+	 * @return The original name
+	 */
+	public String getName(String name);
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/NamespaceComparatorRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/NamespaceComparatorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/NamespaceComparatorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 27 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.comparator;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This class provides the Namespace comparator rule.
+ */
+ at RegistryInfo(extension=ComparatorRule.class)
+public class NamespaceComparatorRule implements ComparatorRule {
+
+	/**
+	 * This method determines whether the comparison rule is
+	 * associated with the supplied type.
+	 * 
+	 * @param obj The object to check
+	 * @return Whether the object is of a type supported by the
+	 * 					comparison rule
+	 */
+	public boolean isTypeSupported(ModelObject obj) {
+		return(obj instanceof Namespace);
+	}
+	
+	/**
+	 * This method determines whether the comparison rule is
+	 * appropriate for the supplied model objects.
+	 * 
+	 * @param main The main model object to be compared
+	 * @param ref The reference model object to be compared against
+	 * @return Whether the rule is relevant for the
+	 * 				model objects
+	 */
+	public boolean isComparisonSupported(ModelObject main, ModelObject ref) {
+		return(main instanceof Namespace &&
+				ref instanceof Namespace);
+	}
+	
+	/**
+	 * This method compares a model object against a reference
+	 * component to determine if they are equal.
+	 * 
+	 * @param context The context
+	 * @param main The main model object
+	 * @param reference The reference model object
+	 * @param l The model listener
+	 * @param deep Perform a deep compare
+	 * @return Whether the model objects are comparable
+	 */
+	public boolean compare(ComparatorContext context, ModelObject main,
+					ModelObject reference, ModelListener l, boolean deep) {
+		boolean ret=false;
+		Namespace mainns=(Namespace)main;
+		Namespace refns=(Namespace)reference;
+		
+		// Check, with relevant mapping from context, that the
+		// namespaces are equivalent
+		if (mainns.getName().equals(refns.getName())) {
+			ret = true;
+		}
+		
+		return(ret);
+	}
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/RoleComparatorRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/RoleComparatorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/RoleComparatorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 6 Dec 2007 : Initial version created by gary
+ */
+package org.scribble.comparator;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This class provides the Role comparator rule.
+ */
+ at RegistryInfo(extension=ComparatorRule.class)
+public class RoleComparatorRule implements ComparatorRule {
+
+	/**
+	 * This method determines whether the comparison rule is
+	 * associated with the supplied type.
+	 * 
+	 * @param obj The object to check
+	 * @return Whether the object is of a type supported by the
+	 * 					comparison rule
+	 */
+	public boolean isTypeSupported(ModelObject obj) {
+		return(obj instanceof Role);
+	}
+	
+	/**
+	 * This method determines whether the comparison rule is
+	 * appropriate for the supplied model objects.
+	 * 
+	 * @param main The main model object to be compared
+	 * @param ref The reference model object to be compared against
+	 * @return Whether the rule is relevant for the
+	 * 				model objects
+	 */
+	public boolean isComparisonSupported(ModelObject main, ModelObject ref) {
+		return(main instanceof Role &&
+				ref instanceof Role);
+	}
+	
+	/**
+	 * This method compares a model object against a reference
+	 * component to determine if they are equal.
+	 * 
+	 * @param context The context
+	 * @param main The main model object
+	 * @param reference The reference model object
+	 * @param l The model listener
+	 * @param deep Perform a deep compare
+	 * @return Whether the model objects are comparable
+	 */
+	public boolean compare(ComparatorContext context, ModelObject main,
+					ModelObject reference, ModelListener l, boolean deep) {
+		boolean ret=false;
+		Role mainr=(Role)main;
+		Role refr=(Role)reference;
+
+		String mainName=context.getMainName(mainr.getName());
+		String refName=context.getReferenceName(refr.getName());
+		
+		ret = mainName.equals(refName);
+		
+		if (ret == false) {
+			String mesg=org.scribble.util.MessageUtil.format(
+					java.util.PropertyResourceBundle.getBundle(
+					"org.scribble.comparator.Messages").
+					getString("_ROLE_MISMATCH"),
+							new String[]{mainName, refName});
+			
+			l.error(new ModelIssue(main, mesg));
+		}
+
+		return(ret);
+	}
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/TypeReferenceComparatorRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/TypeReferenceComparatorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/comparator/TypeReferenceComparatorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 21 Oct 2008 : Initial version created by gary
+ */
+package org.scribble.comparator;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.model.resolutions.UpdateFromReferencedDescription;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This class provides the TypeReference comparator rule.
+ */
+ at RegistryInfo(extension=ComparatorRule.class)
+public class TypeReferenceComparatorRule implements ComparatorRule {
+
+	/**
+	 * This method determines whether the comparison rule is
+	 * associated with the supplied type.
+	 * 
+	 * @param obj The object to check
+	 * @return Whether the object is of a type supported by the
+	 * 					comparison rule
+	 */
+	public boolean isTypeSupported(ModelObject obj) {
+		return(obj instanceof TypeReference);
+	}
+	
+	/**
+	 * This method determines whether the comparison rule is
+	 * appropriate for the supplied model objects.
+	 * 
+	 * @param main The main model object to be compared
+	 * @param ref The reference model object to be compared against
+	 * @return Whether the rule is relevant for the
+	 * 				model objects
+	 */
+	public boolean isComparisonSupported(ModelObject main, ModelObject ref) {
+		return(main instanceof TypeReference &&
+				ref instanceof TypeReference);
+	}
+	
+	/**
+	 * This method compares a model object against a reference
+	 * component to determine if they are equal.
+	 * 
+	 * @param context The context
+	 * @param main The main model object
+	 * @param reference The reference model object
+	 * @param l The model listener
+	 * @param deep Perform a deep compare
+	 * @return Whether the model objects are comparable
+	 */
+	public boolean compare(ComparatorContext context, ModelObject main,
+					ModelObject reference, ModelListener l, boolean deep) {
+		boolean ret=false;
+		TypeReference mtr=(TypeReference)main;
+		TypeReference rtr=(TypeReference)reference;
+		
+		if ((ret = mtr.equals(rtr)) == false) {
+			String text=rtr.getAlias();
+			
+			if (rtr.getNamespace() != null) {
+				text = "{"+rtr.getNamespace()+"}"+text;
+			}
+			
+			String mesg=org.scribble.util.MessageUtil.format(
+					java.util.PropertyResourceBundle.getBundle(
+					"org.scribble.comparator.Messages").
+					getString("_TYPE_MISMATCH"),
+					new String[]{text});
+			
+			ModelIssue issue=new ModelIssue(mtr, mesg);
+			
+			UpdateFromReferencedDescription res=
+					new UpdateFromReferencedDescription();
+			res.setModel(context.getReferenceSource());
+			res.setSourceReference(rtr.getSource());
+			
+			issue.getResolutions().add(res);
+			
+			l.error(issue);
+		}
+	
+		return(ret);
+	}
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/editor/AbstractEditorManager.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/editor/AbstractEditorManager.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/editor/AbstractEditorManager.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 19 Jun 2008 : Initial version created by gary
+ */
+package org.scribble.editor;
+
+import org.scribble.model.admin.ModelIssue;
+
+/**
+ * This abstract represents a base editor manager.
+ */
+public abstract class AbstractEditorManager implements EditorManager {
+
+	/**
+	 * This method enriches the set of properties required
+	 * by the editor, using the properties associated with
+	 * the model issue.
+	 * 
+	 * @param issue The model issue
+	 */
+	public void enrich(ModelIssue issue) {
+	}
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/editor/EditorManager.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/editor/EditorManager.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/editor/EditorManager.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 19 Jun 2008 : Initial version created by gary
+ */
+package org.scribble.editor;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelIssue;
+
+/**
+ * This interface represents an editor.
+ */
+public interface EditorManager {
+
+	/**
+	 * This method focuses the editor on the specified source,
+	 * identified by the model reference and source reference.
+	 * 
+	 * @param mref The model reference
+	 * @param sref The component source reference
+	 * @param prop Additional properties
+	 */
+	public void focus(ModelReference mref, SourceRef sref,
+					java.util.Map<String,Object> props);
+	
+	/**
+	 * This method enriches the set of properties required
+	 * by the editor, using the properties associated with
+	 * the model issue.
+	 * 
+	 * @param issue The model issue
+	 */
+	public void enrich(ModelIssue issue);
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/AbstractFormatter.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/AbstractFormatter.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/AbstractFormatter.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,126 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 13 Dec 2007 : Initial version created by gary
+ */
+package org.scribble.export;
+
+/**
+ * This class provides the abstract implementation for
+ * the formatter.
+ */
+public abstract class AbstractFormatter implements Formatter {
+	
+	/**
+	 * This is the constructor for the abstract formatter.
+	 * 
+	 * @param format The format
+	 */
+	public AbstractFormatter(String format) {
+		m_format = format;
+	}
+
+	/**
+	 * This method returns the format associated with the formatter.
+	 * 
+	 * @return The format
+	 */
+	public String getFormat() {
+		return(m_format);
+	}
+	
+	/**
+	 * This method instructs the formatter to start the block.
+	 */
+	public void startBlock() throws java.io.IOException {
+		m_level++;
+	}
+
+	/**
+	 * This method instructs the formatter to end the block.
+	 *
+	 * @throws IOException Failed to end block
+	 */
+	public void endBlock() throws java.io.IOException {
+		m_level--;
+	}
+		
+	/**
+	 * This method instructs the formatter to start the statement.
+	 */
+	protected void startStatement() throws java.io.IOException {
+	}
+
+	/**
+	 * This method instructs the formatter to end the statement.
+	 */
+	protected void endStatement() throws java.io.IOException {
+	}
+	
+	/**
+	 * This method returns the current level, with zero being the
+	 * outer level.
+	 * 
+	 * @return The current level
+	 */
+	public int getLevel() {
+		return(m_level);
+	}
+
+	/**
+	 * This method sets the value associated with the supplied
+	 * name in the current state.
+	 * 
+	 * @param name The state name
+	 * @param value The state value
+	 */
+	public void setState(String name, Object value) {
+		
+	}
+		
+	/**
+	 * This method pushes the current set of declarations onto the
+	 * stack.
+	 */
+	protected void pushState() {
+		
+	}
+	
+	/**
+	 * This method pops the current set of declarations off the stack.
+	 */
+	protected void popState() {
+		
+	}
+	
+	/**
+	 * This method pushes the current scope onto a stack.
+	 */
+	protected void pushScope() {
+		
+	}
+	
+	/**
+	 * This method pops the current scope from the stack.
+	 */
+	protected void popScope() {
+		
+	}
+	
+	private String m_format=null;
+	private int m_level=0;
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/DefaultExporter.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/DefaultExporter.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/DefaultExporter.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 13 Dec 2007 : Initial version created by gary
+ */
+package org.scribble.export;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+
+/**
+ * This class provides the default implementation for the
+ * exporter interface.
+ */
+ at RegistryInfo(extension=Exporter.class,isService=true)
+public class DefaultExporter implements Exporter {
+	
+	/**
+	 * This is the default constructor.
+	 */
+	public DefaultExporter() {
+	}
+
+	/**
+	 * This method exports the supplied model object to the supplied
+	 * formatter.
+	 * 
+	 * @param ref The model reference associated with the model object
+	 * @param modelObject The model object
+	 * @param formatter The formatter
+	 * @throws IOException Failed to export model
+	 */
+	public void export(ModelReference ref, ModelObject modelObject,
+					Formatter formatter) throws java.io.IOException {
+		java.util.List<Object> rules=
+			org.scribble.extensions.RegistryFactory.getRegistry().
+						getExtensions(ExportRule.class, ref.getNotation());
+		
+		ExporterContext context=
+			new DefaultExporterContext(ref, formatter, rules);
+		
+		context.export(modelObject);
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/DefaultExporterContext.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/DefaultExporterContext.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/DefaultExporterContext.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,195 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 10 May 2009 : Initial version created by gary
+ */
+package org.scribble.export;
+
+import java.util.logging.Logger;
+
+import org.scribble.model.Behaviour;
+import org.scribble.model.Block;
+import org.scribble.model.Declaration;
+import org.scribble.model.ModelInclude;
+import org.scribble.model.ModelObject;
+import org.scribble.model.ModelReference;
+import org.scribble.model.Statement;
+
+public class DefaultExporterContext implements ExporterContext {
+
+	public DefaultExporterContext(ModelReference ref, Formatter formatter,
+			java.util.List<Object> rules) {
+		m_source = ref;
+		m_formatter = formatter;
+		m_rules = rules;
+	}
+	
+	/**
+	 * This method returns the source model reference for the
+	 * model being exported.
+	 * 
+	 * @return The model reference of the source being exported
+	 */
+	public ModelReference getSource() {
+		return(m_source);
+	}
+	
+	/**
+	 * This method returns the formatter being used by
+	 * the exporter.
+	 * 
+	 * @return The formatter
+	 */
+	public Formatter getFormatter() {
+		return(m_formatter);
+	}
+	
+	/**
+	 * This method pushes the supplied object onto a stack,
+	 * for later use by a higher level rule.
+	 * 
+	 * @param obj The object to push on the stack
+	 */
+	public void push(Object obj) {
+		m_stack.add(obj);
+	}
+	
+	/**
+	 * This method pops the object from the top of the stack.
+	 * 
+	 * @return The object on the top of the stack, or
+	 * 				null if no objects remain on the stack
+	 */
+	public Object pop() {
+		Object ret=null;
+	
+		if (m_stack.size() > 0) {
+			ret = m_stack.remove(m_stack.size()-1);
+		}
+		
+		return(ret);
+	}
+	
+	public void export(ModelObject obj) throws java.io.IOException {
+		boolean f_groupingStructure=false;
+		
+		logger.fine("Export "+obj);
+		
+		if (obj != null) {
+			if (obj instanceof Behaviour &&
+						((Behaviour)obj).isScope()) {
+				
+				if (m_formatter instanceof AbstractFormatter) {
+					((AbstractFormatter)m_formatter).pushScope();
+				}
+			}
+			
+			// Check if object has a block property
+			java.beans.BeanInfo bi=null;
+			
+			try {
+				bi = java.beans.Introspector.getBeanInfo(obj.getClass());
+			} catch(Exception e) {
+				logger.log(java.util.logging.Level.SEVERE,
+						"Failed to get bean info for class '"+
+						obj.getClass()+"'", e);
+			}
+			
+			if (bi != null) {
+				java.beans.PropertyDescriptor[] pds=bi.getPropertyDescriptors();
+			
+				for (int i=0; f_groupingStructure == false &&
+								i < pds.length; i++) {
+					Class<?> cls=pds[i].getReadMethod().getReturnType();
+					java.lang.reflect.Type type=pds[i].getReadMethod().getGenericReturnType();
+					
+					if (cls == Block.class ||
+							(cls == java.util.List.class &&
+							type instanceof java.lang.reflect.ParameterizedType &&
+							((java.lang.reflect.ParameterizedType)type).getActualTypeArguments()[0] == Block.class)) {
+						f_groupingStructure = true;
+					}
+				}
+			}
+			
+			if (obj instanceof Block) {
+				f_groupingStructure = true;
+				
+				if (m_formatter instanceof AbstractFormatter) {
+					((AbstractFormatter)m_formatter).pushState();
+				
+					//((AbstractFormatter)m_formatter).startBlock();
+				}
+				
+			} else if (obj instanceof ModelInclude &&
+					((ModelInclude)obj).isInline()) {
+				f_groupingStructure = true;
+				
+			} else if (f_groupingStructure == false &&
+						obj instanceof Statement) {
+	
+				if (m_formatter instanceof AbstractFormatter) {
+					((AbstractFormatter)m_formatter).startStatement();
+				}
+			}
+			
+			for (int i=0; i < m_rules.size(); i++) {
+				ExportRule rule=(ExportRule)m_rules.get(i);
+				
+				if (rule.isSupported(obj, m_formatter)) {
+					rule.export(obj, this);
+				}
+			}
+			
+			if (obj instanceof Declaration) {
+				if (m_formatter instanceof AbstractFormatter) {
+					((AbstractFormatter)m_formatter).setState(
+							((Declaration)obj).getName(), obj);
+				}
+			}
+			
+			if (obj instanceof Block) {
+				
+				if (m_formatter instanceof AbstractFormatter) {
+					//((AbstractFormatter)m_formatter).endBlock();
+				
+					((AbstractFormatter)m_formatter).popState();
+				}
+				
+			} else if (f_groupingStructure == false &&
+						obj instanceof Statement) {
+				if (m_formatter instanceof AbstractFormatter) {
+					((AbstractFormatter)m_formatter).endStatement();		
+				}
+			}
+	
+			if (obj instanceof Behaviour &&
+							((Behaviour)obj).isScope()) {
+				if (m_formatter instanceof AbstractFormatter) {
+					((AbstractFormatter)m_formatter).popScope();
+				}
+			}
+		}
+	}
+	
+	private static Logger logger = Logger.getLogger("org.scribble.export");
+
+	private ModelReference m_source=null;
+	private Formatter m_formatter=null;
+	private java.util.List<Object> m_rules=null;
+	private java.util.List<Object> m_stack=new java.util.Vector<Object>();
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/ExportRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/ExportRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/ExportRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 13 Dec 2007 : Initial version created by gary
+ */
+package org.scribble.export;
+
+import org.scribble.model.*;
+
+/**
+ * This interface represents a rule used to export the model,
+ * based on a specified rule.
+ */
+public interface ExportRule {
+
+	/**
+	 * This method determines whether the exporter rule is appropriate
+	 * for the supplied model object and format.
+	 * 
+	 * @param modelObject The model object
+	 * @param format The format
+	 * @return Whether the rule is appropriate for the model object and
+	 * 						format
+	 */
+	public boolean isSupported(ModelObject modelObject, Formatter format);
+	
+	/**
+	 * This method exports the model object.
+	 * 
+	 * @param modelObject The model object
+	 * @param context The context
+	 * @throws IOException Failed to record export information
+	 */
+	public void export(ModelObject modelObject, ExporterContext context)
+							throws java.io.IOException;
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/Exporter.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/Exporter.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/Exporter.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 13 Dec 2007 : Initial version created by gary
+ */
+package org.scribble.export;
+
+import org.scribble.model.*;
+
+/**
+ * This interface represents the Exporter for Scribble models.
+ */
+public interface Exporter {
+
+	/**
+	 * This method exports the supplied model object to the supplied
+	 * formatter.
+	 * 
+	 * @param ref The model reference associated with the model object
+	 * @param modelObject The model object
+	 * @param formatter The formatter
+	 * @throws IOException Failed to export model
+	 */
+	public void export(ModelReference ref, ModelObject modelObject,
+					Formatter formatter) throws java.io.IOException;
+
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/ExporterContext.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/ExporterContext.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/ExporterContext.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 13 Dec 2007 : Initial version created by gary
+ */
+package org.scribble.export;
+
+import org.scribble.model.*;
+
+/**
+ * This interface represents the context provided to exporter rules.
+ */
+public interface ExporterContext {
+
+	/**
+	 * This method returns the source model reference for the
+	 * model being exported.
+	 * 
+	 * @return The model reference of the source being exported
+	 */
+	public ModelReference getSource();
+	
+	/**
+	 * This method returns the formatter being used by
+	 * the exporter.
+	 * 
+	 * @return The formatter
+	 */
+	public Formatter getFormatter();
+
+	/**
+	 * This method pushes the supplied object onto a stack,
+	 * for later use by a higher level rule.
+	 * 
+	 * @param obj The object to push on the stack
+	 */
+	public void push(Object obj);
+	
+	/**
+	 * This method pops the object from the top of the stack.
+	 * 
+	 * @return The object on the top of the stack, or
+	 * 				null if no objects remain on the stack
+	 */
+	public Object pop();
+	
+	/**
+	 * This method exports the supplied model object.
+	 * 
+	 * @param modelObject The model object
+	 * @throws IOException Failed to export model object
+	 */
+	public void export(ModelObject modelObject) throws java.io.IOException;
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/Formatter.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/Formatter.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/Formatter.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 13 Dec 2007 : Initial version created by gary
+ */
+package org.scribble.export;
+
+/**
+ * This interface represents the formatter used to represent information
+ * based on a specific format.
+ */
+public interface Formatter {
+
+	/**
+	 * This method returns the format associated with the formatter.
+	 * 
+	 * @return The format
+	 */
+	public String getFormat();
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/stream/AbstractModelStreamExportRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/stream/AbstractModelStreamExportRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/stream/AbstractModelStreamExportRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 12 Sept 2008 : Initial version created by gary
+ */
+package org.scribble.export.stream;
+
+import org.scribble.export.*;
+import org.scribble.model.*;
+
+/**
+ * This class implements the stream based export rule for the
+ * Model entity.
+ */
+public abstract class AbstractModelStreamExportRule implements ExportRule {
+
+	/**
+	 * This method determines whether the exporter rule is appropriate
+	 * for the supplied model object and format.
+	 * 
+	 * @param modelObject The model object
+	 * @param format The format
+	 * @return Whether the rule is appropriate for the model object and
+	 * 						format
+	 */
+	public boolean isSupported(ModelObject modelObject, Formatter format) {
+		return(Model.class.isAssignableFrom(modelObject.getClass()) &&
+				format instanceof StreamFormatter);
+	}
+
+	/**
+	 * This method exports the model object.
+	 * 
+	 * @param modelObject The model object
+	 * @param context The context
+	 * @throws IOException Failed to record export information
+	 */
+	public void export(ModelObject modelObject, ExporterContext context)
+							throws java.io.IOException {
+		Model model=(Model)modelObject;
+		StreamFormatter formatter    =(StreamFormatter)context.getFormatter();
+		
+		org.scribble.export.Exporter exp=(org.scribble.export.Exporter)
+			org.scribble.extensions.RegistryFactory.getRegistry().getExtension(
+				org.scribble.export.Exporter.class, null);
+		
+		if (exp != null) {
+			org.scribble.export.text.TextFormatter textformatter=
+				new org.scribble.export.text.TextFormatter();
+			
+			java.io.ByteArrayOutputStream os=
+					new java.io.ByteArrayOutputStream();
+			
+			textformatter.setOutputStream(os);
+			
+			exp.export(context.getSource(), model, textformatter);
+			
+			formatter.record(os.toByteArray());
+		}
+	}
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/stream/StreamFormatter.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/stream/StreamFormatter.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/stream/StreamFormatter.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 12 Sept 2008 : Initial version created by gary
+ */
+package org.scribble.export.stream;
+
+import org.scribble.export.*;
+
+/**
+ * This class provides the stream based implementation of the
+ * Formatter interface.
+ */
+public class StreamFormatter extends AbstractFormatter {
+
+	/**
+	 * The default constructor.
+	 */
+	public StreamFormatter() {
+		super(STREAM_FORMAT);
+	}
+	
+	/**
+	 * This method sets the output stream to use with the formatter.
+	 * 
+	 * @param os The output stream
+	 */
+	public void setOutputStream(java.io.OutputStream os) {
+		m_outputStream = os;
+	}
+	
+	/**
+	 * This method returns the output stream.
+	 * 
+	 * @return The output stream
+	 */
+	public java.io.OutputStream getOutputStream() {
+		return(m_outputStream);
+	}
+	
+	/**
+	 * This method records the supplied text.
+	 * 
+	 * @param value The information to record
+	 * @throws IOException Failed to record text
+	 */
+	public void record(Object value) throws java.io.IOException {
+		if (value instanceof byte[]) {
+			m_outputStream.write((byte[])value);
+		} else if (value instanceof String) {
+			m_outputStream.write(((String)value).getBytes());
+		}
+	}
+	
+	/**
+	 * This method closes the formatter.
+	 * 
+	 * @throws IOException Failed to close formatter
+	 */
+	public void close() throws java.io.IOException {
+		if (m_outputStream != null) {
+			m_outputStream.close();
+		}
+	}
+
+	public static final String STREAM_FORMAT="Stream";
+	
+	private java.io.OutputStream m_outputStream=null;
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/AbstractBlockTextExportRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/AbstractBlockTextExportRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/AbstractBlockTextExportRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 20 Dec 2007 : Initial version created by gary
+ */
+package org.scribble.export.text;
+
+import org.scribble.export.*;
+import org.scribble.model.*;
+
+/**
+ * This class implements the text based export rule for the
+ * Block entity.
+ */
+public abstract class AbstractBlockTextExportRule implements ExportRule {
+
+	/**
+	 * This method exports the model object.
+	 * 
+	 * @param modelObject The model object
+	 * @param context The context
+	 * @throws IOException Failed to record export information
+	 */
+	public void export(ModelObject modelObject, ExporterContext context)
+							throws java.io.IOException {
+		Block block=(Block)modelObject;
+		
+		((TextFormatter)context.getFormatter()).startBlock();
+		
+		for (int i=0; i < block.getContents().size(); i++) {
+			context.export(block.getContents().get(i));
+		}
+
+		((TextFormatter)context.getFormatter()).endBlock();
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/AbstractModelReferenceTextExportRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/AbstractModelReferenceTextExportRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/AbstractModelReferenceTextExportRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 20 Dec 2007 : Initial version created by gary
+ */
+package org.scribble.export.text;
+
+import org.scribble.export.*;
+import org.scribble.model.*;
+
+/**
+ * This class implements the text based export rule for the
+ * ModelReference entity.
+ */
+public abstract class AbstractModelReferenceTextExportRule implements ExportRule {
+
+	/**
+	 * This method determines whether the exporter rule is appropriate
+	 * for the supplied model object and format.
+	 * 
+	 * @param modelObject The model object
+	 * @param format The format
+	 * @return Whether the rule is appropriate for the model object and
+	 * 						format
+	 */
+	public boolean isSupported(ModelObject modelObject, Formatter format) {
+		return(ModelReference.class.isAssignableFrom(modelObject.getClass()) &&
+				format instanceof TextFormatter);
+	}
+
+	/**
+	 * This method exports the model object.
+	 * 
+	 * @param modelObject The model object
+	 * @param context The context
+	 * @throws IOException Failed to record export information
+	 */
+	public void export(ModelObject modelObject, ExporterContext context)
+							throws java.io.IOException {
+		ModelReference ref=(ModelReference)modelObject;
+		TextFormatter formatter=(TextFormatter)context.getFormatter();
+		
+		if (ref.isFullyQualified()) {
+			formatter.record(ref.getNamespace()+"."+
+							ref.getLocalpart());
+		} else {
+			formatter.record(ref.getAlias());
+		}
+		
+		if (ref.getLocatedRole() != null) {
+			
+			// Check if sub-definition path defined
+			for (int i=0; i < ref.getSubDefinitionPath().getPathElementCount(); i++) {
+				formatter.record("$"+ref.getSubDefinitionPath().getPathElement(i));				
+			}
+			
+			formatter.record("@"+ref.getLocatedRole());
+		}
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/AbstractModelTextExportRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/AbstractModelTextExportRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/AbstractModelTextExportRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 17 Dec 2007 : Initial version created by gary
+ */
+package org.scribble.export.text;
+
+import org.scribble.export.*;
+import org.scribble.model.*;
+
+/**
+ * This class implements the text based export rule for the
+ * Model entity.
+ */
+public abstract class AbstractModelTextExportRule implements ExportRule {
+
+	/**
+	 * This method determines whether the exporter rule is appropriate
+	 * for the supplied model object and format.
+	 * 
+	 * @param modelObject The model object
+	 * @param format The format
+	 * @return Whether the rule is appropriate for the model object and
+	 * 						format
+	 */
+	public boolean isSupported(ModelObject modelObject, Formatter format) {
+		return(Model.class.isAssignableFrom(modelObject.getClass()) &&
+				format instanceof TextFormatter);
+	}
+
+	/**
+	 * This method exports the model object.
+	 * 
+	 * @param modelObject The model object
+	 * @param context The context
+	 * @throws IOException Failed to record export information
+	 */
+	public void export(ModelObject modelObject, ExporterContext context)
+							throws java.io.IOException {
+		Model model=(Model)modelObject;
+		TextFormatter formatter=(TextFormatter)context.getFormatter();
+		
+		context.export(model.getNamespace());
+				
+		if (model.getImports().size() > 0) {
+			formatter.record("\r\n");
+		}
+		
+		for (int i=0; i < model.getImports().size(); i++) {
+			context.export(model.getImports().get(i));
+		}
+		
+		formatter.record("\r\n");
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/BlockTextExportRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/BlockTextExportRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/BlockTextExportRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 20 Dec 2007 : Initial version created by gary
+ */
+package org.scribble.export.text;
+
+import org.scribble.export.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+
+/**
+ * This class implements the text based export rule for the
+ * Block entity.
+ */
+ at RegistryInfo(extension=ExportRule.class)
+public class BlockTextExportRule extends AbstractBlockTextExportRule {
+
+	/**
+	 * This method determines whether the exporter rule is appropriate
+	 * for the supplied model object and format.
+	 * 
+	 * @param modelObject The model object
+	 * @param format The format
+	 * @return Whether the rule is appropriate for the model object and
+	 * 						format
+	 */
+	public boolean isSupported(ModelObject modelObject, Formatter format) {
+		return(modelObject.getClass() == Block.class &&
+				format instanceof TextFormatter);
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/ChannelListTextExportRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/ChannelListTextExportRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/ChannelListTextExportRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 9 Mar 2008 : Initial version created by gary
+ */
+package org.scribble.export.text;
+
+import org.scribble.export.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+
+/**
+ * This class implements the text based export rule for the
+ * ChannelList entity.
+ */
+ at RegistryInfo(extension=ExportRule.class)
+public class ChannelListTextExportRule implements ExportRule {
+
+	/**
+	 * This method determines whether the exporter rule is appropriate
+	 * for the supplied model object and format.
+	 * 
+	 * @param modelObject The model object
+	 * @param format The format
+	 * @return Whether the rule is appropriate for the model object and
+	 * 						format
+	 */
+	public boolean isSupported(ModelObject modelObject, Formatter format) {
+		return(ChannelList.class.isAssignableFrom(modelObject.getClass()) &&
+				format instanceof TextFormatter);
+	}
+
+	/**
+	 * This method exports the model object.
+	 * 
+	 * @param modelObject The model object
+	 * @param context The context
+	 * @throws IOException Failed to record export information
+	 */
+	public void export(ModelObject modelObject, ExporterContext context)
+							throws java.io.IOException {
+		ChannelList chlist=(ChannelList)modelObject;
+		TextFormatter formatter=(TextFormatter)context.getFormatter();
+		
+		formatter.record("channel\t");
+		
+		for (int i=0; i < chlist.getChannels().size(); i++) {
+			if (i > 0) {
+				formatter.record(", ");
+			}
+			context.export(chlist.getChannels().get(i));
+		}
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/ChannelTextExportRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/ChannelTextExportRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/ChannelTextExportRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 9 Mar 2008 : Initial version created by gary
+ */
+package org.scribble.export.text;
+
+import org.scribble.export.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+
+/**
+ * This class implements the text based export rule for the
+ * Channel entity.
+ */
+ at RegistryInfo(extension=ExportRule.class)
+public class ChannelTextExportRule implements ExportRule {
+
+	/**
+	 * This method determines whether the exporter rule is appropriate
+	 * for the supplied model object and format.
+	 * 
+	 * @param modelObject The model object
+	 * @param format The format
+	 * @return Whether the rule is appropriate for the model object and
+	 * 						format
+	 */
+	public boolean isSupported(ModelObject modelObject, Formatter format) {
+		return(Channel.class.isAssignableFrom(modelObject.getClass()) &&
+				format instanceof TextFormatter);
+	}
+
+	/**
+	 * This method exports the model object.
+	 * 
+	 * @param modelObject The model object
+	 * @param context The context
+	 * @throws IOException Failed to record export information
+	 */
+	public void export(ModelObject modelObject, ExporterContext context)
+							throws java.io.IOException {
+		Channel ch=(Channel)modelObject;
+		TextFormatter formatter=(TextFormatter)context.getFormatter();
+		
+		formatter.record(ch.getName());
+		
+		if (ch.getFromRole() != null) {
+			formatter.record(" from ");
+			context.export(ch.getFromRole());
+		}
+		
+		if (ch.getToRole() != null) {
+			formatter.record(" to ");
+			context.export(ch.getToRole());
+		}
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/ConformanceReferenceTextExportRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/ConformanceReferenceTextExportRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/ConformanceReferenceTextExportRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 20 Dec 2007 : Initial version created by gary
+ */
+package org.scribble.export.text;
+
+import org.scribble.export.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+
+/**
+ * This class implements the text based export rule for the
+ * ConformanceReference entity.
+ */
+ at RegistryInfo(extension=ExportRule.class)
+public class ConformanceReferenceTextExportRule
+					extends AbstractModelReferenceTextExportRule {
+
+	/**
+	 * This method determines whether the exporter rule is appropriate
+	 * for the supplied model object and format.
+	 * 
+	 * @param modelObject The model object
+	 * @param format The format
+	 * @return Whether the rule is appropriate for the model object and
+	 * 						format
+	 */
+	public boolean isSupported(ModelObject modelObject, Formatter format) {
+		return(super.isSupported(modelObject, format) &&
+				ConformanceReference.class.isAssignableFrom(modelObject.getClass()));
+	}
+
+	/**
+	 * This method exports the model object.
+	 * 
+	 * @param modelObject The model object
+	 * @param context The context
+	 * @throws IOException Failed to record export information
+	 */
+	public void export(ModelObject modelObject, ExporterContext context)
+							throws java.io.IOException {
+		ConformanceReference ref=(ConformanceReference)modelObject;
+		TextFormatter formatter=(TextFormatter)context.getFormatter();
+		
+		super.export(ref, context);
+		
+		if (ref.getNameMapping().size() > 0) {
+			formatter.record("(");
+			formatter.record(")");			
+		}
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/ImplementsReferenceTextExportRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/ImplementsReferenceTextExportRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/ImplementsReferenceTextExportRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 20 Dec 2007 : Initial version created by gary
+ */
+package org.scribble.export.text;
+
+import org.scribble.export.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+
+/**
+ * This class implements the text based export rule for the
+ * ImplementsReference entity.
+ */
+ at RegistryInfo(extension=ExportRule.class)
+public class ImplementsReferenceTextExportRule
+					extends AbstractModelReferenceTextExportRule {
+
+	/**
+	 * This method determines whether the exporter rule is appropriate
+	 * for the supplied model object and format.
+	 * 
+	 * @param modelObject The model object
+	 * @param format The format
+	 * @return Whether the rule is appropriate for the model object and
+	 * 						format
+	 */
+	public boolean isSupported(ModelObject modelObject, Formatter format) {
+		return(super.isSupported(modelObject, format) &&
+				ImplementsReference.class.isAssignableFrom(modelObject.getClass()));
+	}
+
+	/**
+	 * This method exports the model object.
+	 * 
+	 * @param modelObject The model object
+	 * @param context The context
+	 * @throws IOException Failed to record export information
+	 */
+	public void export(ModelObject modelObject, ExporterContext context)
+							throws java.io.IOException {
+		ImplementsReference ref=(ImplementsReference)modelObject;
+		TextFormatter formatter=(TextFormatter)context.getFormatter();
+		
+		super.export(ref, context);
+		
+		if (ref.getNameMapping().size() > 0) {
+			formatter.record("(");
+			
+			java.util.Iterator<String> iter=ref.getNameMapping().keySet().iterator();
+			boolean f_first=true;
+			
+			while (iter.hasNext()) {
+				String key=iter.next();
+				String value=ref.getNameMapping().get(key);
+				
+				if (f_first == false) {
+					formatter.record(", ");
+				}
+				formatter.record(value+" for "+key);
+				
+				f_first = false;
+			}
+			
+			formatter.record(")");			
+		}
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/ImportTextExportRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/ImportTextExportRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/ImportTextExportRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 17 Dec 2007 : Initial version created by gary
+ */
+package org.scribble.export.text;
+
+import org.scribble.export.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+
+/**
+ * This class implements the text based export rule for the
+ * Import entity.
+ */
+ at RegistryInfo(extension=ExportRule.class)
+public class ImportTextExportRule implements ExportRule {
+
+	/**
+	 * This method determines whether the exporter rule is appropriate
+	 * for the supplied model object and format.
+	 * 
+	 * @param modelObject The model object
+	 * @param format The format
+	 * @return Whether the rule is appropriate for the model object and
+	 * 						format
+	 */
+	public boolean isSupported(ModelObject modelObject, Formatter format) {
+		return(Import.class.isAssignableFrom(modelObject.getClass()) &&
+				format instanceof TextFormatter);
+	}
+
+	/**
+	 * This method exports the model object.
+	 * 
+	 * @param modelObject The model object
+	 * @param context The context
+	 * @throws IOException Failed to record export information
+	 */
+	public void export(ModelObject modelObject, ExporterContext context)
+							throws java.io.IOException {
+		Import elem=(Import)modelObject;
+		TextFormatter formatter=(TextFormatter)context.getFormatter();
+		
+		String alias="";
+		
+		if (elem.getAlias() != null) {
+			alias = " as "+elem.getAlias();
+		}
+		
+		formatter.record("import "+elem.getName()+alias);
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/InteractionTextExportRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/InteractionTextExportRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/InteractionTextExportRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,156 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 21 Dec 2007 : Initial version created by gary
+ */
+package org.scribble.export.text;
+
+import org.scribble.export.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+
+/**
+ * This class implements the text based export rule for the
+ * Interaction entity.
+ */
+ at RegistryInfo(extension=ExportRule.class) //,category=Interaction.class)
+public class InteractionTextExportRule implements ExportRule {
+
+	/**
+	 * This method exports the model object.
+	 * 
+	 * @param modelObject The model object
+	 * @param context The context
+	 */
+	public boolean isSupported(ModelObject modelObject, Formatter format) {
+		return(Interaction.class.isAssignableFrom(modelObject.getClass()) &&
+				format instanceof TextFormatter);
+	}
+
+	/**
+	 * This method exports the model object.
+	 * 
+	 * @param modelObject The model object
+	 * @param context The context
+	 * @throws IOException Failed to record export information
+	 */
+	public void export(ModelObject modelObject, ExporterContext context)
+							throws java.io.IOException {
+		Interaction interaction=(Interaction)modelObject;
+		
+		if (interaction.getMessageSignature() != null) {
+			context.export(interaction.getMessageSignature());
+		}
+		
+		exportFrom(interaction, context);
+		
+		exportTo(interaction, context);
+		
+		exportVia(interaction, context);
+		
+		exportRequestLabel(interaction, context);
+		
+		exportReplyToLabel(interaction, context);
+	}
+	
+	/**
+	 * This method exports the text related to an interactions
+	 * 'from' role.
+	 * 
+	 * @param interaction The interaction
+	 * @param context The export context
+	 * @throws java.io.IOException Failed to export information
+	 */
+	protected void exportFrom(Interaction interaction,
+			ExporterContext context) throws java.io.IOException {		
+		TextFormatter formatter=(TextFormatter)context.getFormatter();
+
+		if (interaction.getFromRole() != null) {
+			formatter.record(" from "+interaction.getFromRole().getName());
+		}
+	}
+	
+	/**
+	 * This method exports the text related to an interactions
+	 * 'to' role.
+	 * 
+	 * @param interaction The interaction
+	 * @param context The export context
+	 * @throws java.io.IOException Failed to export information
+	 */
+	protected void exportTo(Interaction interaction,
+			ExporterContext context) throws java.io.IOException {		
+		TextFormatter formatter=(TextFormatter)context.getFormatter();
+
+		if (interaction.getToRole() != null) {
+			formatter.record(" to "+interaction.getToRole().getName());
+		}
+	}
+	
+	/**
+	 * This method exports the text related to an interactions
+	 * 'via' channel.
+	 * 
+	 * @param interaction The interaction
+	 * @param context The export context
+	 * @throws java.io.IOException Failed to export information
+	 */
+	protected void exportVia(Interaction interaction,
+			ExporterContext context) throws java.io.IOException {		
+		TextFormatter formatter=(TextFormatter)context.getFormatter();
+
+		if (interaction.getChannel() != null) {
+			formatter.record(" via "+interaction.getChannel().getName());
+		}
+	}
+	
+	/**
+	 * This method exports the text related to an interactions
+	 * 'request' label.
+	 * 
+	 * @param interaction The interaction
+	 * @param context The export context
+	 * @throws java.io.IOException Failed to export information
+	 */
+	protected void exportRequestLabel(Interaction interaction,
+			ExporterContext context) throws java.io.IOException {		
+		TextFormatter formatter=(TextFormatter)context.getFormatter();
+
+		if (interaction.getRequestLabel() != null) {
+			formatter.record(" request \""+
+					interaction.getRequestLabel()+"\"");
+		}
+	}
+	
+	/**
+	 * This method exports the text related to an interactions
+	 * 'replyTo' label.
+	 * 
+	 * @param interaction The interaction
+	 * @param context The export context
+	 * @throws java.io.IOException Failed to export information
+	 */
+	protected void exportReplyToLabel(Interaction interaction,
+			ExporterContext context) throws java.io.IOException {		
+		TextFormatter formatter=(TextFormatter)context.getFormatter();
+
+		if (interaction.getReplyToLabel() != null) {
+			formatter.record(" replyTo \""+
+					interaction.getReplyToLabel()+"\"");
+		}
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/MessageSignatureTextExportRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/MessageSignatureTextExportRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/MessageSignatureTextExportRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 21 Dec 2007 : Initial version created by gary
+ */
+package org.scribble.export.text;
+
+import org.scribble.export.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+
+/**
+ * This class implements the text based export rule for the
+ * MessageSignature entity.
+ */
+ at RegistryInfo(extension=ExportRule.class)
+public class MessageSignatureTextExportRule implements ExportRule {
+
+	/**
+	 * This method determines whether the exporter rule is appropriate
+	 * for the supplied model object and format.
+	 * 
+	 * @param modelObject The model object
+	 * @param format The format
+	 * @return Whether the rule is appropriate for the model object and
+	 * 						format
+	 */
+	public boolean isSupported(ModelObject modelObject, Formatter format) {
+		return(MessageSignature.class.isAssignableFrom(modelObject.getClass()) &&
+				format instanceof TextFormatter);
+	}
+
+	/**
+	 * This method exports the model object.
+	 * 
+	 * @param modelObject The model object
+	 * @param context The context
+	 * @throws IOException Failed to record export information
+	 */
+	public void export(ModelObject modelObject, ExporterContext context)
+							throws java.io.IOException {
+		MessageSignature sig=(MessageSignature)modelObject;
+		TextFormatter formatter=(TextFormatter)context.getFormatter();
+		
+		if (sig.getOperation() != null) {
+			formatter.record(sig.getOperation());
+			
+			formatter.record("(");
+		}
+		
+		for (int i=0; i < sig.getTypes().size(); i++) {
+			if (i > 0) {
+				formatter.record(", ");
+			}
+			context.export(sig.getTypes().get(i));
+		}
+		
+		if (sig.getOperation() != null) {
+			formatter.record(")");
+		}
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/ModelNameTextExportRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/ModelNameTextExportRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/ModelNameTextExportRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 20 Dec 2007 : Initial version created by gary
+ */
+package org.scribble.export.text;
+
+import org.scribble.export.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+
+/**
+ * This class implements the text based export rule for the
+ * ModelName entity.
+ */
+ at RegistryInfo(extension=ExportRule.class)
+public class ModelNameTextExportRule implements ExportRule {
+
+	/**
+	 * This method determines whether the exporter rule is appropriate
+	 * for the supplied model object and format.
+	 * 
+	 * @param modelObject The model object
+	 * @param format The format
+	 * @return Whether the rule is appropriate for the model object and
+	 * 						format
+	 */
+	public boolean isSupported(ModelObject modelObject, Formatter format) {
+		return(LocatedName.class.isAssignableFrom(modelObject.getClass()) &&
+				format instanceof TextFormatter);
+	}
+
+	/**
+	 * This method exports the model object.
+	 * 
+	 * @param modelObject The model object
+	 * @param context The context
+	 * @throws IOException Failed to record export information
+	 */
+	public void export(ModelObject modelObject, ExporterContext context)
+							throws java.io.IOException {
+		LocatedName modelName=(LocatedName)modelObject;
+		TextFormatter formatter=(TextFormatter)context.getFormatter();
+		
+		formatter.record(modelName.getName());
+		
+		if (modelName.getRole() != null) {
+			formatter.record("@"+modelName.getRole());
+		}
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/NamespaceTextExportRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/NamespaceTextExportRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/NamespaceTextExportRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 17 Dec 2007 : Initial version created by gary
+ */
+package org.scribble.export.text;
+
+import org.scribble.export.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.ModelObject;
+import org.scribble.model.Namespace;
+
+/**
+ * This class implements the text based export rule for the
+ * Namespace entity.
+ */
+ at RegistryInfo(extension=ExportRule.class)
+public class NamespaceTextExportRule implements ExportRule {
+
+	/**
+	 * This method determines whether the exporter rule is appropriate
+	 * for the supplied model object and format.
+	 * 
+	 * @param modelObject The model object
+	 * @param format The format
+	 * @return Whether the rule is appropriate for the model object and
+	 * 						format
+	 */
+	public boolean isSupported(ModelObject modelObject, Formatter format) {
+		return(Namespace.class.isAssignableFrom(modelObject.getClass()) &&
+				format instanceof TextFormatter);
+	}
+
+	/**
+	 * This method exports the model object.
+	 * 
+	 * @param modelObject The model object
+	 * @param context The context
+	 * @throws IOException Failed to record export information
+	 */
+	public void export(ModelObject modelObject, ExporterContext context)
+							throws java.io.IOException {
+		Namespace namespace=(Namespace)modelObject;
+		TextFormatter formatter=(TextFormatter)context.getFormatter();
+		
+		formatter.record("namespace "+namespace.getName());
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/RoleListTextExportRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/RoleListTextExportRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/RoleListTextExportRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 20 Dec 2007 : Initial version created by gary
+ */
+package org.scribble.export.text;
+
+import org.scribble.export.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+
+/**
+ * This class implements the text based export rule for the
+ * RoleList entity.
+ */
+ at RegistryInfo(extension=ExportRule.class)
+public class RoleListTextExportRule implements ExportRule {
+
+	/**
+	 * This method determines whether the exporter rule is appropriate
+	 * for the supplied model object and format.
+	 * 
+	 * @param modelObject The model object
+	 * @param format The format
+	 * @return Whether the rule is appropriate for the model object and
+	 * 						format
+	 */
+	public boolean isSupported(ModelObject modelObject, Formatter format) {
+		return(RoleList.class.isAssignableFrom(modelObject.getClass()) &&
+				format instanceof TextFormatter);
+	}
+
+	/**
+	 * This method exports the model object.
+	 * 
+	 * @param modelObject The model object
+	 * @param context The context
+	 * @throws IOException Failed to record export information
+	 */
+	public void export(ModelObject modelObject, ExporterContext context)
+							throws java.io.IOException {
+		RoleList rolelist=(RoleList)modelObject;
+		TextFormatter formatter=(TextFormatter)context.getFormatter();
+		
+		formatter.record("role\t");
+		
+		for (int i=0; i < rolelist.getRoles().size(); i++) {
+			if (i > 0) {
+				formatter.record(", ");
+			}
+			context.export(rolelist.getRoles().get(i));
+		}
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/RoleTextExportRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/RoleTextExportRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/RoleTextExportRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 20 Dec 2007 : Initial version created by gary
+ */
+package org.scribble.export.text;
+
+import org.scribble.export.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+
+/**
+ * This class implements the text based export rule for the
+ * Role entity.
+ */
+ at RegistryInfo(extension=ExportRule.class)
+public class RoleTextExportRule implements ExportRule {
+
+	/**
+	 * This method determines whether the exporter rule is appropriate
+	 * for the supplied model object and format.
+	 * 
+	 * @param modelObject The model object
+	 * @param format The format
+	 * @return Whether the rule is appropriate for the model object and
+	 * 						format
+	 */
+	public boolean isSupported(ModelObject modelObject, Formatter format) {
+		return(Role.class.isAssignableFrom(modelObject.getClass()) &&
+				format instanceof TextFormatter);
+	}
+
+	/**
+	 * This method exports the model object.
+	 * 
+	 * @param modelObject The model object
+	 * @param context The context
+	 * @throws IOException Failed to record export information
+	 */
+	public void export(ModelObject modelObject, ExporterContext context)
+							throws java.io.IOException {
+		Role role=(Role)modelObject;
+		TextFormatter formatter=(TextFormatter)context.getFormatter();
+		
+		formatter.record(role.getName());
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/TextFormatter.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/TextFormatter.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/TextFormatter.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,158 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 13 Dec 2007 : Initial version created by gary
+ */
+package org.scribble.export.text;
+
+import org.scribble.export.*;
+
+/**
+ * This class provides the text based implementation of the
+ * Formatter interface.
+ */
+public class TextFormatter extends AbstractFormatter {
+
+	/**
+	 * The default constructor.
+	 */
+	public TextFormatter() {
+		super(TEXT_FORMAT);
+	}
+	
+	/**
+	 * This method sets the output stream to use with the formatter.
+	 * 
+	 * @param os The output stream
+	 */
+	public void setOutputStream(java.io.OutputStream os) {
+		m_outputStream = os;
+	}
+	
+	/**
+	 * This method returns the output stream.
+	 * 
+	 * @return The output stream
+	 */
+	public java.io.OutputStream getOutputStream() {
+		return(m_outputStream);
+	}
+	
+	/**
+	 * This method records the supplied text.
+	 * 
+	 * @param value The information to record
+	 * @throws IOException Failed to record text
+	 */
+	public void record(Object value) throws java.io.IOException {
+		
+		if (value instanceof String) {
+			String text=(String)value;
+			
+			if (m_endOfBlock && text.charAt(0) != ' ') {
+				String str = "\r\n";
+				
+				m_outputStream.write(str.getBytes());
+
+				m_emptyLine = true;
+			}
+			
+			if (m_emptyLine) {
+				// Indent to the appropriate level
+				String str = "\t";
+				
+				for (int i=0; i < getLevel(); i++) {
+					m_outputStream.write(str.getBytes());
+				}
+			}
+			
+			m_outputStream.write(text.getBytes());
+		}
+				
+		m_emptyLine = false;
+		m_endOfBlock = false;
+	}
+	
+	/**
+	 * This method instructs the formatter to end the statement.
+	 */
+	@Override
+	protected void endStatement() throws java.io.IOException {
+		
+		record(";\r\n");
+
+		m_emptyLine = true;
+	}
+
+	/**
+	 * This method instructs the formatter to increase the indentation
+	 * level.
+	 * 
+	 * @throws IOException Failed to increase level
+	 */
+	@Override
+	public void startBlock() throws java.io.IOException {
+		
+		record(" {\r\n");
+		
+		m_emptyLine = true;
+		
+		super.startBlock();
+	}
+
+	/**
+	 * This method instructs the formatter to decrease the indentation
+	 * level.
+	 * 
+	 * @throws IOException Failed to end block
+	 */
+	@Override
+	public void endBlock() throws java.io.IOException {
+		super.endBlock();
+		
+		record("}");
+		
+		m_endOfBlock = true;
+	}
+	
+	/**
+	 * This method cancels the indication of end of block.
+	 * This can be used to allow follow on activities to
+	 * continue their text export after the end of block
+	 * symbol, instead of being placed on a new line.
+	 */
+	public void cancelEndOfBlock() {
+		m_endOfBlock = false;
+	}
+
+	/**
+	 * This method closes the formatter.
+	 * 
+	 * @throws IOException Failed to close formatter
+	 */
+	public void close() throws java.io.IOException {
+		if (m_outputStream != null) {
+			m_outputStream.close();
+		}
+	}
+
+	public static final String TEXT_FORMAT="Text";
+	
+	private java.io.OutputStream m_outputStream=null;
+	private boolean m_endOfBlock=false;
+	private boolean m_emptyLine=true;
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/TypeReferenceTextExportRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/TypeReferenceTextExportRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/export/text/TypeReferenceTextExportRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 20 Dec 2007 : Initial version created by gary
+ */
+package org.scribble.export.text;
+
+import org.scribble.export.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+
+/**
+ * This class implements the text based export rule for the
+ * TypeReference entity.
+ */
+ at RegistryInfo(extension=ExportRule.class)
+public class TypeReferenceTextExportRule
+					extends AbstractModelReferenceTextExportRule {
+
+	/**
+	 * This method determines whether the exporter rule is appropriate
+	 * for the supplied model object and format.
+	 * 
+	 * @param modelObject The model object
+	 * @param format The format
+	 * @return Whether the rule is appropriate for the model object and
+	 * 						format
+	 */
+	public boolean isSupported(ModelObject modelObject, Formatter format) {
+		return(super.isSupported(modelObject, format) &&
+				TypeReference.class.isAssignableFrom(modelObject.getClass()));
+	}
+
+	/**
+	 * This method exports the model object.
+	 * 
+	 * @param modelObject The model object
+	 * @param context The context
+	 * @throws IOException Failed to record export information
+	 */
+	public void export(ModelObject modelObject, ExporterContext context)
+							throws java.io.IOException {
+		TypeReference ref=(TypeReference)modelObject;
+		
+		super.export(ref, context);
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/extensions/AbstractRegistry.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/extensions/AbstractRegistry.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/extensions/AbstractRegistry.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,315 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 16 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.extensions;
+
+import java.util.logging.*;
+
+/**
+ * An abstract implementation of the registry interface.
+ */
+public abstract class AbstractRegistry implements Registry {
+
+	public static final String SCRIBBLE_EXTENSIONS = "Scribble-Extensions";
+
+	/**
+	 * This method triggers the initialization of the
+	 * registry based on extensions in the environment.
+	 * 
+	 * @throws RegistryException Failed to initialize the registry
+	 */
+	public abstract void initialize() throws RegistryException;
+	
+	/**
+	 * This method adds a new extension based on its
+	 * class. The class must provide an annotation (RegistryInfo) to
+	 * provide the information necessary for the registry.
+	 * 
+	 * @param cls The extension class
+	 * @throws RegistryException Failed to add extension
+	 */
+	public void addExtension(Class<?> cls) throws RegistryException {
+		RegistryInfo config=null;
+		
+		// Check whether class has a configuration
+		if ((config=(RegistryInfo)cls.getAnnotation(RegistryInfo.class)) != null) {
+			Class<?> intf=config.extension();
+			
+			java.util.List<Class<?>> clsList=m_extensionClasses.get(intf);
+			
+			if (clsList == null) {
+				clsList = new java.util.Vector<Class<?>>();
+				m_extensionClasses.put(intf, clsList);
+			}
+			
+			clsList.add(cls);
+			
+			// Check if extension is a service that should be
+			// registered
+			if (config.isService()) {
+				registerService(config, cls);
+			}
+			
+			// Check if extension is a notation that should be
+			// maintained in a separate map
+			if (org.scribble.model.Notation.class == intf) {
+				try {
+					org.scribble.model.Notation notation=
+							(org.scribble.model.Notation)cls.newInstance();
+					
+					m_notations.put(notation.getCode(), notation);
+				} catch(Exception e) {
+					logger.severe("Failed to add notation: "+e);
+				}
+			}
+			
+		} else {
+			throw new RegistryException("Class '"+cls.getName()+
+					"' does not have registry information");
+		}
+	}
+	
+	/**
+	 * This method removes an extension based on its
+	 * class.
+	 * 
+	 * @param cls The extension class
+	 * @throws RegistryException Failed to remove extension
+	 */
+	public void removeExtension(Class<?> cls) throws RegistryException {
+		
+		// TODO: Need to implement
+	}
+	
+	/**
+	 * This method registers the service.
+	 * 
+	 * @param config The registry configuration
+	 * @param cls The extension implementation
+	 * @throws RegistryException Failed to register service
+	 */
+	protected void registerService(RegistryInfo config,
+					Class<?> cls) throws RegistryException {
+	}
+	
+	/**
+	 * This method returns the extension associated with the
+	 * supplied interface.
+	 * 
+	 * @param intf The interface associated with the required extension
+	 * @param notation The optional notation
+	 * @return The extension
+	 */
+	public Object getExtension(Class<?> intf, String notation) {
+		Object ret=null;
+		
+		// ISSUE: What if mix of stateless and stateful implementations?
+		// should we maintain a list
+		
+		java.util.List<?> instList=getInstanceList(intf, notation);
+			
+		if (instList != null && instList.size() > 0) {
+			ret = instList.get(0);
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the set of extensions associated with
+	 * the supplied interface.
+	 * 
+	 * @param intf The interface
+	 * @param notation The optional notation
+	 * @return The list of extensions associated with the interface
+	 */
+	public java.util.List<Object> getExtensions(Class<?> intf, String notation) {
+		return(getInstanceList(intf, notation));
+	}
+	
+	/**
+	 * This method returns the list of instances associated with the
+	 * supplied interface. The list is ordered in terms of precise match
+	 * to notation followed by imprecise match. (Note: currently the
+	 * imprecise matches are not ordered in terms of how imprecise they
+	 * are, so if a precise match is not found, then an implementation
+	 * of the supplied interface for one of the notations 'super notations',
+	 * will be returned if it exists).
+	 * 
+	 * @param intf The interface
+	 * @param notation The optional notation
+	 * @return The list of instances
+	 */
+	protected java.util.List<Object> getInstanceList(Class<?> intf, String notation) {
+		java.util.List<Object> ret=null;
+		NotationDetails details=null;
+		
+		synchronized(m_notationDetails) {
+			details = m_notationDetails.get(notation==null?"null":notation);
+			
+			if (details == null) {
+				details = new NotationDetails();
+				m_notationDetails.put(notation==null?"null":notation, details);
+			}
+		}
+		
+		synchronized(details) {
+			// Check if instance available
+			if (details.hasServiceInstances(intf)) {
+				ret = details.getServiceInstances(intf);
+			} else {
+				java.util.List<Class<?>> list=m_extensionClasses.get(intf);
+				
+				if (list != null && list.size() > 0) {
+					ret = new java.util.Vector<Object>();
+					
+					for (int i=0; i < list.size(); i++) {
+						Class<?> cls=(Class<?>)list.get(i);
+						RegistryInfo config=(RegistryInfo)
+								cls.getAnnotation(RegistryInfo.class);
+					
+						int suitability=getNotationSuitability(notation, config.notation());
+						
+						if (suitability >= 0) {
+							try {
+								if (suitability == 0) {
+									ret.add(0, cls.newInstance());
+								} else {
+									ret.add(cls.newInstance());
+								}
+							} catch(Exception e) {
+								logger.log(Level.SEVERE,
+										"Failed to instantiate the class '"+
+										cls.getName()+"'", e);
+							}
+						}
+					}
+
+					// Remove overridden extensions
+					filterOverriddenExtensions(ret);
+					
+					details.addServiceInstances(intf, ret);
+				}
+			}
+		}
+
+		if (ret == null) {
+			ret = new java.util.Vector<Object>();
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method iterates through the list of objects to determine
+	 * whether extensions have been overridden, and therefore
+	 * should be removed.
+	 * 
+	 * @param list The list of objects to be filtered.
+	 */
+	protected static void filterOverriddenExtensions(java.util.List<Object> list) {
+		
+		for (int i=0; i < list.size(); i++) {
+			boolean f_remove=false;
+			
+			for (int j=0; f_remove == false &&
+						j < list.size(); j++) {
+				
+				if (i != j &&
+					list.get(i).getClass().isAssignableFrom(
+							list.get(j).getClass())) {
+					f_remove = true;
+				}
+			}
+			
+			if (f_remove) {
+				list.remove(i);
+				i--;
+			}
+		}
+	}
+	
+	/**
+	 * This method determines if the supplied notation is suitable for
+	 * the configured notation value.
+	 * 
+	 * @param supplied The supplied notation
+	 * @param config The notation associated with the extension
+	 * @return Notation suitability rating, -1 not suitable, 0 precise match, 1 and
+	 * 			above represent levels of generality
+	 */
+	protected int getNotationSuitability(String supplied, String config) {
+		int ret=-1;
+		
+		if (supplied == null || config.equals("") ||
+				supplied.equals(config)) {
+			ret = 0;
+		} else {
+			java.util.StringTokenizer st=new java.util.StringTokenizer(config,",");
+			
+			while (ret == -1 && st.hasMoreTokens()) {
+				String notation=st.nextToken();
+				int count=0;
+				
+				org.scribble.model.Notation n=
+							m_notations.get(supplied);
+				
+				while (ret == -1 && n != null) {
+					if (notation.equals(n.getCode())) {
+						ret = count;
+					} else {
+						n = n.getSuperNotation();
+						count++;
+					}
+				}
+			}
+		}
+		
+		return(ret);
+	}
+	
+	private static final Logger logger=Logger.getLogger("org.scribble.extensions");
+
+	private java.util.Map<Class<?>,java.util.List<Class<?>>> m_extensionClasses=
+		new java.util.Hashtable<Class<?>, java.util.List<Class<?>>>();
+	private java.util.Map<String, NotationDetails> m_notationDetails=
+		new java.util.Hashtable<String, NotationDetails>();
+	private java.util.Map<String,org.scribble.model.Notation> m_notations=
+				new java.util.HashMap<String,org.scribble.model.Notation>();
+	
+	public class NotationDetails {
+		public NotationDetails() {
+		}
+		
+		public void addServiceInstances(Class<?> intf, java.util.List<Object> insts) {
+			m_serviceInstances.put(intf, insts);
+		}
+		
+		public boolean hasServiceInstances(Class<?> intf) {
+			return(m_serviceInstances.containsKey(intf));
+		}
+		
+		public java.util.List<Object> getServiceInstances(Class<?> intf) {
+			return(m_serviceInstances.get(intf));
+		}
+		
+		private java.util.Map<Class<?>,java.util.List<Object>> m_serviceInstances=
+			new java.util.Hashtable<Class<?>, java.util.List<Object>>();		
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/extensions/ClasspathRegistry.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/extensions/ClasspathRegistry.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/extensions/ClasspathRegistry.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 19 Jan 2009 : Initial version created by gary
+ */
+package org.scribble.extensions;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * This registry implementation uses the classpath to
+ * locate the relevant extensions.
+ */
+public class ClasspathRegistry extends AbstractRegistry {
+
+	public static void main(String[] args) {
+		ClasspathRegistry cr=new ClasspathRegistry();
+		
+		try {
+			cr.initialize();
+		} catch(Exception e) {
+			e.printStackTrace();
+		}
+	}
+	
+	/**
+	 * This method determines if the registry implementation is
+	 * active.
+	 * 
+	 * @return Whether the registry is active
+	 */
+	public boolean isActive() {
+		return(true);
+	}
+	
+	/**
+	 * This method triggers the initialization of the
+	 * registry based on extensions in the environment.
+	 * 
+	 * @throws RegistryException Failed to initialize the registry
+	 */
+	public void initialize() throws RegistryException {
+		
+		String cpath=System.getProperties().getProperty("java.class.path");
+		
+		java.util.StringTokenizer st=new java.util.StringTokenizer(cpath, ";:");
+		
+		while (st.hasMoreTokens()) {
+			String path=st.nextToken();
+			
+			if (logger.isLoggable(Level.FINE)) {
+				logger.fine("Path="+path);
+			}
+			
+			if (path.endsWith(".jar")) {
+				try {
+					java.util.jar.JarFile jarFile=
+								new java.util.jar.JarFile(path);
+					
+					java.util.jar.Manifest manifest=
+									jarFile.getManifest();
+					
+					String scribbleExtensions=
+							manifest.getMainAttributes().getValue(SCRIBBLE_EXTENSIONS);
+
+					if (scribbleExtensions != null) {
+						registerExtensions(scribbleExtensions);
+					}
+				} catch(Exception e) {
+					e.printStackTrace();
+				}
+			}
+		}
+	}
+	
+	/**
+	 * This method registers the individual extension class names
+	 * in the supplied comma-separated list.
+	 * 
+	 * @param extensions The comma-separated list of extension
+	 * 				class names
+	 */
+	protected void registerExtensions(String extensions) {
+		java.util.StringTokenizer st=
+				new java.util.StringTokenizer(extensions, ", ");
+		
+		while (st.hasMoreTokens()) {
+			String extension=st.nextToken();
+			
+			if (logger.isLoggable(Level.FINE)) {
+				logger.fine("Register extension: "+extension);
+			}
+			
+			try {
+				Class<?> cls=Class.forName(extension);
+				
+				if (cls != null) {
+					addExtension(cls);
+				}
+			} catch(Exception e) {				
+				logger.log(Level.SEVERE, "Failed to register extension '"+
+								extension+"'", e);
+			}
+		}
+	}
+	
+	private static Logger logger = Logger.getLogger("org.scribble.extensions");
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/extensions/OSGiRegistry.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/extensions/OSGiRegistry.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/extensions/OSGiRegistry.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,147 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 19 Jan 2009 : Initial version created by gary
+ */
+package org.scribble.extensions;
+
+import java.util.logging.Logger;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+
+/**
+ * This registry implementation uses the classpath to
+ * locate the relevant extensions.
+ */
+public class OSGiRegistry extends AbstractRegistry {
+
+	/**
+	 * This constructor is for the OSGiRegistry, initialised
+	 * with the OSGi bundle context.
+	 * 
+	 * @param context The bundle context
+	 */
+	public OSGiRegistry(BundleContext context) {
+		m_context = context;
+	}
+	
+	/**
+	 * This method determines if the registry implementation is
+	 * active.
+	 * 
+	 * @return Whether the registry is active
+	 */
+	public boolean isActive() {
+		return(true);
+	}
+	
+	/**
+	 * This method triggers the initialization of the
+	 * registry based on extensions in the environment.
+	 * 
+	 * @throws RegistryException Failed to initialize the registry
+	 */
+	public void initialize() throws RegistryException {
+		
+		if (m_context != null) {
+			Bundle[] bundles=m_context.getBundles();
+
+			for (int i=0; i < bundles.length; i++) {
+				Bundle bundle=bundles[i];
+				
+				if (bundle != null) {
+					Object val=bundle.getHeaders().get(SCRIBBLE_EXTENSIONS);
+					
+					if (val instanceof String) {
+						java.util.StringTokenizer st=new java.util.StringTokenizer((String)val, ", ");
+						
+						while (st.hasMoreTokens()) {
+							String clsName=st.nextToken();
+							
+							try {
+								Class<?> cls=bundle.loadClass(clsName);
+								addExtension(cls);
+								
+								if (logger.isLoggable(java.util.logging.Level.FINE)) {
+									logger.fine("Registered scribble extension: "+cls);
+								}
+								
+							} catch(Exception e) {
+								e.printStackTrace();
+							}
+						}
+					}
+				}
+			}
+		}
+	}
+
+	/**
+	 * This method registers the individual extension class names
+	 * in the supplied comma-separated list.
+	 * 
+	 * @param extensions The comma-separated list of extension
+	 * 				class names
+	 */
+	protected void registerExtensions(String extensions) {
+		java.util.StringTokenizer st=
+				new java.util.StringTokenizer(extensions, ", ");
+		
+		while (st.hasMoreTokens()) {
+			String extension=st.nextToken();
+			
+			try {
+				Class<?> cls=Class.forName(extension);
+				
+				if (cls != null) {
+					addExtension(cls);
+				}
+			} catch(Exception e) {
+				e.printStackTrace();
+			}
+		}
+	}
+	
+	/**
+	 * This method registers the service.
+	 * 
+	 * @param config The registry configuration
+	 * @param cls The extension implementation
+	 * @throws RegistryException Failed to register service
+	 */
+	protected void registerService(RegistryInfo config,
+					Class<?> cls) throws RegistryException {
+		try {
+			m_context.registerService(config.extension().getName(),
+						cls.newInstance(), null);
+			
+			logger.info("Registered '"+
+					config.extension().getName()+"' against implementation '"+
+					cls.getName()+"'");
+			
+		} catch(Exception e) {
+			throw new RegistryException("Failed to register service '"+
+					config.extension().getName()+"' against implementation '"+
+					cls.getName()+"': "+e, e);
+		}
+	}
+	
+	private static Logger logger = Logger.getLogger("org.scribble.extensions");
+
+	private BundleContext m_context=null;
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/extensions/Registry.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/extensions/Registry.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/extensions/Registry.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 16 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.extensions;
+
+/**
+ * This interface represents the registry of extensions
+ * available within the environment.
+ */
+public interface Registry {
+	
+	/**
+	 * This method determines if the registry implementation is
+	 * active.
+	 * 
+	 * @return Whether the registry is active
+	 */
+	public boolean isActive();
+	
+	/**
+	 * This method returns the extension associated with the
+	 * supplied interface.
+	 * 
+	 * @param intf The interface associated with the required extension
+	 * @param notation The optional notation
+	 * @return The extension
+	 */
+	public Object getExtension(Class<?> intf, String notation);
+	
+	/**
+	 * This method returns the set of extensions associated with
+	 * the supplied interface.
+	 * 
+	 * @param intf The interface
+	 * @param notation The optional notation
+	 * @return The list of extensions associated with the interface
+	 */
+	public java.util.List<Object> getExtensions(Class<?> intf, String notation);
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/extensions/RegistryException.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/extensions/RegistryException.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/extensions/RegistryException.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 16 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.extensions;
+
+/**
+ * This class represents a registry exception.
+ *
+ */
+public class RegistryException extends Exception {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 4132588615349997229L;
+
+	/**
+	 * This method initializes the registry
+	 * exception with a message.
+	 * 
+	 * @param mesg The reason for the exception
+	 */
+	public RegistryException(String mesg) {
+		super(mesg);
+	}
+	
+	/**
+	 * This method initializes the registry
+	 * exception with a message and an associated
+	 * exception.
+	 * 
+	 * @param mesg The reason for the exception
+	 * @param t The associated exception
+	 */
+	public RegistryException(String mesg, Throwable t) {
+		super(mesg, t);
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/extensions/RegistryFactory.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/extensions/RegistryFactory.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/extensions/RegistryFactory.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,110 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 16 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.extensions;
+
+import java.util.logging.*;
+
+/**
+ * This class provides a factory mechanism for retrieving the extension
+ * registry.
+ */
+public class RegistryFactory {
+	
+	/**
+	 * This method returns the registry.
+	 * 
+	 * @return The extension registry
+	 */
+	public static synchronized Registry getRegistry() {
+		
+		if (m_registry == null) {
+			m_registry = createRegistry();
+		}
+		
+		return(m_registry);
+	}
+	
+	/**
+	 * This method sets the registry implementation to be
+	 * used.
+	 * 
+	 * @param registry The registry
+	 */
+	public static void setRegistry(Registry registry) {
+		m_registry = registry;
+	}
+	
+	/**
+	 * This method creates the registry.
+	 * 
+	 * @return The registry
+	 */
+	protected static Registry createRegistry() {
+		Registry ret=null;
+		
+		// Check if system property has been set
+		if (System.getProperties().containsKey("org.scribble.registry.class")) {
+			String clsName=System.getProperty("org.scribble.registry.class");
+			
+			try {
+				Class<?> cls=Class.forName(clsName);
+				ret = (Registry)cls.newInstance();
+			} catch(Exception e) {
+				logger.log(Level.FINE,
+						"Unable to instantiate registry '"+
+						clsName+"'", e);
+			}
+		} else {
+		
+			// Instantiate the first available registry implementation
+			for (int i=0; ret == null &&
+						i < m_registryImpls.length; i++) {
+				
+				try {
+					Class<?> cls=Class.forName(m_registryImpls[i]);
+					ret = (Registry)cls.newInstance();
+					
+					if (ret.isActive() == false) {
+						ret = null;
+					} else if (ret instanceof AbstractRegistry) {
+						((AbstractRegistry)ret).initialize();
+					}
+					
+				} catch(Exception e) {
+					logger.log(Level.FINE,
+							"Unable to instantiate registry '"+
+							m_registryImpls[i]+"'", e);
+					ret = null;
+				}
+			}
+		}
+		
+		return(ret);
+	}
+	
+	private static Logger logger=Logger.getLogger("org.scribble.extensions");
+	
+	private static Registry m_registry=null;
+	
+	private static final String[] m_registryImpls={
+		"org.scribble.extensions.EclipseRegistry",
+		"org.scribble.extensions.ClasspathRegistry"
+	};
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/extensions/RegistryInfo.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/extensions/RegistryInfo.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/extensions/RegistryInfo.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 16 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.extensions;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation type defines the information required by the extension
+ * registry, to be able to determine preference order between multiple
+ * extensions of the same interface type, aswell as determine whether
+ * the same extension instance can be returned each time, or whether
+ * a new instance has to be created (i.e. if stateful).
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target(ElementType.TYPE)
+public @interface RegistryInfo {
+	Class<?> extension();
+	String notation() default "";
+	boolean isService() default false;
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/AbstractNotation.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/AbstractNotation.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/AbstractNotation.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 23 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.model;
+
+/**
+ * This abstract implementation .
+ */
+public abstract class AbstractNotation implements Notation {
+
+	/**
+	 * The constructor to initialise the details associated
+	 * with the notation.
+	 * 
+	 * @param code The code
+	 * @param name The name
+	 * @param useScribbleEditor Whether the scribble editor
+	 * 						should be used
+	 */
+	public AbstractNotation(String code, String name,
+					boolean useScribbleEditor) {
+		m_code = code;
+		m_name = name;
+		m_useScribbleEditor = useScribbleEditor;
+	}
+	
+	/**
+	 * This method returns the code associated with the notation.
+	 * 
+	 * @return The notation code
+	 */
+	public String getCode() {
+		return(m_code);
+	}
+	
+	/**
+	 * This method returns the name of the notation.
+	 * 
+	 * @return The name
+	 */
+	public String getName() {
+		return(m_name);
+	}
+	
+	/**
+	 * This method returns the initial description associated
+	 * with the supplied reference.
+	 * 
+	 * @param ref The reference
+	 * @return The initial description, or null if no description
+	 */
+	public String getInitialDescription(ModelReference ref) {
+		return(null);
+	}
+	
+	/**
+	 * This method determines whether the Scribble editor should
+	 * be used for editing the notation.
+	 * 
+	 * @return Whether the Scribble editor should be used
+	 */
+	public boolean useScribbleEditor() {
+		return(m_useScribbleEditor);
+	}
+	
+	/**
+	 * This method returns the optional 'super' notation.
+	 * If defined, then this notation is a derived notation
+	 * from the 'super' notation.
+	 * 
+	 * @return The optional 'super' notation
+	 */
+	public Notation getSuperNotation() {
+		return(null);
+	}
+	
+	private String m_code=null;
+	private String m_name=null;
+	private boolean m_useScribbleEditor=false;
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Activity.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Activity.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Activity.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 22 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.model;
+
+/**
+ * This class represents the base class for all Scribble definition
+ * components.
+ */
+public abstract class Activity extends Statement {
+	
+	private static final long serialVersionUID = 907254090600526766L;
+
+	/**
+	 * This method returns the list of roles that are
+	 * responsible for initiating the activity. This can
+	 * be used to determine whether the model is
+	 * consistent in terms of decision makers subsequently
+	 * initiating actions.
+	 * 
+	 * @return The list of initiator roles
+	 */
+	public java.util.List<Role> getInitiatorRoles() {
+		return(new java.util.Vector<Role>());
+	}
+
+	/**
+	 * This method returns the list of roles that are
+	 * associated with the outcome of the activity.
+	 * 
+	 * @return The list of final roles
+	 */
+	public java.util.List<Role> getFinalRoles() {
+		return(new java.util.Vector<Role>());
+	}
+	
+	/**
+	 * This method returns the optional located role
+	 * associated with the enclosing definition.
+	 * 
+	 * @return The located role, or null if the
+	 * 			enclosing definition is not located
+	 */
+	protected Role getLocatedRole() {
+		Role ret=null;
+		
+		if (getParent() instanceof Activity) {
+			ret = ((Activity)getParent()).getLocatedRole();
+		}
+		
+		return(ret);
+	}
+
+	/**
+	 * This method returns the definition in which this
+	 * activity is contained.
+	 * 
+	 * @return The definition, or null if not found
+	 */
+	public Definition getEnclosingDefinition() {
+		Definition ret=null;
+		
+		if (getParent() instanceof Activity) {
+			ret = ((Activity)getParent()).getEnclosingDefinition();
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method indicates whether the activity
+	 * is a conditional construct.
+	 * 
+	 * @return Whether the activity is conditional
+	 */
+	public boolean isConditional() {
+		return(false);
+	}
+	
+	/**
+	 * This method returns whether the activity represents
+	 * a scope.
+	 * 
+	 * @return Whether activity represents a scope
+	 */
+	public boolean isScope() {
+		return(false);
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Annotations.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Annotations.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Annotations.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 20 Apr 2009 : Initial version created by gary
+ */
+package org.scribble.model;
+
+/**
+ * This class represents a map of named serializable
+ * information that can be used to provide additional
+ * details about a model component.
+ */
+public class Annotations extends java.util.HashMap<String,Object> {
+
+	private static final long serialVersionUID = -4594153737794956180L;
+
+	/**
+	 * The default constructor.
+	 */
+	public Annotations() {
+	}
+	
+	/**
+	 * This is the copy constructor.
+	 * 
+	 * @param annotations The annotations to copy
+	 */
+	public Annotations(Annotations annotations) {
+		putAll(annotations);
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Behaviour.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Behaviour.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Behaviour.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 25 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.model;
+
+/**
+ * This class represents the base class for all Scribble behavioural
+ * activities.
+ */
+public abstract class Behaviour extends Activity {
+
+	private static final long serialVersionUID = -487404402751133649L;
+
+	/**
+	 * This method returns whether the behaviour is a grouping
+	 * construct.
+	 * 
+	 * @return Whether the behaviour is a grouping construct 
+	 */
+	public boolean isGroupingConstruct() {
+		return(false);
+	}
+	
+	/**
+	 * This method returns whether the behaviour is a wait
+	 * state.
+	 * 
+	 * @return Whether the behaviour is a wait state
+	 */
+	public boolean isWaitState() {
+		return(false);
+	}
+	
+	/**
+	 * This method returns the list of roles that are
+	 * associated with the behaviour.
+	 * 
+	 * @return The list of associated roles
+	 */
+	public java.util.List<Role> getAssociatedRoles() {
+		return(new java.util.Vector<Role>());
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Block.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Block.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Block.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 29 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.model;
+
+/**
+ * This class represents a group of activities.
+ * 
+ */
+public class Block extends Activity {
+
+	private static final long serialVersionUID = 6629455247154922281L;
+
+	/**
+	 * This method returns the contents associated with
+	 * the block.
+	 * 
+	 * @return The contents
+	 */
+	@Reference(containment=true)
+	public java.util.List<Activity> getContents() {
+		return(m_contents);
+	}
+	
+	/**
+	 * This method returns the list of roles that are
+	 * responsible for initiating the activity. This can
+	 * be used to determine whether the model is
+	 * consistent in terms of decision makers subsequently
+	 * initiating actions.
+	 * 
+	 * @return The list of initiator roles
+	 */
+	@Override
+	public java.util.List<Role> getInitiatorRoles() {
+		java.util.List<Role> ret=super.getInitiatorRoles();
+		boolean f_end=false;
+		
+		for (int i=0; f_end == false &&
+						i < getContents().size(); i++) {
+			
+			if (getContents().get(i) instanceof Behaviour) {
+				java.util.List<Role> roleList=
+					getContents().get(i).getInitiatorRoles();
+				
+				for (int j=0; j < roleList.size(); j++) {
+					if (ret.contains(roleList.get(j)) == false) {
+						ret.add(roleList.get(j));
+					}
+				}
+				
+				if (getContents().get(i).isConditional() == false) {
+					f_end = true;
+				}
+			}
+		}
+		
+		return(ret);
+	}
+
+	private java.util.List<Activity> m_contents=
+		new ContainmentList<Activity>(this, Activity.class);
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Channel.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Channel.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Channel.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,129 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 22 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.model;
+
+/**
+ * This class represents the channel declaration.
+ */
+public class Channel extends ModelObject implements Declaration {
+
+	private static final long serialVersionUID = 1158151945766114601L;
+
+	/**
+	 * This is the default constructor.
+	 */
+	public Channel() {
+	}
+	
+	/**
+	 * This constructor initializes the channel with a name.
+	 * 
+	 * @param name The channel name
+	 */
+	public Channel(String name) {
+		m_name = name;
+	}
+	
+	/**
+	 * This method returns the name of the channel.
+	 * 
+	 * @return The name
+	 */
+	public String getName() {
+		return(m_name);
+	}
+	
+	/**
+	 * This method sets the name of the channel.
+	 * 
+	 * @param name The name
+	 */
+	public void setName(String name) {
+		m_name = name;
+	}
+	
+	/**
+	 * This method returns the 'from' role.
+	 * 
+	 * @return The 'from' role
+	 */
+	public Role getFromRole() {
+		return(m_fromRole);
+	}
+	
+	/**
+	 * This method sets the 'from' role.
+	 * 
+	 * @param role The 'from' role
+	 */
+	public void setFromRole(Role role) {
+		m_fromRole = role;
+	}
+	
+	/**
+	 * This method returns the 'to' role.
+	 * 
+	 * @return The 'to' role
+	 */
+	public Role getToRole() {
+		return(m_toRole);
+	}
+	
+	/**
+	 * This method sets the 'to' role.
+	 * 
+	 * @param role The 'to' role
+	 */
+	public void setToRole(Role role) {
+		m_toRole = role;
+	}
+	
+	public boolean equals(Object obj) {
+		boolean ret=false;
+	
+		if (obj instanceof Channel) {
+			Channel other=(Channel)obj;
+			
+			if (other.getName() != null && other.getName().equals(m_name)) {
+				ret = true;
+			}
+		}
+		
+		return(ret);
+	}
+	
+	public int hashCode() {
+		int ret=super.hashCode();
+		
+		if (m_name != null) {
+			ret = m_name.hashCode();
+		}
+		
+		return(ret);
+	}
+	
+	public String toString() {
+		return(getName());
+	}
+
+	private String m_name=null;
+	private Role m_fromRole=null;
+	private Role m_toRole=null;
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/ChannelList.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/ChannelList.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/ChannelList.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 27 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.model;
+
+/**
+ * This class represents the list of channels declared within
+ * a Scribble definition.
+ */
+public class ChannelList extends Activity {
+
+	private static final long serialVersionUID = 1532837321091960033L;
+
+	/**
+	 * This method returns the list of channels.
+	 * 
+	 * @return The list of channels
+	 */
+	@Reference(containment=true)
+	public java.util.List<Channel> getChannels() {
+		return(m_channels);
+	}
+	
+	private java.util.List<Channel> m_channels=new ContainmentList<Channel>(this, Channel.class);
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/ConformanceReference.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/ConformanceReference.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/ConformanceReference.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 12 Dec 2007 : Initial version created by gary
+ */
+package org.scribble.model;
+
+/**
+ * This class represents a conformance link to another
+ * definition.
+ */
+public class ConformanceReference extends NameMappingReference {
+
+	private static final long serialVersionUID = -6759419194304963409L;
+
+	/**
+	 * This is the constructor for the conformance reference.
+	 * 
+	 * @param notation The notation
+	 */
+	public ConformanceReference(String notation) {
+		super(notation);
+	}
+	
+	/**
+	 * This is the copy constructor for the conformance
+	 * reference.
+	 * 
+	 * @param ref The reference to copy
+	 */
+	public ConformanceReference(ConformanceReference ref) {
+		super(ref);
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/ContainmentList.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/ContainmentList.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/ContainmentList.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,366 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 23 Feb 2008 : Initial version created by gary
+ */
+package org.scribble.model;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Vector;
+
+/**
+ * This class represents a list that understands how to manage
+ * containment and parent relationships.
+ *
+ * @param <E>
+ */
+public class ContainmentList<E extends ModelObject> extends Vector<E> implements List<E> {
+
+	private static final long serialVersionUID = -4226210156656211621L;
+
+	/**
+	 * This is the constructor for the containment list
+	 * @param parent
+	 */
+	public ContainmentList(ModelObject parent, Class<E> type) {
+		m_parent = parent;
+		m_type = type;
+	}
+	
+	/**
+	 * This method returns the base type associated with the list
+	 * elements.
+	 * 
+	 * @return The base type for the list elements
+	 */
+	public Class<E> getType() {
+		return(m_type);
+	}
+
+    /**
+     * Appends the specified element to the end of this list (optional
+     * operation). <p>
+     *
+     * Lists that support this operation may place limitations on what
+     * elements may be added to this list.  In particular, some
+     * lists will refuse to add null elements, and others will impose
+     * restrictions on the type of elements that may be added.  List
+     * classes should clearly specify in their documentation any restrictions
+     * on what elements may be added.
+     *
+     * @param o element to be appended to this list.
+     * @return <tt>true</tt> (as per the general contract of the
+     *            <tt>Collection.add</tt> method).
+     * 
+     * @throws UnsupportedOperationException if the <tt>add</tt> method is not
+     * 		  supported by this list.
+     * @throws ClassCastException if the class of the specified element
+     * 		  prevents it from being added to this list.
+     * @throws NullPointerException if the specified element is null and this
+     *           list does not support null elements.
+     * @throws IllegalArgumentException if some aspect of this element
+     *            prevents it from being added to this list.
+     */
+    public boolean add(E o) {
+    	boolean ret=super.add(o);
+		
+    	if (ret) {
+    		o.setParent(m_parent);
+    	}
+    	
+    	return(ret);
+    }
+    
+    /**
+     * Removes the first occurrence in this list of the specified element 
+     * (optional operation).  If this list does not contain the element, it is
+     * unchanged.  More formally, removes the element with the lowest index i
+     * such that <tt>(o==null ? get(i)==null : o.equals(get(i)))</tt> (if
+     * such an element exists).
+     *
+     * @param o element to be removed from this list, if present.
+     * @return <tt>true</tt> if this list contained the specified element.
+     * @throws ClassCastException if the type of the specified element
+     * 	          is incompatible with this list (optional).
+     * @throws NullPointerException if the specified element is null and this
+     *            list does not support null elements (optional).
+     * @throws UnsupportedOperationException if the <tt>remove</tt> method is
+     *		  not supported by this list.
+     */
+    public boolean remove(Object o) {
+    	boolean ret=super.remove(o);
+    	
+    	if (ret && o instanceof ModelObject) {
+    		((ModelObject)o).setParent(null);
+    	}
+    	
+    	return(ret);
+    }
+
+    /**
+     * Appends all of the elements in the specified collection to the end of
+     * this list, in the order that they are returned by the specified
+     * collection's iterator (optional operation).  The behavior of this
+     * operation is unspecified if the specified collection is modified while
+     * the operation is in progress.  (Note that this will occur if the
+     * specified collection is this list, and it's nonempty.)
+     *
+     * @param c collection whose elements are to be added to this list.
+     * @return <tt>true</tt> if this list changed as a result of the call.
+     * 
+     * @throws UnsupportedOperationException if the <tt>addAll</tt> method is
+     *         not supported by this list.
+     * @throws ClassCastException if the class of an element in the specified
+     * 	       collection prevents it from being added to this list.
+     * @throws NullPointerException if the specified collection contains one
+     *         or more null elements and this list does not support null
+     *         elements, or if the specified collection is <tt>null</tt>.
+     * @throws IllegalArgumentException if some aspect of an element in the
+     *         specified collection prevents it from being added to this
+     *         list.
+     * @see #add(Object)
+     */
+    public boolean addAll(Collection<? extends E> c) {
+    	boolean ret=super.addAll(c);
+    	
+    	if (ret) {
+    		java.util.Iterator<? extends E> iter=c.iterator();
+    		
+    		while (iter.hasNext()) {
+    			iter.next().setParent(m_parent);
+    		}
+    	}
+    	
+    	return(ret);
+    }
+
+    /**
+     * Inserts all of the elements in the specified collection into this
+     * list at the specified position (optional operation).  Shifts the
+     * element currently at that position (if any) and any subsequent
+     * elements to the right (increases their indices).  The new elements
+     * will appear in this list in the order that they are returned by the
+     * specified collection's iterator.  The behavior of this operation is
+     * unspecified if the specified collection is modified while the
+     * operation is in progress.  (Note that this will occur if the specified
+     * collection is this list, and it's nonempty.)
+     *
+     * @param index index at which to insert first element from the specified
+     *	            collection.
+     * @param c elements to be inserted into this list.
+     * @return <tt>true</tt> if this list changed as a result of the call.
+     * 
+     * @throws UnsupportedOperationException if the <tt>addAll</tt> method is
+     *		  not supported by this list.
+     * @throws ClassCastException if the class of one of elements of the
+     * 		  specified collection prevents it from being added to this
+     * 		  list.
+     * @throws NullPointerException if the specified collection contains one
+     *           or more null elements and this list does not support null
+     *           elements, or if the specified collection is <tt>null</tt>.
+     * @throws IllegalArgumentException if some aspect of one of elements of
+     *		  the specified collection prevents it from being added to
+     *		  this list.
+     * @throws IndexOutOfBoundsException if the index is out of range (index
+     *		  &lt; 0 || index &gt; size()).
+     */
+    public boolean addAll(int index, Collection<? extends E> c) {
+    	boolean ret=super.addAll(index, c);
+    	
+    	if (ret) {
+    		java.util.Iterator<? extends E> iter=c.iterator();
+    		
+    		while (iter.hasNext()) {
+    			iter.next().setParent(m_parent);
+    		}
+    	}
+    	
+    	return(ret);    	
+    }
+
+    /**
+     * Removes from this list all the elements that are contained in the
+     * specified collection (optional operation).
+     *
+     * @param c collection that defines which elements will be removed from
+     *          this list.
+     * @return <tt>true</tt> if this list changed as a result of the call.
+     * 
+     * @throws UnsupportedOperationException if the <tt>removeAll</tt> method
+     * 		  is not supported by this list.
+     * @throws ClassCastException if the types of one or more elements
+     *            in this list are incompatible with the specified
+     *            collection (optional).
+     * @throws NullPointerException if this list contains one or more
+     *            null elements and the specified collection does not support
+     *            null elements (optional).
+     * @throws NullPointerException if the specified collection is
+     *            <tt>null</tt>.
+     * @see #remove(Object)
+     * @see #contains(Object)
+     */
+    public boolean removeAll(Collection<?> c) {
+    	boolean ret=super.removeAll(c);
+    	
+    	if (ret) {
+    		java.util.Iterator<?> iter=c.iterator();
+    		
+    		while (iter.hasNext()) {
+    			Object val=iter.next();
+    			if (val instanceof ModelObject) {
+    				((ModelObject)val).setParent(null);
+    			}
+    		}
+    	}
+    	
+    	return(ret);    	
+    }
+
+    /**
+     * Retains only the elements in this list that are contained in the
+     * specified collection (optional operation).  In other words, removes
+     * from this list all the elements that are not contained in the specified
+     * collection.
+     *
+     * @param c collection that defines which elements this set will retain.
+     * 
+     * @return <tt>true</tt> if this list changed as a result of the call.
+     * 
+     * @throws UnsupportedOperationException if the <tt>retainAll</tt> method
+     * 		  is not supported by this list.
+     * @throws ClassCastException if the types of one or more elements
+     *            in this list are incompatible with the specified
+     *            collection (optional).
+     * @throws NullPointerException if this list contains one or more
+     *            null elements and the specified collection does not support
+     *            null elements (optional).
+     * @throws NullPointerException if the specified collection is
+     *         <tt>null</tt>.
+     * @see #remove(Object)
+     * @see #contains(Object)
+     */
+    public boolean retainAll(Collection<?> c) {
+    	return(super.retainAll(c));
+    }
+
+    /**
+     * Removes all of the elements from this list (optional operation).  This
+     * list will be empty after this call returns (unless it throws an
+     * exception).
+     *
+     * @throws UnsupportedOperationException if the <tt>clear</tt> method is
+     * 		  not supported by this list.
+     */
+    public void clear() {
+		java.util.Iterator<? extends E> iter=iterator();
+		
+		while (iter.hasNext()) {
+			iter.next().setParent(null);
+		}
+
+		super.clear();
+    }
+    
+    /**
+     * Replaces the element at the specified position in this list with the
+     * specified element (optional operation).
+     *
+     * @param index index of element to replace.
+     * @param element element to be stored at the specified position.
+     * @return the element previously at the specified position.
+     * 
+     * @throws UnsupportedOperationException if the <tt>set</tt> method is not
+     *		  supported by this list.
+     * @throws    ClassCastException if the class of the specified element
+     * 		  prevents it from being added to this list.
+     * @throws    NullPointerException if the specified element is null and
+     *            this list does not support null elements.
+     * @throws    IllegalArgumentException if some aspect of the specified
+     *		  element prevents it from being added to this list.
+     * @throws    IndexOutOfBoundsException if the index is out of range
+     *		  (index &lt; 0 || index &gt;= size()).
+     */
+    public E set(int index, E element) {
+    	E ret=super.set(index, element);
+    	
+    	if (element != null) {
+    		element.setParent(m_parent);
+    	}
+    	
+    	if (ret != null) {
+    		ret.setParent(null);
+    	}
+    	
+    	return(ret);
+    }
+
+    /**
+     * Inserts the specified element at the specified position in this list
+     * (optional operation).  Shifts the element currently at that position
+     * (if any) and any subsequent elements to the right (adds one to their
+     * indices).
+     *
+     * @param index index at which the specified element is to be inserted.
+     * @param element element to be inserted.
+     * 
+     * @throws UnsupportedOperationException if the <tt>add</tt> method is not
+     *		  supported by this list.
+     * @throws    ClassCastException if the class of the specified element
+     * 		  prevents it from being added to this list.
+     * @throws    NullPointerException if the specified element is null and
+     *            this list does not support null elements.
+     * @throws    IllegalArgumentException if some aspect of the specified
+     *		  element prevents it from being added to this list.
+     * @throws    IndexOutOfBoundsException if the index is out of range
+     *		  (index &lt; 0 || index &gt; size()).
+     */
+    public void add(int index, E element) {
+    	super.add(index, element);
+    	
+    	if (element != null) {
+    		element.setParent(m_parent);
+    	}
+    }
+
+    /**
+     * Removes the element at the specified position in this list (optional
+     * operation).  Shifts any subsequent elements to the left (subtracts one
+     * from their indices).  Returns the element that was removed from the
+     * list.
+     *
+     * @param index the index of the element to removed.
+     * @return the element previously at the specified position.
+     * 
+     * @throws UnsupportedOperationException if the <tt>remove</tt> method is
+     *		  not supported by this list.
+     * @throws IndexOutOfBoundsException if the index is out of range (index
+     *            &lt; 0 || index &gt;= size()).
+     */
+    public E remove(int index) {
+    	E ret=super.remove(index);
+    	
+    	if (ret != null) {
+    		ret.setParent(null);
+    	}
+    	
+    	return(ret);
+    }
+    
+    private ModelObject m_parent=null;
+    private Class<E> m_type=null;
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Declaration.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Declaration.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Declaration.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 28 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.model;
+
+/**
+ * This interface represents a named declaration within 
+ * the scope of a Scribble block.
+ * 
+ */
+public interface Declaration {
+
+	/**
+	 * The name associated with the declaration.
+	 * 
+	 * @return The declaration name
+	 */
+	public String getName();
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/DeclarationBinding.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/DeclarationBinding.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/DeclarationBinding.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 7 Dec 2007 : Initial version created by gary
+ */
+package org.scribble.model;
+
+/**
+ * This class represents the binding between a declaration and
+ * the name of a declaration in a composed definition.
+ */
+public class DeclarationBinding extends ModelObject {
+
+	private static final long serialVersionUID = -8912117052145055821L;
+
+	/**
+	 * The default constructor.
+	 */
+	public DeclarationBinding() {
+	}
+	
+	/**
+	 * This constructor initializes the declaration and bound
+	 * name.
+	 * 
+	 * @param decl The declaration
+	 * @param boundName The bound name
+	 */
+	public DeclarationBinding(Declaration decl, String boundName) {
+		m_declaration = decl;
+		m_boundName = boundName;
+	}
+	
+	/**
+	 * This method sets the declaration.
+	 * 
+	 * @param decl The declaration
+	 */
+	public void setDeclaration(Declaration decl) {
+		m_declaration = decl;
+	}
+	
+	/**
+	 * This method returns the declaration.
+	 * 
+	 * @return The declaration
+	 */
+	public Declaration getDeclaration() {
+		return(m_declaration);
+	}
+
+	/**
+	 * This method sets the bound name.
+	 * 
+	 * @param boundName The bound name
+	 */
+	public void setBoundName(String boundName) {
+		m_boundName = boundName;
+	}
+	
+	/**
+	 * This method returns the bound name.
+	 * 
+	 * @return The bound name
+	 */
+	public String getBoundName() {
+		return(m_boundName);
+	}
+
+	private Declaration m_declaration=null;
+	private String m_boundName=null;
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Definition.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Definition.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Definition.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,326 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 7 Dec 2007 : Initial version created by gary
+ */
+package org.scribble.model;
+
+/**
+ * This class represents the base class for all Scribble definitions.
+ */
+public abstract class Definition extends Activity {
+
+	private static final long serialVersionUID = 6381278356995297737L;
+
+	/**
+	 * This is the default constructor for the definition.
+	 * 
+	 */
+	public Definition() {
+	}
+	
+	/**
+	 * This method returns the name of the definition.
+	 * 
+	 * @return The name
+	 */
+	@Reference(containment=true)
+	public LocatedName getLocatedName() {
+		return(m_locatedName);
+	}
+	
+	/**
+	 * This method sets the name of the definition.
+	 * 
+	 * @param name The name
+	 */
+	public void setLocatedName(LocatedName name) {
+		
+		if (m_locatedName != null) {
+			m_locatedName.setParent(null);
+		}
+		
+		m_locatedName = name;
+		
+		if (m_locatedName != null) {
+			m_locatedName.setParent(this);
+		}
+	}
+	
+	/**
+	 * This method determines whether the definition is stateless.
+	 * 
+	 * @return Whether the definition is stateless
+	 */
+	public boolean isStateless() {
+		return(m_stateless);
+	}
+	
+	/**
+	 * This method sets whether the definition is stateless.
+	 * 
+	 * @param stateless Whether the definition is stateless
+	 */
+	public void setStateless(boolean stateless) {
+		m_stateless = stateless;
+	}
+	
+	/**
+	 * This method returns the list of models that this definition
+	 * must conform to.
+	 * 
+	 * @return The list of models that must be conformed to
+	 */
+	@Reference(containment=true)
+	public java.util.List<ConformanceReference> getConformsTo() {
+		return(m_conformsTo);
+	}
+	
+	/**
+	 * This method returns the list of models that this definition
+	 * implements.
+	 * 
+	 * @return The list of models this definition implements
+	 */
+	@Reference(containment=true)
+	public java.util.List<ImplementsReference> getImplements() {
+		return(m_implements);
+	}
+	
+	/**
+	 * This method returns the block of activities associated
+	 * with the definition.
+	 * 
+	 * @return The block of activities
+	 */
+	@Reference(containment=true)
+	public Block getBlock() {
+		
+		if (m_contents == null) {
+			m_contents = new Block();
+			m_contents.setParent(this);
+		}
+		
+		return(m_contents);
+	}
+	
+	/**
+	 * This method sets the block of activities associated
+	 * with the definition.
+	 * 
+	 * @param block The block of activities
+	 */
+	public void setBlock(Block block) {
+		if (m_contents != null) {
+			m_contents.setParent(null);
+		}
+		
+		m_contents = block;
+		
+		if (m_contents != null) {
+			m_contents.setParent(this);
+		}
+	}
+	
+	/**
+	 * This method returns the model in which this definition
+	 * is contained.
+	 * 
+	 * @return The model, or null if not contained within
+	 * 					a model
+	 */
+	public Model getModel() {
+		Model ret=null;
+		ModelObject cur=this;
+		
+		while (ret == null && cur != null) {
+			if (cur instanceof Model) {
+				ret = (Model)cur;
+			} else {
+				cur = cur.getParent();
+			}
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the definition in which this
+	 * activity is contained.
+	 * 
+	 * @return The definition, or null if not found
+	 */
+	@Override
+	public Definition getEnclosingDefinition() {
+		return(this);
+	}
+	
+	/**
+	 * This method returns the top level definition.
+	 * 
+	 * @return The top level definition
+	 */
+	public Definition getTopLevelDefinition() {
+		Definition ret=this;
+		
+		if (getParent() instanceof Definition) {
+			ret = ((Definition)getParent()).getTopLevelDefinition();
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the sub-definition associated
+	 * with the supplied name.
+	 * 
+	 * @param name The name
+	 * @return The sub-definition for the supplied name,
+	 * 				or null if not found
+	 */
+	public Definition getSubDefinition(String name) {
+		Definition ret=null;
+	
+		for (int i=0; ret == null &&
+				i < getBlock().getContents().size(); i++) {
+			Activity act=getBlock().getContents().get(i);
+			
+			if (act instanceof Definition &&
+					((Definition)act).getLocatedName().getName().equals(name)) {
+				ret = (Definition)act;
+			}
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the sub-definition associated
+	 * with the supplied path.
+	 * 
+	 * @param subPath The sub path
+	 * @return The sub-definition for the supplied path,
+	 * 				or null if not found
+	 */
+	public Definition getSubDefinition(SubDefinitionPath subPath) {
+		Definition ret=this;
+	
+		for (int i=0; ret != null && 
+					i < subPath.getPathElementCount(); i++) {
+			ret = ret.getSubDefinition(subPath.getPathElement(i));
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method return the top level declarations associated
+	 * with the definition.
+	 * 
+	 * @return The declarations
+	 */
+	public java.util.Set<Declaration> getDeclarations() {
+		java.util.Set<Declaration> ret=new java.util.HashSet<Declaration>();
+		
+		// Check if definition has a located role
+		if (getLocatedName().getRole() != null) {
+			ret.add(getLocatedName().getRole());
+		}
+		
+		// Check activities for suitable declarations
+		java.util.Iterator<Activity> iter=getBlock().getContents().iterator();
+		
+		while (iter.hasNext()) {
+			Activity act=iter.next();
+			
+			if (act instanceof RoleList) {
+				ret.addAll(((RoleList)act).getRoles());
+			} else if (act instanceof ChannelList) {
+				ret.addAll(((ChannelList)act).getChannels());
+			}
+		}
+		
+		return(ret);
+	}
+		
+	/**
+	 * This method returns the named top level declaration,
+	 * associated with this definition.
+	 * 
+	 * @param name The declaration name
+	 * @return The declaration, or null if not found
+	 */
+	public Declaration getDeclaration(String name) {
+		Declaration ret=null;
+		
+		java.util.Iterator<Declaration> iter=getDeclarations().iterator();
+		while (ret == null && iter.hasNext()) {
+			ret = iter.next();
+			
+			if (ret.getName().equals(name) == false) {
+				ret = null;
+			}
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the list of roles defined at
+	 * the top level of the definition.
+	 * 
+	 * @return The list of roles
+	 */
+	public java.util.List<Role> getRoles() {
+		java.util.List<Role> ret=new java.util.Vector<Role>();
+		
+		for (int i=0; i < getBlock().getContents().size(); i++) {
+		
+			if (getBlock().getContents().get(i) instanceof RoleList) {
+				ret.addAll(((RoleList)getBlock().getContents().get(i)).getRoles());
+			}
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the optional located role
+	 * associated with the enclosing definition.
+	 * 
+	 * @return The located role, or null if the
+	 * 			enclosing definition is not located
+	 */
+	@Override
+	protected Role getLocatedRole() {
+		Role ret=null;
+		
+		if (getLocatedName() != null) {
+			ret = getLocatedName().getRole();
+		}
+		
+		return(ret);
+	}
+
+	private LocatedName m_locatedName=null;
+	private boolean m_stateless=false;
+	private java.util.List<ConformanceReference> m_conformsTo=
+			new ContainmentList<ConformanceReference>(this, ConformanceReference.class);
+	private java.util.List<ImplementsReference> m_implements=
+			new ContainmentList<ImplementsReference>(this, ImplementsReference.class);
+	private Block m_contents=null;
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/ImplementsReference.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/ImplementsReference.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/ImplementsReference.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 1 Feb 2008 : Initial version created by gary
+ */
+package org.scribble.model;
+
+/**
+ * This class represents a 'implements' link to another
+ * definition.
+ */
+public class ImplementsReference extends NameMappingReference {
+
+	private static final long serialVersionUID = -4001311732651746245L;
+
+	/**
+	 * This is the constructor for the 'implements' reference.
+	 * 
+	 * @param notation The notation
+	 */
+	public ImplementsReference(String notation) {
+		super(notation);
+	}
+	
+	/**
+	 * This is the copy constructor for the 'implements'
+	 * reference.
+	 * 
+	 * @param ref The reference to copy
+	 */
+	public ImplementsReference(ImplementsReference ref) {
+		super(ref);
+	}
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Import.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Import.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Import.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 22 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.model;
+
+/**
+ * This class represents an import definition associated with a model.
+ * 
+ */
+public class Import extends Statement {
+
+	private static final long serialVersionUID = -5422814413966814121L;
+
+	/**
+	 * The default constructor.
+	 */
+	public Import() {
+	}
+	
+	/**
+	 * This method returns the fully qualified name of the
+	 * definition(s) being imported.
+	 * 
+	 * @return The name
+	 */
+	public String getName() {
+		return(m_name);
+	}
+	
+	/**
+	 * This method sets the fully qualified name of the
+	 * definition(s) being imported.
+	 * 
+	 * @param name The name
+	 */
+	public void setName(String name) {
+		m_name = name;
+	}
+	
+	/**
+	 * This method returns the optional alias.
+	 * 
+	 * @return The alias
+	 */
+	public String getAlias() {
+		return(m_alias);
+	}
+	
+	/**
+	 * This method sets the optional alias.
+	 * 
+	 * @param alias The alias
+	 */
+	public void setAlias(String alias) {
+		m_alias = alias;
+	}
+	
+	private String m_name=null;
+	private String m_alias=null;
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Interaction.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Interaction.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Interaction.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,303 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 22 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.model;
+
+/**
+ * This class represents an interaction.
+ * 
+ */
+public class Interaction extends Behaviour {
+
+	private static final long serialVersionUID = -3628413228540452576L;
+
+	/**
+	 * This class returns the message signature.
+	 * 
+	 * @return The message signature
+	 */
+	@Reference(containment=true)
+	public MessageSignature getMessageSignature() {
+		return(m_messageSignature);
+	}
+	
+	/**
+	 * This method sets the message signature.
+	 * 
+	 * @param signature The message signature
+	 */
+	public void setMessageSignature(MessageSignature signature) {
+		
+		if (m_messageSignature != null) {
+			m_messageSignature.setParent(null);
+		}
+		
+		m_messageSignature = signature;
+		
+		if (m_messageSignature != null) {
+			m_messageSignature.setParent(this);
+		}
+	}
+	
+	/**
+	 * This method returns the optional channel.
+	 * 
+	 * @return The channel
+	 */
+	public Channel getChannel() {
+		return(m_channel);
+	}
+	
+	/**
+	 * This method sets the channel.
+	 * 
+	 * @param channel The channel
+	 */
+	public void setChannel(Channel channel) {
+		m_channel = channel;
+	}
+	
+	/**
+	 * This method returns the optional 'from' role.
+	 * 
+	 * @return The optional 'from' role
+	 */
+	public Role getFromRole() {
+		return(m_fromRole);
+	}
+	
+	/**
+	 * This method sets the optional 'from' role.
+	 * 
+	 * @param part The optional 'from' role
+	 */
+	public void setFromRole(Role part) {
+		m_fromRole = part;
+	}
+	
+	/**
+	 * This method returns the optional 'to' role.
+	 * 
+	 * @return The optional 'to' role
+	 */
+	public Role getToRole() {
+		return(m_toRole);
+	}
+	
+	/**
+	 * This method sets the optional 'to' role.
+	 * 
+	 * @param part The optional 'to' role
+	 */
+	public void setToRole(Role part) {
+		m_toRole = part;
+	}
+	
+	/**
+	 * This method returns the label used to identify
+	 * this request.
+	 * 
+	 * @return The request label
+	 */
+	public String getRequestLabel() {
+		return(m_requestLabel);
+	}
+	
+	/**
+	 * This method sets the label used to identify this
+	 * request.
+	 * 
+	 * @param label The request label
+	 */
+	public void setRequestLabel(String label) {
+		m_requestLabel = label;
+	}
+	
+	/**
+	 * This method returns the label used to correlate
+	 * this response with a previous request.
+	 * 
+	 * @return The replyTo label
+	 */
+	public String getReplyToLabel() {
+		return(m_replyToLabel);
+	}
+	
+	/**
+	 * This method sets the label used to correlate
+	 * this response with a previous request.
+	 * 
+	 * @param label The replyTo label
+	 */
+	public void setReplyToLabel(String label) {
+		m_replyToLabel = label;
+	}
+	
+	/**
+	 * This method returns the list of roles that are
+	 * responsible for initiating the activity. This can
+	 * be used to determine whether the model is
+	 * consistent in terms of decision makers subsequently
+	 * initiating actions.
+	 * 
+	 * @return The list of initiator roles
+	 */
+	@Override
+	public java.util.List<Role> getInitiatorRoles() {
+		java.util.List<Role> ret=super.getInitiatorRoles();
+		
+		if (getFromRole() != null) {
+			
+			if (ret.contains(getFromRole()) == false) {
+				ret.add(getFromRole());
+			}
+		} else {
+			Definition defn=getEnclosingDefinition();
+			
+			if (defn != null) {
+				Role locatedRole=defn.getLocatedName().getRole();
+				
+				if (locatedRole != null && getToRole() != null &&
+						getToRole().equals(locatedRole) == false &&
+						ret.contains(locatedRole) == false) {
+					ret.add(locatedRole);
+				}
+			}
+		}
+		
+		return(ret);
+	}
+
+	/**
+	 * This method returns the list of roles that are
+	 * associated with the outcome of the activity.
+	 * 
+	 * @return The list of final roles
+	 */
+	@Override
+	public java.util.List<Role> getFinalRoles() {
+		java.util.List<Role> ret=super.getFinalRoles();
+		
+		if (getToRole() != null) {
+			
+			if (ret.contains(getToRole()) == false) {
+				ret.add(getToRole());
+			}
+		} else {
+			Definition defn=getEnclosingDefinition();
+			
+			if (defn != null) {
+				Role locatedRole=defn.getLocatedName().getRole();
+				
+				if (locatedRole != null && getFromRole() != null &&
+						getFromRole().equals(locatedRole) == false &&
+						ret.contains(locatedRole) == false) {
+					ret.add(locatedRole);
+				}
+			}
+		}
+		
+		return(ret);
+	}
+
+	/**
+	 * This method returns the list of roles that are
+	 * associated with the behaviour.
+	 * 
+	 * @return The list of associated roles
+	 */
+	@Override
+	public java.util.List<Role> getAssociatedRoles() {
+		java.util.List<Role> ret=super.getAssociatedRoles();
+		
+		if (getToRole() != null &&
+					ret.contains(getToRole()) == false) {
+			ret.add(getToRole());
+		}
+		
+		if (getFromRole() != null &&
+					ret.contains(getFromRole()) == false) {
+			ret.add(getFromRole());
+		}
+		
+		if (getToRole() == null || getFromRole() == null) {
+			Role locatedRole=getLocatedRole();
+			
+			if (locatedRole != null && ret.contains(locatedRole) == false) {
+				ret.add(locatedRole);
+			}
+		}
+		
+		return(ret);
+	}
+
+	/**
+	 * This method returns whether the behaviour is a wait
+	 * state.
+	 * 
+	 * @return Whether the behaviour is a wait state
+	 */
+	@Override
+	public boolean isWaitState() {
+		boolean ret=false;
+		Role role=getLocatedRole();
+		
+		// Check if interaction is a receive
+		if (role != null &&
+			((getToRole() != null && role.equals(getToRole())) ||
+			(getFromRole() != null && role.equals(getFromRole()) == false))) {
+			ret = true;
+		}
+		
+		return(ret);
+	}
+
+	public String toString() {
+		StringBuffer ret=new StringBuffer();
+		
+		if (getMessageSignature() != null) {
+			ret.append(getMessageSignature());
+			ret.append(" ");
+		}
+		
+		if (getFromRole() != null) {
+			ret.append(getFromRole());
+			ret.append("->");
+			
+			if (getToRole() != null) {
+				ret.append(getToRole());
+			}
+		} else {
+			ret.append("->");
+			
+			if (getToRole() != null) {
+				ret.append(getToRole());
+			}
+		}
+		
+		return(ret.toString());
+	}
+	
+	private MessageSignature m_messageSignature=null;
+	private Channel m_channel=null;
+	private Role m_fromRole=null;
+	private Role m_toRole=null;
+	private String m_requestLabel=null;
+	private String m_replyToLabel=null;
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/LocatedName.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/LocatedName.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/LocatedName.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,133 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 13 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.model;
+
+/**
+ * This class represents the name of a model.
+ */
+public class LocatedName extends ModelObject {
+
+	private static final long serialVersionUID = -7430644107592080014L;
+
+	/**
+	 * This is the default constructor for the model name.
+	 */
+	public LocatedName() {
+	}
+	
+	/**
+	 * This is the constructor for the model name.
+	 * 
+	 * @param name The name
+	 * @param located The optional located role
+	 */
+	public LocatedName(String name, Role located) {
+		m_name = name;
+		m_role = located;
+	}
+	
+	/**
+	 * This method returns the name.
+	 * 
+	 * @return The name
+	 */
+	public String getName() {
+		return(m_name);
+	}
+	
+	/**
+	 * This method sets the name.
+	 * 
+	 * @param name The name
+	 */
+	public void setName(String name) {
+		m_name = name;
+	}
+	
+	/**
+	 * This method returns the located role. This
+	 * field is set when the protocol represents a local
+	 * model.
+	 * 
+	 * @return The located role
+	 */
+	@Reference(containment=true)
+	public Role getRole() {
+		return(m_role);
+	}
+	
+	/**
+	 * This method sets the located role. This
+	 * field is set when the protocol represents a local
+	 * model.
+	 * 
+	 * @param role The located role
+	 */
+	public void setRole(Role role) {
+		
+		if (m_role != null) {
+			m_role.setParent(null);
+		}
+		
+		m_role = role;
+		
+		if (m_role != null) {
+			m_role.setParent(this);
+		}
+	}
+	
+	public int hashCode() {
+		int ret=super.hashCode();
+		
+		if (m_name != null) {
+			ret = m_name.hashCode();
+		}
+		
+		return(ret);
+	}
+	
+	public boolean equals(Object other) {
+		boolean ret=false;
+		
+		if (other instanceof LocatedName &&
+				m_name != null &&
+				((LocatedName)other).m_name != null &&
+				m_name.equals(((LocatedName)other).m_name)) {
+			
+			if (m_role == null &&
+					((LocatedName)other).m_role == null) {
+				ret = true;
+			} else if (m_role != null &&
+					((LocatedName)other).m_role != null &&
+					m_role.equals(((LocatedName)other).m_role)) {
+				ret = true;
+			}
+		}
+		
+		return(ret);
+	}
+			
+	public String toString() {
+		return("Name["+getName()+" loc="+m_role+"]");
+	}
+	
+	private String m_name=null;
+	private Role m_role=null;
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/MessageSignature.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/MessageSignature.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/MessageSignature.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 24 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.model;
+
+/**
+ * This class represents a message signature.
+ */
+public class MessageSignature extends ModelObject {
+
+	private static final long serialVersionUID = 8952431919812954593L;
+
+	/**
+	 * This method returns the optional operation.
+	 * 
+	 * @return The optional operation
+	 */
+	public String getOperation() {
+		return(m_operation);
+	}
+	
+	/**
+	 * This method sets the operation.
+	 * 
+	 * @param operation The operation
+	 */
+	public void setOperation(String operation) {
+		m_operation = operation;
+	}
+	
+	// TODO: Need to think about actual type for this list
+	// See how JDT DOM handles local details (e.g. short
+	// name) versus fully qualified name identifying the
+	// actual type. Issue also is if the model can be
+	// updated, what happens to the fully qualified name?
+	/**
+	 * This method returns the list of type references. If
+	 * no operation is defined, then only one type reference
+	 * should be defined.
+	 * 
+	 * @return The list of type references
+	 */
+	@Reference(containment=true)
+	public java.util.List<TypeReference> getTypes() {
+		return(m_types);
+	}
+	
+	public String toString() {
+		String ret=getOperation();
+		
+		if (getOperation() != null &&
+					getOperation().trim().length() > 0) {
+			ret += "(";
+		}
+		
+		for (int i=0; i < m_types.size(); i++) {
+			if (i > 0) {
+				ret += ",";
+			}
+			ret += m_types.get(i).getAlias();	
+		}
+		
+		if (getOperation() != null &&
+				getOperation().trim().length() > 0) {
+			ret += ")";
+		}
+		
+		return(ret);
+	}
+	
+	private String m_operation=null;
+	private java.util.List<TypeReference> m_types=
+			new ContainmentList<TypeReference>(this, TypeReference.class);
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Model.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Model.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Model.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,213 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 18 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.model;
+
+/**
+ * This class represents the base class for models associated with
+ * specific notations. The details associated with the notation are
+ * contained within derived classes.
+ *
+ */
+public abstract class Model extends ModelObject {
+
+	private static final long serialVersionUID = -1282833027993451521L;
+
+	/**
+	 * The default constructor for the model.
+	 */
+	public Model() {
+	}
+	
+	/**
+	 * This method sets the namespace associated with the model.
+	 * 
+	 * @param namespace The namespace
+	 */
+	public void setNamespace(Namespace namespace) {
+		
+		if (m_namespace != null) {
+			m_namespace.setParent(null);
+		}
+		
+		m_namespace = namespace;
+		
+		if (m_namespace != null) {
+			m_namespace.setParent(this);
+		}
+	}
+	
+	/**
+	 * This method returns the namespace associated with the model.
+	 * 
+	 * @return The namespace
+	 */
+	@Reference(containment=true)
+	public Namespace getNamespace() {
+		return(m_namespace);
+	}
+	
+	/**
+	 * This method returns the list of import definitions.
+	 * 
+	 * @return The import definitions
+	 */
+	@Reference(containment=true)
+	public java.util.List<Import> getImports() {
+		return(m_imports);
+	}
+	
+	/**
+	 * This method returns the model name associated with
+	 * the model.
+	 * 
+	 * @return The model name
+	 */
+	//public abstract ModelName getModelName();
+
+	/**
+	 * This method returns a list of local model references
+	 * associated with a global conversation model. The
+	 * supplied reference provides the template for the
+	 * local model references.
+	 * 
+	 * @param template The global model reference that should
+	 * 				be used as the template for the local model
+	 * 				references
+	 * @return The list of local model references
+	 */
+	public java.util.List<ModelReference> getLocalModels(final ModelReference template) {
+		final java.util.List<ModelReference> localModelRefs=
+					new java.util.Vector<ModelReference>();
+		
+		java.util.List<Definition> defns=getDefinitions();
+		
+		for (int i=0; i < defns.size(); i++) {
+			// Identify all of the roles defined in the
+			// top level definition
+			defns.get(i).visit(new Visitor() {
+				
+				public boolean visit(ModelObject obj) {
+					boolean ret=true;
+					
+					if (obj instanceof RoleList &&
+							((RoleList)obj).isOpen() == false) {
+						RoleList plist=(RoleList)obj;
+						
+						for (int i=0; i < plist.getRoles().size(); i++) {
+							Role role=plist.getRoles().get(i);
+							
+							// Create model reference for this role
+							ModelReference lref=
+								new ModelReference(template);
+							
+							lref.setLocatedRole(role.getName());
+							
+							Definition defn=plist.getEnclosingDefinition();
+							
+							while (defn != null &&
+										(defn.getParent() instanceof Model) == false) {
+								lref.getSubDefinitionPath().addPathElement(0,
+											defn.getLocatedName().getName());
+								
+								ModelObject parent=defn.getParent();
+								
+								if (parent instanceof Activity) {
+									defn = ((Activity)defn.getParent()).getEnclosingDefinition();
+								} else {
+									defn = null;
+								}
+							}
+							
+							// Associate role annotations with local model reference
+							// NOTE: This may be a temporary measure while Role objects
+							// have the Contract model associated with them, as a
+							// convenient way to make the info available to the generator.
+							lref.getAnnotations().putAll(role.getAnnotations());
+							
+							localModelRefs.add(lref);
+						}
+					}
+					
+					return(ret);
+				}
+			});
+		}
+		
+		return(localModelRefs);
+	}
+
+	/**
+	 * This method returns the list of definitions supported by
+	 * this model.
+	 * 
+	 * @return The list of definitions
+	 */
+	public abstract java.util.List<Definition> getDefinitions();
+	
+	/**
+	 * This method determines whether the model is located.
+	 * 
+	 * @return Whether the model is located
+	 */
+	public boolean isLocated() {
+		boolean ret=false;
+		
+		java.util.List<Definition> defns=getDefinitions();
+		
+		if (defns.size() > 0) {
+			ret = (defns.get(0).getLocatedName().getRole() != null);
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method initializes the URIs for the model
+	 * objects contained in the model.
+	 *
+	 */
+	public void initializeURIs() {
+		initializeURIPart("");
+	}
+	
+	/**
+	 * This method returns the contained model object,
+	 * within the model, based on the supplied URI.
+	 * 
+	 * @param uri The URI
+	 * @return The model object, or null if not found
+	 */
+	public ModelObject findModelObject(String uri) {
+		ModelObject ret=this;
+		
+		String[] parts=uri.split("/");
+		
+		// Start at position 2, as the URI begins with "//"
+		for (int i=2; ret != null && i < parts.length; i++) {
+			ret = ret.findChild(parts[i]);
+		}
+		
+		return(ret);
+	}
+	
+	private Namespace m_namespace=null;
+	private java.util.List<Import> m_imports=
+				new ContainmentList<Import>(this, Import.class);
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/ModelInclude.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/ModelInclude.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/ModelInclude.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,148 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 1 Dec 2007 : Initial version created by gary
+ */
+package org.scribble.model;
+
+/**
+ * This abstract class represents a behavioural activity that
+ * includes another model description, providing name mapping
+ * information where appropriate.
+ */
+public abstract class ModelInclude extends Behaviour {
+
+	private static final long serialVersionUID = 5201789723150072145L;
+
+	/**
+	 * This method returns the reference associated with
+	 * the included model.
+	 * 
+	 * @return The model reference
+	 */
+	public abstract ModelReference getReference();
+	
+	/**
+	 * This method returns the definition being
+	 * included.
+	 * 
+	 * @return The definition
+	 */
+	public abstract Definition getDefinition();
+	
+	/**
+	 * This method indicates whether the model include is
+	 * an inline definition.
+	 * 
+	 * @return Whether an inline definition
+	 */
+	public boolean isInline() {
+		return(false);
+	}
+
+	/**
+	 * This method returns the bindings for the
+	 * composition construct.
+	 * 
+	 * @return The list of bindings
+	 */
+	public java.util.List<DeclarationBinding> getBindings() {
+		return(m_bindings);
+	}
+	
+	/**
+	 * This method returns the declaration binding associated
+	 * with the supplied declaration.
+	 * 
+	 * @param decl The declaration
+	 * @return The declaration binding, or null if not found
+	 */
+	public DeclarationBinding getDeclarationBinding(Declaration decl) {
+		DeclarationBinding ret=null;
+		
+		java.util.Iterator<DeclarationBinding> iter=getBindings().iterator();
+		
+		while (ret == null && iter.hasNext()) {
+			ret = iter.next();
+			
+			if (ret.getDeclaration() != decl) {
+				ret = null;
+			}
+		}
+		
+		return(ret);
+	}
+		
+	/**
+	 * This method determines whether the model include construct
+	 * is asynchronous.
+	 * 
+	 * @return Whether the model include is asynchronous
+	 */
+	public abstract boolean isAsynchronous();
+	
+	/**
+	 * This method returns the list of roles that are
+	 * responsible for initiating the activity. This can
+	 * be used to determine whether the model is
+	 * consistent in terms of decision makers subsequently
+	 * initiating actions.
+	 * 
+	 * @return The list of initiator roles
+	 */
+	@Override
+	public java.util.List<Role> getInitiatorRoles() {
+		java.util.List<Role> ret=super.getInitiatorRoles();
+		
+		Definition defn=getDefinition();
+		
+		if (defn != null) {
+			ret.addAll(defn.getBlock().getInitiatorRoles());
+		}
+		
+		return(ret);
+	}
+
+	/**
+	 * This method returns the list of roles that are
+	 * associated with the outcome of the activity.
+	 * 
+	 * @return The list of final roles
+	 */
+	@Override
+	public java.util.List<Role> getFinalRoles() {
+		java.util.List<Role> ret=null;
+		
+		if (isAsynchronous()) {
+			ret = getInitiatorRoles();
+			
+		} else {
+			ret = super.getFinalRoles();
+			
+			Definition defn=getDefinition();
+			
+			if (defn != null) {
+				ret.addAll(defn.getBlock().getFinalRoles());
+			}	
+		}
+		
+		
+		return(ret);
+	}
+
+	private java.util.List<DeclarationBinding> m_bindings=new java.util.Vector<DeclarationBinding>();
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/ModelObject.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/ModelObject.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/ModelObject.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,355 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 20 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.model;
+
+import java.util.logging.Logger;
+
+/**
+ * This is the generic object from which all Scribble model objects
+ * are derived.
+ */
+public abstract class ModelObject {
+
+	private static final long serialVersionUID = -8915435247669402908L;
+
+	/**
+	 * This is the default constructor for the model object.
+	 */
+	public ModelObject() {
+	}
+	
+	/**
+	 * This is the constructor initialized with the source
+	 * reference.
+	 * 
+	 * @param source The source reference
+	 */
+	public ModelObject(int start, int end) {
+		m_sourceRef.setStartPosition(start);
+		m_sourceRef.setEndPosition(end);
+	}
+	
+	/**
+	 * This method returns the source reference.
+	 * 
+	 * @return The source reference
+	 */
+	public SourceRef getSource() {
+		return(m_sourceRef);
+	}
+	
+	/**
+	 * This method returns the parent of this
+	 * model object.
+	 * 
+	 * @return The parent, or null if top model
+	 * 					object
+	 */
+	public ModelObject getParent() {
+		return(m_parent);
+	}
+	
+	/**
+	 * This method sets the parent model object.
+	 * 
+	 * @param parent The parent
+	 */
+	public void setParent(ModelObject parent) {
+		m_parent = parent;
+	}
+	
+	/**
+	 * This method establishes the necessary information to
+	 * indicate that the current model object is derived
+	 * from the supplied source model object.
+	 * 
+	 * @param modelObj The source model object
+	 */
+	public void derivedFrom(ModelObject modelObj) {
+		if (modelObj != null) {
+			m_sourceRef = new SourceRef(modelObj.getSource());
+			
+			m_annotations = new Annotations(modelObj.getAnnotations());
+		}
+	}
+	
+	/**
+	 * This method returns the annotations associated
+	 * with this model object.
+	 * 
+	 * @return The annotations
+	 */
+	public Annotations getAnnotations() {
+		return(m_annotations);
+	}
+	
+	/**
+	 * This method visits the model object using the supplied
+	 * visitor.
+	 * 
+	 * @param visitor The visitor
+	 */
+	public void visit(Visitor visitor) {
+		boolean visitContained=visitor.visit(this);
+		
+		if (visitContained) {
+			
+			// Iterate over references and contained model objects
+			java.beans.BeanInfo bi=null;
+			
+			try {
+				bi = java.beans.Introspector.getBeanInfo(getClass());
+			} catch(Exception e) {
+				logger.log(java.util.logging.Level.SEVERE,
+						"Failed to get bean info for class '"+
+						getClass()+"'", e);
+			}
+			
+			if (bi != null) {
+				java.beans.PropertyDescriptor[] pds=bi.getPropertyDescriptors();
+				
+				for (int i=0; i < pds.length; i++) {
+					if (pds[i].getReadMethod() != null) {
+						org.scribble.model.Reference ref=
+							(org.scribble.model.Reference)
+							pds[i].getReadMethod().getAnnotation(
+									org.scribble.model.Reference.class);
+						
+						if (ref != null && ref.containment()) {
+							try {
+								Object refObject=pds[i].getReadMethod().invoke(this, (Object[])null);
+								
+								if (refObject instanceof java.util.List) {
+									java.util.List<?> list=(java.util.List<?>)refObject;
+									
+									for (int j=0; j < list.size(); j++) {
+										if (list.get(j) instanceof ModelObject) {
+											
+											((ModelObject)list.get(j)).visit(visitor);
+											
+										} else {
+											logger.severe("Property '"+
+													pds[i].getName()+"' on class '"+
+													getClass()+
+													"': Object in list is not a ModelObject");
+										}
+									}
+								} else if (refObject instanceof ModelObject) {
+									((ModelObject)refObject).visit(visitor);
+									
+								} else if (refObject != null) {
+									logger.severe("Property '"+pds[i].getName()+"' on class '"+
+											getClass()+
+											"': Contained object is not a ModelObject or list: "+
+											refObject.getClass());
+								}
+							} catch(Exception e) {
+								logger.severe("Failed to obtain property '"+
+										pds[i].getName()+"' on class '"+
+										getClass()+"': "+e);
+								e.printStackTrace();
+							}
+						}
+					}
+				}			
+			}
+		}
+	}
+	
+	/**
+	 * This method sets the URI on the current model object, and
+	 * iterates through all contained model objects to set the
+	 * relative URI on them.
+	 * 
+	 * @param uriPart The model object's URI part, relative to
+	 * 				its parent
+	 */
+	protected void initializeURIPart(String uriPart) {
+		String uri="";
+		
+		if (getParent() != null) {
+			uri = getParent().getSource().getModelObjectURI();
+		}
+
+		uri += "/" + (uriPart == null ? "":uriPart);
+		
+		// Initialize the URI on the source reference
+		getSource().setModelObjectURI(uri);
+		
+		// Iterate over references and contained model objects
+		java.beans.BeanInfo bi=null;
+		
+		try {
+			bi = java.beans.Introspector.getBeanInfo(getClass());
+		} catch(Exception e) {
+			logger.log(java.util.logging.Level.SEVERE,
+					"Failed to get bean info for class '"+
+					getClass()+"'", e);
+		}
+		
+		if (bi != null) {
+			java.beans.PropertyDescriptor[] pds=bi.getPropertyDescriptors();
+			
+			for (int i=0; i < pds.length; i++) {
+				if (pds[i].getReadMethod() != null) {
+					org.scribble.model.Reference ref=
+						(org.scribble.model.Reference)
+						pds[i].getReadMethod().getAnnotation(
+								org.scribble.model.Reference.class);
+					
+					if (ref != null && ref.containment()) {
+						try {
+							Object refObject=pds[i].getReadMethod().invoke(this, (Object[])null);
+							
+							if (refObject instanceof java.util.List) {
+								java.util.List<?> list=(java.util.List<?>)refObject;
+								
+								for (int j=0; j < list.size(); j++) {
+									if (list.get(j) instanceof ModelObject) {
+										
+										((ModelObject)list.get(j)).initializeURIPart(pds[i].getName()+"."+(j+1));
+										
+									} else {
+										logger.severe("Property '"+
+												pds[i].getName()+"' on class '"+
+												getClass()+
+												"': Object in list is not a ModelObject");
+									}
+								}
+							} else if (refObject instanceof ModelObject) {
+								((ModelObject)refObject).initializeURIPart(pds[i].getName());
+								
+							} else if (refObject != null) {
+								logger.severe("Property '"+pds[i].getName()+"' on class '"+
+										getClass()+
+										"': Contained object is not a ModelObject or list: "+
+										refObject.getClass());
+							}
+						} catch(Exception e) {
+							logger.severe("Failed to obtain property '"+
+									pds[i].getName()+"' on class '"+
+									getClass()+"': "+e);
+							e.printStackTrace();
+						}
+					}
+				}
+			}			
+		}
+	}
+	
+	/**
+	 * This method returns the child model object associated with
+	 * the supplied URI part.
+	 * 
+	 * @param uriPart The URI part
+	 * @return The model object, or null if not found
+	 */
+	protected ModelObject findChild(String uriPart) {
+		ModelObject ret=null;
+		int index=-1;
+		int pos=-1;
+		
+		// Check if has an index
+		if ((index=uriPart.indexOf('.')) != -1) {
+			String num=uriPart.substring(index+1);
+			
+			uriPart = uriPart.substring(0, index);
+			
+			try {
+				pos = Integer.parseInt(num);
+			} catch(Exception e) {
+				e.printStackTrace();
+			}	
+		}
+		
+		// Find property
+		java.beans.BeanInfo bi=null;
+		java.beans.PropertyDescriptor pd=null;
+		
+		try {
+			bi = java.beans.Introspector.getBeanInfo(getClass());
+		} catch(Exception e) {
+			logger.log(java.util.logging.Level.SEVERE,
+					"Failed to get bean info for class '"+
+					getClass()+"'", e);
+		}
+		
+		if (bi != null) {
+			java.beans.PropertyDescriptor[] pds=bi.getPropertyDescriptors();
+			
+			for (int i=0; pd == null && i < pds.length; i++) {
+				if (pds[i].getName().equals(uriPart)) {
+					pd = pds[i];
+				}
+			}
+		}
+		
+		if (pd != null && pd.getReadMethod() != null) {
+			try {
+				Object refObject=pd.getReadMethod().invoke(this, (Object[])null);
+				
+				if (refObject instanceof java.util.List &&
+						pos != -1) {
+					java.util.List<?> list=(java.util.List<?>)refObject;
+					
+					ret = (ModelObject)list.get(pos-1);
+				} else if (refObject instanceof ModelObject) {
+					ret = (ModelObject)refObject;
+					
+				} else if (refObject != null) {
+					logger.severe("Property '"+pd.getName()+"' on class '"+
+							getClass()+
+							"': Contained object is not a ModelObject or list: "+
+							refObject.getClass());
+				}
+			} catch(Exception e) {
+				logger.severe("Failed to obtain property '"+
+						pd.getName()+"' on class '"+
+						getClass()+"': "+e);
+				e.printStackTrace();
+			}
+		}
+		
+		return(ret);
+	}
+	
+	/* DON'T PROVIDE AN EQUALS IMPL, as this causes a problem with comparator rules
+	 * when checking for multiple paths - but can use equality of the source refs
+	public boolean equals(Object obj) {
+		boolean ret=false;
+		
+		if (obj instanceof ModelObject) {
+			ModelObject other=(ModelObject)obj;
+			
+			if (m_sourceRef != null &&
+					other.m_sourceRef != null) {
+				ret = m_sourceRef.equals(other.m_sourceRef);
+			}
+		}
+		return(ret);
+	}
+	*/
+	
+	private static Logger logger = Logger.getLogger("org.scribble.model");
+
+	private SourceRef m_sourceRef=new SourceRef();
+	private ModelObject m_parent=null;
+	private Annotations m_annotations=new Annotations();
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/ModelReference.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/ModelReference.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/ModelReference.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,461 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 18 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.model;
+
+/**
+ * This class represents a reference to a Scribble destination
+ * within the model repository.
+ */
+public class ModelReference extends ModelObject {
+
+	private static final long serialVersionUID = 7962754571821586984L;
+
+	/**
+	 * This is the constructor for the model reference.
+	 * 
+	 * @param notation The notation
+	 */
+	public ModelReference(String notation) {
+		m_notation = notation;
+		
+		// Mark as placeholder, until either alias or
+		// local part set
+		m_placeholder = true;
+	}
+	
+	/**
+	 * This is the copy constructor for the model reference.
+	 * 
+	 * @param ref The reference to copy
+	 */
+	public ModelReference(ModelReference ref) {
+		m_alias = ref.m_alias;
+		m_namespace = ref.m_namespace;
+		m_localpart = ref.m_localpart;
+		m_subDefinitionPath = new SubDefinitionPath(ref.getSubDefinitionPath());
+		m_locatedRole = ref.m_locatedRole;
+		m_notation = ref.m_notation;
+		m_inner = ref.m_inner;
+		m_fullyQualified = ref.m_fullyQualified;
+		
+		if (ref.m_properties != null) {
+			m_properties = new java.util.Hashtable<String, Object>();
+			
+			java.util.Iterator<String> iter=ref.m_properties.keySet().iterator();
+			
+			while (iter.hasNext()) {
+				String key=iter.next();
+				Object value=ref.m_properties.get(key);
+				
+				m_properties.put(key, value);
+			}
+		}
+	}
+	
+	/**
+	 * This is the constructor for the model reference.
+	 * 
+	 * @param namespace The namespace
+	 * @param localpart The localpart
+	 * @param located The optional located role
+	 * @param notation The notation
+	 */
+	public ModelReference(String namespace, String localpart,
+					String located, String notation) {
+		m_namespace = namespace;
+		m_localpart = localpart;
+		m_locatedRole = located;
+		m_notation = notation;
+
+	}
+	
+	/**
+	 * This method returns the alias.
+	 * 
+	 * @return The alias
+	 */
+	public String getAlias() {
+		String ret=m_alias;
+
+		// If alias not defined, then use local part
+		// (The getLocalpart method will do the reverse,
+		// so if only one field is defined, then they
+		// will be treated as the same).
+		if (ret == null) {
+			ret = m_localpart;
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method sets the alias.
+	 * 
+	 * @param alias The alias
+	 */
+	public void setAlias(String alias) {
+		m_alias = alias;
+		
+		// If the alias is set, then model reference
+		// is not a placeholder
+		m_placeholder = false;
+	}
+	
+	/**
+	 * This method returns the namespace.
+	 * 
+	 * @return The namespace
+	 */
+	public String getNamespace() {
+		return(m_namespace);
+	}
+	
+	/**
+	 * This method sets the namespace.
+	 * 
+	 * @param namespace The namespace
+	 */
+	public void setNamespace(String namespace) {
+		m_namespace = namespace;
+	}
+	
+	/**
+	 * This method returns the localpart.
+	 * 
+	 * @return The localpart
+	 */
+	public String getLocalpart() {
+		String ret=m_localpart;
+		
+		// If local part not defined, then use alias
+		// (The getAlias method will do the reverse,
+		// so if only one field is defined, then they
+		// will be treated as the same).
+		if (ret == null) {
+			ret = m_alias;
+		}
+
+		return(ret);
+	}
+	
+	/**
+	 * This method sets the localpart.
+	 * 
+	 * @param localpart The localpart
+	 */
+	public void setLocalpart(String localpart) {
+		m_localpart = localpart;
+		
+		// If the local part is set, then model reference
+		// is not a placeholder
+		m_placeholder = false;
+	}
+	
+	/**
+	 * This method returns the sub definition path. The
+	 * path identifies the sub definition of interest,
+	 * within a global model, for a located role.
+	 * 
+	 * @return The sub definition path
+	 */
+	public SubDefinitionPath getSubDefinitionPath() {
+		return(m_subDefinitionPath);
+	}
+	
+	/**
+	 * This method returns the located role associated
+	 * with the model reference.
+	 * 
+	 * @return The located role
+	 */
+	public String getLocatedRole() {
+		return(m_locatedRole);
+	}
+	
+	/**
+	 * This method sets the located role associated
+	 * with the model reference.
+	 * 
+	 * @param located The located role
+	 */
+	public void setLocatedRole(String located) {
+		m_locatedRole = located;
+	}
+	
+	/**
+	 * This method returns the notation code associated with the
+	 * model reference.
+	 * 
+	 * @return The notation code
+	 */
+	public String getNotation() {
+		return(m_notation);
+	}
+	
+	/**
+	 * This method sets the notation code associated with the
+	 * model reference.
+	 * 
+	 * @param notation The notation code
+	 */
+	public void setNotation(String notation) {
+		m_notation = notation;
+	}
+	
+	/**
+	 * This method indicates whether the model reference is simply
+	 * being used as a placeholder to provide information about the
+	 * notation of the model.
+	 * 
+	 * @return Whether the model reference is a placeholder
+	 */
+	public boolean isPlaceholder() {
+		return(m_placeholder);
+	}
+	
+	/**
+	 * This method determines whether the model reference is
+	 * fully qualified. This means that the namespace and
+	 * localpart were explicitly defined, as opposed to the
+	 * namespace being implicitly resolved using import
+	 * statements associated with the model.<p>
+	 * <p>
+	 * The default value is false.
+	 * 
+	 * @return Whether the model reference is fully qualified
+	 */
+	public boolean isFullyQualified() {
+		return(m_fullyQualified);
+	}
+	
+	/**
+	 * This method sets whether the model reference is
+	 * fully qualified.
+	 * 
+	 * @param fq Whether the model reference is fully qualified
+	 */
+	public void setFullyQualified(boolean fq) {
+		m_fullyQualified = fq;
+	}
+	
+	/**
+	 * This method determines if the model reference has been resolved
+	 * to an existing definition.
+	 * 
+	 * @return Whether the reference has been resolved
+	 */
+	public boolean isResolved() {
+		return(m_namespace != null || isInner());
+	}
+	
+	/**
+	 * This method determines whether the reference is to an inner
+	 * description.
+	 * 
+	 * @return Whether the reference is related to an inner description
+	 */
+	public boolean isInner() {
+		return(m_inner);
+	}
+	
+	/**
+	 * This method sets whether the reference is to an inner description.
+	 * 
+	 * @param inner Whether reference to inner description
+	 */
+	public void setInner(boolean inner) {
+		m_inner = inner;
+	}
+	
+	/**
+	 * This method sets the property associated with
+	 * the supplied name to the supplied value.
+	 * 
+	 * @param name The name
+	 * @param value The value
+	 */
+	public void setProperty(String name, Object value) {
+		m_properties.put(name, value);
+	}
+	
+	/**
+	 * This method returns the set of property names
+	 * associated with the model reference.
+	 * 
+	 * @return The set of property names
+	 */
+	public java.util.Set<String> getPropertyNames() {
+		return(m_properties.keySet());
+	}
+	
+	/**
+	 * This method determines whether another reference, that
+	 * implements (or conforms to) this reference, can be
+	 * used.
+	 * 
+	 * @return Whether to use an implementation of this
+	 * 				referenced model
+	 */
+	public boolean useImplementations() {
+		return(false);
+	}
+	
+	/**
+	 * This method returns the property associated with
+	 * the supplied name.
+	 * 
+	 * @param name The name
+	 * @return The value, or null if not found
+	 */
+	public Object getProperty(String name) {
+		return(m_properties.get(name));
+	}
+	
+	/**
+	 * This method determines if the named property
+	 * is associated with the model reference.
+	 * 
+	 * @param name The property name
+	 * @return Whether the property is associated with the
+	 * 					model reference
+	 */
+	public boolean hasProperty(String name) {
+		return(m_properties.containsKey(name));
+	}
+	
+	/**
+	 * This method determines if the supplied object is
+	 * equivalent to this object.
+	 * 
+	 * @param other The other object
+	 * @return Whether the objects are equal
+	 */
+	public boolean equals(Object other) {
+		boolean ret=false;
+		
+		// TODO: Do we need to consider comparison against a model ref
+		// with just an alias???
+		
+		if (other instanceof ModelReference) {
+			ModelReference ref=(ModelReference)other;
+			
+			ret = compare(m_namespace, ref.m_namespace);
+			
+			if (ret) {
+				ret = compare(m_localpart, ref.m_localpart);
+			}
+			
+			if (ret) {
+				ret = m_subDefinitionPath.equals(
+							ref.m_subDefinitionPath);
+			}
+			
+			if (ret) {
+				ret = compare(m_locatedRole, ref.m_locatedRole);
+			}
+			
+			if (ret) {
+				ret = compare(m_notation, ref.m_notation);
+			}
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method compares two strings.
+	 * 
+	 * @param first The first string
+	 * @param second The second string
+	 * @return Whether the strings are the same
+	 */
+	protected boolean compare(String first, String second) {
+		boolean ret=true;
+		
+		if (first == null && second != null) {
+			ret = false;
+		} else if (first != null && second == null) {
+			ret = false;
+		} else if (first != null) {
+			ret = first.equals(second);
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the hash code.
+	 * 
+	 * @return The hash code
+	 */
+	public int hashCode() {
+		int ret=0;
+		
+		if (getAlias() != null) {
+			ret = getAlias().hashCode();
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the textual representation of the model
+	 * reference.
+	 * 
+	 * @return The textual representation
+	 */
+	public String toText() {
+		String ret=getNamespace();
+		
+		if (ret == null) {
+			ret = getAlias();
+		} else {
+			ret += "."+getAlias();
+		}
+		
+		if (getLocatedRole() != null) {
+			ret += LOCATED_REFERENCE_SEPARATOR+getLocatedRole();
+		}
+		
+		return(ret);
+	}
+	
+	public String toString() {
+		String subdefnpath=m_subDefinitionPath.toString();
+				
+		return("Ref["+getAlias()+" ns="+m_namespace+" lp="+
+				m_localpart+subdefnpath+" loc="+m_locatedRole+
+				" "+m_notation+"]");
+	}
+	
+	public static final String NAMESPACES_TO_MONITOR="NamespacesToMonitor";
+	public static final String LOCATED_REFERENCE_SEPARATOR="@";
+	
+	private String m_alias=null;
+	private String m_namespace=null;
+	private String m_localpart=null;
+	private SubDefinitionPath m_subDefinitionPath=new SubDefinitionPath();
+	private String m_locatedRole=null;
+	private String m_notation=null;
+	private boolean m_inner=false;
+	private boolean m_fullyQualified=false;
+	private boolean m_placeholder=false;
+	private java.util.Hashtable<String, Object> m_properties=new java.util.Hashtable<String, Object>();
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/MultiPathBehaviour.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/MultiPathBehaviour.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/MultiPathBehaviour.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 29 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.model;
+
+/**
+ * This interface represents behaviours that are associated
+ * with multiple paths.
+ */
+public abstract class MultiPathBehaviour extends Behaviour {
+
+	private static final long serialVersionUID = 2630833363341001897L;
+
+	/**
+	 * This method returns whether the behaviour is a grouping
+	 * construct.
+	 * 
+	 * @return Whether the behaviour is a grouping construct 
+	 */
+	@Override
+	public boolean isGroupingConstruct() {
+		return(true);
+	}
+	
+	/**
+	 * This method returns the list of mutually exclusive
+	 * activity blocks that comprise the multi-path construct.
+	 * 
+	 * @return The list of blocks
+	 */
+	public abstract java.util.List<Block> getPaths();
+	
+	/**
+	 * This method creates a new path within the multi-path
+	 * behaviour. If the implementation cannot create
+	 * the new path, then it will return null.
+	 * 
+	 * @return The new block, or null if cannot be created
+	 */
+	public abstract Block createNewPath();
+	
+	/**
+	 * This method removes a path from the multi-path
+	 * behaviour.
+	 * 
+	 * @param path The path
+	 * @return Whether the path was removed
+	 */
+	public abstract boolean removePath(Block path);
+	
+	/**
+	 * This method indicates whether the construct requires a
+	 * strict scope to be maintained. If the scope does not
+	 * need to be strictly maintained, then it is possible that
+	 * either activities relevant to each path could either
+	 * be duplicated within each path, or shared following
+	 * the construct.
+	 * 
+	 * @return Whether a strict scope should be maintained
+	 */
+	public boolean isStrictScope() {
+		return(false);
+	}
+	
+	/**
+	 * This method indicates whether the construct is
+	 * conditional.
+	 * 
+	 * @return Whether the construct is conditional
+	 */
+	public boolean isConditional() {
+		return(false);
+	}
+	
+	/**
+	 * This method determines whether the paths are mutually
+	 * exclusive.
+	 * 
+	 * @return Whether the paths are mutually exclusive
+	 */
+	public boolean isMutuallyExclusivePaths() {
+		return(false);
+	}
+	
+	/**
+	 * This method returns the ordering constraint for
+	 * the multipath behaviour.
+	 * 
+	 * @return The ordering constraint
+	 */
+	public abstract OrderingConstraint getOrdering();
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/NameMappingReference.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/NameMappingReference.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/NameMappingReference.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 20 Mar 2008 : Initial version created by gary
+ */
+package org.scribble.model;
+
+/**
+ * This interfaces represents a reference that has
+ * associated name mapping information.
+ */
+public abstract class NameMappingReference extends ModelReference {
+
+	private static final long serialVersionUID = -4511382903786589595L;
+
+	/**
+	 * This is the constructor for a name mapping reference.
+	 * 
+	 * @param notation The notation
+	 */
+	public NameMappingReference(String notation) {
+		super(notation);
+	}
+
+	/**
+	 * This is the copy constructor for the name mapping
+	 * reference.
+	 * 
+	 * @param ref The reference to copy
+	 */
+	public NameMappingReference(NameMappingReference ref) {
+		super(ref);
+		
+		java.util.Iterator<String> iter=ref.getNameMapping().keySet().iterator();
+		
+		while (iter.hasNext()) {
+			String key=iter.next();
+			String value=ref.getNameMapping().get(key);
+			
+			getNameMapping().put(key, value);
+		}
+	}
+	
+	/**
+	 * This method returns the mapping between names in the main
+	 * definition and the definition being implemented.
+	 * 
+	 * @return The name mapping information
+	 */
+	public java.util.Map<String,String> getNameMapping() {
+		return(m_nameMapping);
+	}
+	
+	private java.util.Map<String,String> m_nameMapping=new java.util.Hashtable<String,String>();
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Namespace.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Namespace.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Namespace.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 22 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.model;
+
+/**
+ * This class represents the namespace associated with a model.
+ * 
+ */
+public class Namespace extends Statement {
+
+	private static final long serialVersionUID = 2546583254402988900L;
+
+	/**
+	 * The default constructor.
+	 */
+	public Namespace() {
+	}
+	
+	/**
+	 * This method returns the name associated with the namespace.
+	 * 
+	 * @return The name
+	 */
+	public String getName() {
+		return(m_name);
+	}
+	
+	/**
+	 * This method sets the name associated with the namespace.
+	 * 
+	 * @param name The namespace
+	 */
+	public void setName(String name) {
+		m_name = name;
+	}
+	
+	private String m_name=null;
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Notation.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Notation.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Notation.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 23 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.model;
+
+/**
+ * This interface represents the details associated with a
+ * Scribble notation.
+ */
+public interface Notation {
+
+	/**
+	 * This method returns the code associated with the notation.
+	 * 
+	 * @return The notation code
+	 */
+	public String getCode();
+	
+	/**
+	 * This method returns the name of the notation.
+	 * 
+	 * @return The name
+	 */
+	public String getName();
+	
+	/**
+	 * This method returns the initial description associated
+	 * with the supplied reference.
+	 * 
+	 * @param ref The reference
+	 * @return The initial description, or null if no description
+	 */
+	public String getInitialDescription(ModelReference ref);
+	
+	/**
+	 * This method determines whether the Scribble editor should
+	 * be used for editing the notation.
+	 * 
+	 * @return Whether the Scribble editor should be used
+	 */
+	public boolean useScribbleEditor();
+	
+	/**
+	 * This method returns the optional 'super' notation.
+	 * If defined, then this notation is a derived notation
+	 * from the 'super' notation.
+	 * 
+	 * @return The optional 'super' notation
+	 */
+	public Notation getSuperNotation();
+
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/OrderingConstraint.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/OrderingConstraint.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/OrderingConstraint.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 18 Oct 2008 : Initial version created by gary
+ */
+package org.scribble.model;
+
+/**
+ * This enumeration determines the ordering constraint for a
+ * grouping construct.
+ */
+public enum OrderingConstraint {
+	Unordered,
+	Ordered
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Reference.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Reference.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Reference.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 28 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.model;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation type provides information about a relationship
+ * within the Scribble model.
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target(ElementType.METHOD)
+public @interface Reference {
+
+	boolean containment() default false;
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Role.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Role.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Role.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 22 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.model;
+
+/**
+ * This class represents a role.
+ * 
+ */
+public class Role extends ModelObject implements Declaration {
+
+	private static final long serialVersionUID = 3368940100177769548L;
+
+	/**
+	 * This is the default constructor.
+	 */
+	public Role() {
+	}
+	
+	/**
+	 * This is the copy constructor.
+	 * 
+	 * @param role The role
+	 */
+	public Role(Role role) {
+		m_name = role.getName();
+	}
+	
+	/**
+	 * This constructor initializes the role with a name.
+	 * 
+	 * @param roleName The role name
+	 */
+	public Role(String roleName) {
+		m_name = roleName;
+	}
+	
+	/**
+	 * This method returns the name of the role.
+	 * 
+	 * @return The name
+	 */
+	public String getName() {
+		return(m_name);
+	}
+	
+	/**
+	 * This method sets the name of the role.
+	 * 
+	 * @param name The name
+	 */
+	public void setName(String name) {
+		m_name = name;
+	}
+	
+	public boolean equals(Object obj) {
+		boolean ret=false;
+	
+		if (obj instanceof Role) {
+			Role other=(Role)obj;
+			
+			if (other.getName() != null && other.getName().equals(m_name)) {
+				ret = true;
+			}
+		}
+		
+		return(ret);
+	}
+	
+	public int hashCode() {
+		int ret=super.hashCode();
+		
+		if (m_name != null) {
+			ret = m_name.hashCode();
+		}
+		
+		return(ret);
+	}
+	
+	public String toString() {
+		return(getName());
+	}
+	
+	private String m_name=null;	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/RoleList.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/RoleList.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/RoleList.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 22 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.model;
+
+/**
+ * This class represents the list of roles declared within
+ * a Scribble definition.
+ */
+public class RoleList extends Activity {
+
+	private static final long serialVersionUID = -536190968014907396L;
+
+	/**
+	 * This method returns the list of roles.
+	 * 
+	 * @return The list of roles
+	 */
+	@Reference(containment=true)
+	public java.util.List<Role> getRoles() {
+		return(m_roles);
+	}
+	
+	/**
+	 * This method returns the role associated with
+	 * the supplied name.
+	 * 
+	 * @param name The role name
+	 * @return The role, or null if not found
+	 */
+	public Role getRole(String name) {
+		Role ret=null;
+		
+		for (int i=0; ret == null &&
+					i < m_roles.size(); i++) {
+			if (m_roles.get(i).getName().equals(name)) {
+				ret = m_roles.get(i);
+			}
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method determines whether the roles in the
+	 * list are 'open', meaning they can be bound to.
+	 * 
+	 * @return Whether the role list is 'open'
+	 */
+	public boolean isOpen() {
+		return(m_open);
+	}
+	
+	/**
+	 * This method sets whether the role list is 'open'.
+	 *  
+	 * @param open Whether the role list should be open
+	 */
+	public void setOpen(boolean open) {
+		m_open = open;
+	}
+	
+	private boolean m_open=false;
+	private java.util.List<Role> m_roles=
+			new ContainmentList<Role>(this, Role.class);
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/SinglePathBehaviour.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/SinglePathBehaviour.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/SinglePathBehaviour.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 12 Mar 2008 : Initial version created by gary
+ */
+package org.scribble.model;
+
+/**
+ * This interface represents behaviours that are associated
+ * with a single path.
+ */
+public abstract class SinglePathBehaviour extends Behaviour {
+
+	private static final long serialVersionUID = -2129339015295636976L;
+
+	/**
+	 * This method returns whether the behaviour is a grouping
+	 * construct.
+	 * 
+	 * @return Whether the behaviour is a grouping construct 
+	 */
+	@Override
+	public boolean isGroupingConstruct() {
+		return(true);
+	}
+	
+	/**
+	 * This method returns the block of activities
+	 * associated with the single path.
+	 * 
+	 * @return The block of activities
+	 */
+	public abstract Block getBlock();
+	
+	/**
+	 * This method indicates whether the construct requires a
+	 * strict scope to be maintained. If the scope does not
+	 * need to be strictly maintained, then it is possible that
+	 * activities could be contained by the construct or
+	 * following the construct.
+	 * 
+	 * @return Whether a strict scope should be maintained
+	 */
+	public boolean isStrictScope() {
+		return(false);
+	}
+	
+	/**
+	 * This method indicates whether the construct is
+	 * conditional.
+	 * 
+	 * @return Whether the construct is conditional
+	 */
+	public boolean isConditional() {
+		return(false);
+	}
+	
+	/**
+	 * This method indicates whether the construct is
+	 * repetitive.
+	 * 
+	 * @return Whether the construct supports repetition
+	 */
+	public boolean isRepetition() {
+		return(false);
+	}
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/SourceRef.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/SourceRef.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/SourceRef.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,219 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 9 Jun 2008 : Initial version created by gary
+ */
+package org.scribble.model;
+
+public class SourceRef implements java.io.Serializable {
+
+	private static final long serialVersionUID = -6129050166122933390L;
+
+	/**
+	 * This is the default constructor.
+	 */
+	public SourceRef() {
+	}
+	
+	/**
+	 * This is the copy constructor for the source reference.
+	 * 
+	 * @param ref The source reference to copy
+	 */
+	public SourceRef(SourceRef ref) {
+		m_startPosition = ref.getStartPosition();
+		m_endPosition = ref.getEndPosition();
+		m_modelObjectURI = ref.getModelObjectURI();
+		m_componentURI = ref.getComponentURI();
+		m_object = ref.getObject();
+		m_properties.putAll(ref.getProperties());
+	}
+	
+	/**
+	 * This is the constructor to initialize the source reference
+	 * using positional information.
+	 * 
+	 * @param start The start position
+	 * @param end The end position
+	 */
+	public SourceRef(int start, int end) {
+		setStartPosition(start);
+		setEndPosition(end);
+	}
+	
+	/**
+	 * This method sets the start position of this model object
+	 * within the source description.
+	 * 
+	 * @param pos The start position, or -1 if not relevant
+	 */
+	public void setStartPosition(int pos) {
+		m_startPosition = pos;
+	}
+	
+	/**
+	 * This method returns the start position of this model object
+	 * within the source description.
+	 * 
+	 * @return The start position, or -1 if not set
+	 */
+	public int getStartPosition() {
+		return(m_startPosition);
+	}
+	
+	/**
+	 * This method sets the end position of this model object
+	 * within the source description.
+	 * 
+	 * @param pos The end position, or -1 if not relevant
+	 */
+	public void setEndPosition(int pos) {
+		m_endPosition = pos;
+	}
+	
+	/**
+	 * This method returns the end position of this model object
+	 * within the source description.
+	 * 
+	 * @return The end position, or -1 if not set
+	 */
+	public int getEndPosition() {
+		return(m_endPosition);
+	}
+	
+	/**
+	 * This method returns the model object location within
+	 * the model.
+	 * 
+	 * @return The model object URI
+	 */
+	public String getModelObjectURI() {
+		return(m_modelObjectURI);	
+	}
+	
+	/**
+	 * This method sets the model object location within the
+	 * model.
+	 * 
+	 * @param uri The model object URI
+	 */
+	public void setModelObjectURI(String uri) {
+		m_modelObjectURI = uri;
+	}
+	
+	/**
+	 * This method returns the optional component location within the
+	 * source model. This can be used to locate the source component
+	 * associated with the Scribble model object. The format of the
+	 * location will be dependent upon the nature of the model from
+	 * which the Scribble model was derived.
+	 * 
+	 * @return The component location
+	 */
+	public String getComponentURI() {
+		return(m_componentURI);	
+	}
+	
+	/**
+	 * This method sets the component location within the
+	 * source model.
+	 * 
+	 * @param component The component location
+	 */
+	public void setComponentURI(String component) {
+		m_componentURI = component;
+	}
+	
+	/**
+	 * This method returns the object associated with the
+	 * source reference. If the object is not available then
+	 * it can be resolved using the start/end and/or component
+	 * information.
+	 * 
+	 * @return The object, or null if not defined
+	 */
+	public Object getObject() {
+		return(m_object);
+	}
+	
+	/**
+	 * This method sets the object within the
+	 * source model.
+	 * 
+	 * @param obj The object
+	 */
+	public void setObject(Object obj) {
+		m_object = obj;
+	}
+	
+	/**
+	 * This method returns the set of additional properties
+	 * that are associated with the source reference.
+	 * 
+	 *@return The additional properties
+	 */
+	public java.util.Map<String,Object> getProperties() {
+		return(m_properties);
+	}
+	
+	public String toString() {
+		String ret="";
+		
+		if (m_componentURI != null) {
+			ret = m_componentURI;
+		}
+		
+		if (m_startPosition != -1) {
+			if (ret.length() > 0) {
+				ret += ",";
+			}
+			ret += "start="+m_startPosition;
+		}
+		
+		if (m_endPosition != -1) {
+			if (ret.length() > 0) {
+				ret += ",";
+			}
+			ret += "end="+m_endPosition;
+		}
+		
+		return(ret);
+	}
+	
+	public boolean equals(Object obj) {
+		boolean ret=false;
+
+		if (obj instanceof SourceRef) {
+			SourceRef other=(SourceRef)obj;
+			
+			if (m_modelObjectURI != null &&
+					other.m_modelObjectURI != null) {
+				ret = m_modelObjectURI.equals(other.m_modelObjectURI);
+			}
+		}
+		
+		return(ret);
+	}
+	
+	private int m_startPosition=-1;
+	private int m_endPosition=-1;
+	private String m_modelObjectURI=null;
+	private String m_componentURI=null;
+	private Object m_object=null;
+	private java.util.Map<String,Object> m_properties=
+				new java.util.HashMap<String, Object>();
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Statement.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Statement.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Statement.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 22 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.model;
+
+/**
+ * This class represents the base class for all Scribble statements.
+ */
+public abstract class Statement extends ModelObject {
+
+	private static final long serialVersionUID = -3646837175049449380L;
+
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/SubDefinitionPath.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/SubDefinitionPath.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/SubDefinitionPath.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,144 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 26 Apr 2009 : Initial version created by gary
+ */
+package org.scribble.model;
+
+/**
+ * This class provides the path to a definition scope contained
+ * within a top level definition.
+ */
+public class SubDefinitionPath {
+
+	/**
+	 * The default constructor.
+	 */
+	public SubDefinitionPath() {		
+	}
+	
+	/**
+	 * This constructor is initialised with the arrau of
+	 * path elements.
+	 * 
+	 * @param elems The array of path elements
+	 */
+	public SubDefinitionPath(String[] elems) {
+		for (int i=0; i < elems.length; i++) {
+			m_path.add(elems[i]);
+		}
+	}
+	
+	/**
+	 * The copy constructor.
+	 * 
+	 * @param sdp The path to copy
+	 */
+	public SubDefinitionPath(SubDefinitionPath sdp) {
+		m_path.addAll(sdp.m_path);
+	}
+	
+	/**
+	 * This method adds an element to the end of the path.
+	 * 
+	 * @param elem The element
+	 */
+	public void addPathElement(String elem) {
+		m_path.add(elem);
+	}
+	
+	/**
+	 * This method adds an element to the specified location
+	 * within the path.
+	 * 
+	 * @param pos The position
+	 * @param elem The element
+	 */
+	public void addPathElement(int pos, String elem) {
+		m_path.add(pos, elem);
+	}
+	
+	/**
+	 * This method returns the element at the specified position
+	 * within the path.
+	 * 
+	 * @param pos The position
+	 * @return The element
+	 */
+	public String getPathElement(int pos) {
+		return(m_path.get(pos));
+	}
+	
+	/**
+	 * This method removes an element from the specified location
+	 * within the path.
+	 * 
+	 * @param pos The position
+	 * @return The removed element
+	 */
+	public String removePathElement(int pos) {
+		return(m_path.remove(pos));
+	}
+	
+	/**
+	 * This method returns the number of elements within the
+	 * path.
+	 * 
+	 * @return The number of elements in the path
+	 */
+	public int getPathElementCount() {
+		return(m_path.size());
+	}
+	
+	/**
+	 * This method clears the path associated with the sub
+	 * definition.
+	 */
+	public void clear() {
+		m_path.clear();
+	}
+	
+	public boolean equals(Object other) {
+		boolean ret=false;
+		
+		if (other instanceof SubDefinitionPath) {
+			SubDefinitionPath sdp=(SubDefinitionPath)other;
+			
+			ret = (m_path.size() ==
+				sdp.m_path.size());
+
+			for (int i=0; ret && i < m_path.size(); i++) {
+				ret = m_path.get(i).equals(
+							sdp.m_path.get(i));
+			}
+		}
+		
+		return(ret);
+	}
+	
+	public String toString() {
+		String ret="";
+		
+		for (int i=0; i < m_path.size(); i++) {
+			ret += "$"+m_path.get(i);
+		}
+		
+		return(ret);
+	}		
+	
+	private java.util.List<String> m_path=new java.util.Vector<String>();
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/TypeModel.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/TypeModel.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/TypeModel.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 23 Jan 2008 : Initial version created by gary
+ */
+package org.scribble.model;
+
+import java.util.List;
+
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This class represents the protocol model.
+ * 
+ */
+ at RegistryInfo(extension=Model.class)
+public class TypeModel extends Model {
+
+	private static final long serialVersionUID = 5245035155865638862L;
+
+	/**
+	 * This method returns the notation associated with
+	 * the model.
+	 * 
+	 * @return The notation
+	 */
+	public String getNotation() {
+		return(TYPE);
+	}
+	
+	/**
+	 * This method returns the model name associated with
+	 * the model.
+	 * 
+	 * @return The model name
+	 */
+	public LocatedName getModelName() {
+		return(m_modelName);
+	}
+	
+	/**
+	 * This method is used to set the model name.
+	 * 
+	 * @param modelName The model name
+	 */
+	public void setModelName(LocatedName modelName) {
+		m_modelName = modelName;
+	}
+	
+	/**
+	 * This method returns a read-only list of roles
+	 * associated with the model. If this model represents
+	 * a local model, then the roles in the list
+	 * will be the remote roles, with the local
+	 * role being associated with the model name.
+	 * 
+	 * @return The read-only list of roles, or null if
+	 * 			roles are not relevant for this model
+	 */
+	public java.util.List<Role> getRoles() {
+		return(null);
+	}
+
+	@Override
+	public List<Definition> getDefinitions() {
+		return(new java.util.Vector<Definition>());
+	}
+	
+	public static final String TYPE="stp";
+
+	private LocatedName m_modelName=null;
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/TypeNotation.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/TypeNotation.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/TypeNotation.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 8 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.model;
+
+import org.scribble.extensions.*;
+
+/**
+ * This class represents the type notation.
+ */
+ at RegistryInfo(extension=org.scribble.model.Notation.class)
+public class TypeNotation extends org.scribble.model.AbstractNotation {
+
+	/**
+	 * This is the default constructor for the type notation.
+	 */
+	public TypeNotation() {
+		super(TypeModel.TYPE, "Type", true);
+	}
+	
+	/**
+	 * This method returns the initial description associated
+	 * with the supplied reference.
+	 * 
+	 * @param ref The reference
+	 * @return The initial description, or null if no description
+	 */
+	public String getInitialDescription(ModelReference ref) {
+		return(null);
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/TypeReference.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/TypeReference.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/TypeReference.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 24 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.model;
+
+/**
+ * This class represents a type reference.
+ */
+public class TypeReference extends ModelReference {
+
+	private static final long serialVersionUID = 6492984753933254949L;
+
+	/**
+	 * This is the default constructor for the type reference.
+	 */
+	public TypeReference() {
+		super(TypeModel.TYPE);
+	}
+
+	/**
+	 * This method determines whether another reference, that
+	 * implements (or conforms to) this reference, can be
+	 * used.
+	 * 
+	 * @return Whether to use an implementation of this
+	 * 				referenced model
+	 */
+	public boolean useImplementations() {
+		return(true);
+	}
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Visitor.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Visitor.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/Visitor.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 18 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.model;
+
+/**
+ * This interface represents a visitor which can be used
+ * to traverse a model.
+ */
+public interface Visitor {
+
+	/**
+	 * This method visits the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @return Whether contained objects should be visited
+	 */
+	public boolean visit(ModelObject obj);
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/admin/AbstractModelRepository.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/admin/AbstractModelRepository.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/admin/AbstractModelRepository.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,157 @@
+/*
+ * Copyright 2007-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 29 Jun 2009 : Initial version created by gary
+ */
+package org.scribble.model.admin;
+
+import org.scribble.extensions.RegistryFactory;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelChangeListener;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.model.admin.ModelRepository;
+
+import java.util.logging.*;
+
+/**
+ * This class represents the abstract implementation for the
+ * model repository. Derived classes will be responsible
+ * for grounding the implementation for a specific repository
+ * type.
+ *
+ */
+public abstract class AbstractModelRepository implements ModelRepository {
+
+	/**
+	 * This is the default constructor for the abstract OSGi Model Repository.
+	 */
+	public AbstractModelRepository() {
+	}
+	
+	/**
+	 * This method returns the model associated with the supplied
+	 * Scribble reference.
+	 * 
+	 * @param ref The scribble reference
+	 * @param l The model listener
+	 * @return The scribble model
+	 */
+	public Model getModel(ModelReference ref, ModelListener l) {
+		Model ret=null;
+		
+		synchronized(this) {
+			if (logger.isLoggable(Level.FINEST)) {
+				logger.finest("Get models for: "+ref);
+			}
+			
+			// Load model and invoke the parser
+			java.io.InputStream is=getInputStream(ref);
+			
+			if (is != null) {
+				org.scribble.parser.Parser parser=(org.scribble.parser.Parser)
+						org.scribble.extensions.RegistryFactory.getRegistry().getExtension(
+								org.scribble.parser.Parser.class, ref.getNotation());
+
+				if (parser != null) {
+					ret=parser.parse(ref, is, l, null);
+
+					if (ret != null) {
+						ret.initializeURIs();
+					}
+				}
+			}
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method updates the model, associated with the
+	 * supplied reference, with the contents of the specified
+	 * model.
+	 * 
+	 * @param ref The model reference
+	 * @param model The model
+	 * @throws java.io.IOException Failed to update the model
+	 */
+	public void updateModel(ModelReference ref, Model model)
+								throws java.io.IOException {
+		
+		org.scribble.export.Exporter exporter=
+			(org.scribble.export.Exporter)
+			RegistryFactory.getRegistry().getExtension(
+					org.scribble.export.Exporter.class, null);
+		
+		org.scribble.export.stream.StreamFormatter formatter=
+				new org.scribble.export.stream.StreamFormatter();
+		
+		java.io.ByteArrayOutputStream os=new java.io.ByteArrayOutputStream();
+	
+		formatter.setOutputStream(os);
+		
+		exporter.export(ref, model, formatter);
+	
+		byte[] b=os.toByteArray();
+	
+		os.close();
+	
+		java.io.ByteArrayInputStream is=
+				new java.io.ByteArrayInputStream(b);
+	
+		updateModel(ref, is);
+		
+		is.close();
+	}
+
+	/**
+	 * This method applies the updated model, defined in the supplied input
+	 * stream, to the repository resource associated with the supplied reference.
+	 * 
+	 * @param ref The model reference
+	 * @param is The input stream
+	 * @throws java.io.IOException Failed to update the model
+	 */
+	protected void updateModel(ModelReference ref, java.io.InputStream is)
+										throws java.io.IOException {
+		throw new java.io.IOException("Unsupported operation");
+	}
+
+	/**
+	 * This method returns the input stream for the source associated
+	 * with the model reference.
+	 * 
+	 * @param ref The model reference
+	 * @return The input stream
+	 */
+	protected abstract java.io.InputStream getInputStream(ModelReference ref);
+		
+	private static Logger logger = Logger.getLogger("org.scribble.model.admin");
+	
+	private static java.util.List<org.scribble.model.Notation> m_notations=new java.util.Vector<org.scribble.model.Notation>();
+	private java.util.List<ModelChangeListener> m_listeners=new java.util.Vector<ModelChangeListener>();
+
+	static {
+		// Register the notations to be supported
+		java.util.List<Object> notations=
+			org.scribble.extensions.RegistryFactory.getRegistry().getExtensions(
+						org.scribble.model.Notation.class, null);
+		
+		for (int i=0; i < notations.size(); i++) {
+			m_notations.add((org.scribble.model.Notation)notations.get(i));
+		}
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/admin/Context.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/admin/Context.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/admin/Context.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.scribble.model.admin;
+
+import org.scribble.model.ModelReference;
+
+/**
+ * This interface provides access to the environment in which a tool is
+ * being used.
+ *
+ */
+public interface Context {
+
+	/**
+	 * This method can be used to retrieve the contents of a resource which
+	 * is located at the specified URI. If the URI is a relative path, then
+	 * the supplied model reference can be used to identify the source from
+	 * which the path is relative.
+	 * 
+	 * @param ref The model reference for the source file
+	 * @param uri The URI of the resource to load
+	 * @return The input stream, or null if not found
+	 */
+	public java.io.InputStream getResource(ModelReference ref, String uri);
+	
+	/**
+	 * This method can be used to retrieve the URI of a resource which
+	 * is located at the specified URI. If the URI is a relative path, then
+	 * the supplied model reference can be used to identify the source from
+	 * which the path is relative.
+	 * 
+	 * @param ref The model reference for the source file
+	 * @param uri The URI of the resource to load
+	 * @return The URI, or null if not found
+	 */
+	public java.net.URI getResourceURI(ModelReference ref, String uri);
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/admin/DefaultModelChangeListener.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/admin/DefaultModelChangeListener.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/admin/DefaultModelChangeListener.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 8 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.model.admin;
+
+import org.scribble.model.ModelReference;
+
+/**
+ * This class represents a default model change listener.
+ * 
+ */
+public class DefaultModelChangeListener implements ModelChangeListener {
+
+	/**
+	 * This method reports a new model has been added.
+	 * 
+	 * @param ref The reference associated with the model
+	 */
+	public void modelAdded(ModelReference ref) {
+	}
+	
+	/**
+	 * This method reports an update to a model.
+	 * 
+	 * @param ref The reference associated with the model
+	 */
+	public void modelUpdated(ModelReference ref) {
+	}
+	
+	/**
+	 * This method reports an existing model has been removed.
+	 * 
+	 * @param ref The reference associated with the model
+	 */
+	public void modelRemoved(ModelReference ref) {
+	}
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/admin/DefaultModelListener.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/admin/DefaultModelListener.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/admin/DefaultModelListener.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,211 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 11 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.model.admin;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.scribble.model.ModelObject;
+import org.scribble.model.ModelReference;
+import org.scribble.model.resolutions.*;
+
+/**
+ * This class provides the default implementation of the model listener
+ * interface.
+ */
+public class DefaultModelListener implements ModelListener {
+	
+	/**
+	 * The default constructor.
+	 */
+	public DefaultModelListener() {
+	}
+	
+	/**
+	 * This constructor initializes the default model listener
+	 * with an optional external source model reference.
+	 * 
+	 * @param externalSource The optional external source
+	 */
+	public DefaultModelListener(ModelReference externalSource) {
+		m_composedModelSource = externalSource;
+	}
+
+	/**
+	 * This method reports errors detected in model analysis.
+	 * 
+	 * @param issue The issue
+	 */
+	public void error(ModelIssue issue) {
+		
+		if (logger.isLoggable(Level.FINE)) {
+			logger.fine("Reporting error: "+issue.getMessage());
+		}
+		
+		m_errors.add(issue);
+	}
+
+	/**
+	 * This method reports warnings detected in model analysis.
+	 * 
+	 * @param issue The issue
+	 */
+	public void warning(ModelIssue issue) {
+		m_warnings.add(issue);
+	}
+	
+	/**
+	 * This method applies the errors and warnings to the supplied
+	 * model listener.
+	 * 
+	 * @param l The model listener
+	 * @param override The optional model object to override the existing
+	 * 				entries model objects
+	 * @param props Additional properties
+	 * @param resolutions The resolutions
+	 */
+	public void apply(ModelListener l, ModelObject override,
+						java.util.Map<String,Object> props,
+						java.util.List<Resolution> resolutions) {
+		
+		for (int i=0; i < m_errors.size(); i++) {
+			ModelIssue entry=m_errors.get(i);			
+			ModelObject src=entry.getModelObject();
+			
+			if (override != null) {
+				src = override;
+			}
+			
+			ModelIssue newEntry=new ModelIssue(src, applyMessage(entry.getMessage()),
+					applyProperties(entry.getProperties(),entry.getModelObject(),
+							props));
+			
+			newEntry.getResolutions().addAll(entry.getResolutions());
+			
+			if (resolutions != null) {
+				for (int j=0; j < resolutions.size(); j++) {
+					if (newEntry.getResolutions().contains(resolutions.get(j)) == false) {
+						newEntry.getResolutions().add(resolutions.get(j));
+					}
+					
+				}
+			}
+			
+			if (getComposedSource() != null) {
+				ShowComposedIssue res=new ShowComposedIssue();
+				res.setComposedModel(getComposedSource());
+				res.setSourceReference(entry.getModelObject().getSource());
+				newEntry.getResolutions().add(res);
+			}
+
+			l.error(newEntry);
+		}
+		
+		for (int i=0; i < m_warnings.size(); i++) {
+			ModelIssue entry=m_warnings.get(i);
+			ModelObject src=entry.getModelObject();
+			
+			if (override != null) {
+				src = override;
+			}
+			
+			ModelIssue newEntry=new ModelIssue(src, applyMessage(entry.getMessage()),
+					applyProperties(entry.getProperties(),entry.getModelObject(),
+							props));
+			
+			newEntry.getResolutions().addAll(resolutions);
+			
+			if (getComposedSource() != null) {
+				ShowComposedIssue res=new ShowComposedIssue();
+				res.setComposedModel(getComposedSource());
+				res.setSourceReference(entry.getModelObject().getSource());
+				newEntry.getResolutions().add(res);
+			}
+
+			l.warning(newEntry);
+		}
+	}
+	
+	/**
+	 * This method determines what message should be returned.
+	 * 
+	 * @param mesg
+	 * @return The message to use
+	 */
+	protected String applyMessage(String mesg) {
+		String ret=mesg;
+		
+		if (getComposedSource() != null) {
+			String externalMessagePrefix=
+					java.util.PropertyResourceBundle.getBundle(
+						"org.scribble.model.admin.Messages").
+							getString("_COMPOSED_ISSUE_PREFIX");
+			
+			if (ret.startsWith(externalMessagePrefix) == false) {
+				ret = externalMessagePrefix+ret;
+			}
+		}
+		
+		return(ret);
+	}
+
+	protected java.util.Map<String,Object> applyProperties(java.util.Map<String,Object> props,
+						ModelObject modelObject,
+						java.util.Map<String,Object> additionalProps) {
+		java.util.Map<String,Object> ret=props;
+		
+		// Copy additional properties if defined
+		if (additionalProps != null) {
+			if (ret == null) {
+				ret = new java.util.HashMap<String,Object>();
+			}
+			
+			ret.putAll(additionalProps);
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the list of errors reported to the model
+	 * listener.
+	 * 
+	 * @return The model listener
+	 */
+	public java.util.List<ModelIssue> getErrors() {
+		return(m_errors);
+	}
+	
+	/**
+	 * This method returns the optional composed source model reference
+	 * associated with the errors and warnings being reported.
+	 * 
+	 * @return The optional composed source
+	 */
+	public ModelReference getComposedSource() {
+		return(m_composedModelSource);
+	}
+	
+	private static Logger logger = Logger.getLogger("org.scribble.model.admin");
+
+	private ModelReference m_composedModelSource=null;
+	private java.util.List<ModelIssue> m_errors=new java.util.Vector<ModelIssue>();
+	private java.util.List<ModelIssue> m_warnings=new java.util.Vector<ModelIssue>();
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/admin/DefaultResolution.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/admin/DefaultResolution.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/admin/DefaultResolution.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 7 Sep 2008 : Initial version created by gary
+ */
+package org.scribble.model.admin;
+
+import org.scribble.model.ModelReference;
+import org.scribble.model.SourceRef;
+import org.scribble.model.resolutions.Resolution;
+import org.scribble.model.resolutions.ResolutionException;
+
+/**
+ * This class provides a default implementation of the
+ * Resolution interface, which can be configured with
+ * the required information to instantiate the resolution,
+ * or derived to create the actual resolution implementation.
+ */
+public class DefaultResolution implements Resolution {
+
+	/**
+	 * This is the default constructor for the
+	 * default resolution implementation.
+	 */
+	public DefaultResolution() {
+	}
+	
+	/**
+	 * This method returns the name of the resolution.
+	 * 
+	 * @return The name
+	 */
+	public String getName() {
+		return(m_name);
+	}
+	
+	/**
+	 * This method sets the name of the resolution.
+	 * 
+	 * @param name The name
+	 */
+	public void setName(String name) {
+		m_name = name;
+	}
+	
+	/**
+	 * This method returns the description of the resolution.
+	 * 
+	 * @return The description
+	 */
+	public String getDescription() {
+		return(m_description);
+	}
+	
+	/**
+	 * This method sets the description.
+	 * 
+	 * @param desc The description
+	 */
+	public void setDescription(String desc) {
+		m_description = desc;
+	}
+	
+	/**
+	 * This method returns the class associated with the
+	 * resolution. This class must have a default constructor.
+	 * 
+	 * @return The resolution class
+	 */
+	public String getResolutionClass() {
+		return(m_className);
+	}
+	
+	/**
+	 * This method returns the properties used to configure
+	 * the resolution.
+	 * 
+	 * @return The properties
+	 */
+	public java.util.Map<String, Object> getProperties() {
+		return(m_properties);
+	}
+
+	/**
+	 * This method is invoked to perform the resolution
+	 * on the identified model, associated with the model
+	 * object located using the supplied source reference
+	 * information. Further details regarding the issue
+	 * to be resolved is provided by the model issue -
+	 * although the 'model object' part of the model
+	 * issue may not be defined. This will have to be
+	 * recovered using the supplied model and source
+	 * reference.
+	 * 
+	 * @param ref The model reference
+	 * @param obj The source reference of the model object
+	 * @param issue The issue
+	 * @exception ResolutionException Failed to resolve
+	 */
+	public void resolve(ModelReference ref, SourceRef obj,
+					ModelIssue issue) throws ResolutionException {
+	}
+	
+	private String m_name=null;
+	private String m_description=null;
+	private String m_className=getClass().getName();
+	private java.util.Map<String, Object> m_properties=
+					new java.util.HashMap<String, Object>();
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/admin/Messages.properties
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/admin/Messages.properties	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/admin/Messages.properties	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,21 @@
+# /*
+# * Copyright 2005-8 Pi4 Technologies Ltd
+# *
+# * 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.
+# *
+# *
+# * Change History:
+# * 21 Oct 2008 : Initial version created by gary
+# */
+
+_COMPOSED_ISSUE_PREFIX=Composition issue:

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/admin/ModelChangeListener.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/admin/ModelChangeListener.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/admin/ModelChangeListener.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 20 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.model.admin;
+
+import org.scribble.model.ModelReference;
+
+/**
+ * This interface represents a model change listener.
+ * 
+ */
+public interface ModelChangeListener {
+
+	/**
+	 * This method reports a new model has been added.
+	 * 
+	 * @param ref The reference associated with the model
+	 */
+	public void modelAdded(ModelReference ref);
+	
+	/**
+	 * This method reports an update to a model.
+	 * 
+	 * @param ref The reference associated with the model
+	 */
+	public void modelUpdated(ModelReference ref);
+	
+	/**
+	 * This method reports an existing model has been removed.
+	 * 
+	 * @param ref The reference associated with the model
+	 */
+	public void modelRemoved(ModelReference ref);
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/admin/ModelIssue.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/admin/ModelIssue.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/admin/ModelIssue.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,152 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 6 Sep 2008 : Initial version created by gary
+ */
+package org.scribble.model.admin;
+
+import org.scribble.model.ModelObject;
+import org.scribble.model.resolutions.Resolution;
+
+/**
+ * This class represents the information related to an issue
+ * associated with a model object.
+ */
+public class ModelIssue {
+	
+	/**
+	 * This is the default constructor for the model
+	 * issue.
+	 */
+	public ModelIssue() {
+	}
+
+	/**
+	 * This is the constructor for initializing the issue
+	 * with the target model object and message.
+	 * 
+	 * @param modelObject The model object
+	 * @param mesg The message
+	 */
+	public ModelIssue(ModelObject modelObject, String mesg) {
+		m_modelObject = modelObject;
+		m_message = mesg;
+	}
+	
+	/**
+	 * This is the constructor for initializing the issue
+	 * with the target model object and message.
+	 * 
+	 * @param modelObject The model object
+	 * @param mesg The message
+	 * @param props The properties
+	 */
+	public ModelIssue(ModelObject modelObject, String mesg,
+			java.util.Map<String,Object> props) {
+		m_modelObject = modelObject;
+		m_message = mesg;
+		m_properties = props;
+	}
+	
+	/**
+	 * This method returns the model object associated
+	 * with the issue.
+	 * 
+	 * @return The model object
+	 */
+	public ModelObject getModelObject() {
+		return(m_modelObject);
+	}
+	
+	/**
+	 * This method sets the model object.
+	 * 
+	 * @param mo The model object
+	 */
+	public void setModelObject(ModelObject mo) {
+		m_modelObject = mo;
+	}
+	
+	/**
+	 * This method returns the message describing the
+	 * issue.
+	 * 
+	 * @return The message
+	 */
+	public String getMessage() {
+		return(m_message);
+	}
+	
+	/**
+	 * This method sets the message.
+	 * 
+	 * @param mesg The message
+	 */
+	public void setMessage(String mesg) {
+		m_message = mesg;
+	}
+	
+	/**
+	 * This method returns the properties associated with
+	 * the issue.
+	 * 
+	 * @return The properties
+	 */
+	public java.util.Map<String,Object> getProperties() {
+		return(m_properties);
+	}
+	
+	/**
+	 * This method returns the resolutions associated
+	 * with the model issue.
+	 * 
+	 * @return The resolutions
+	 */
+	public java.util.List<Resolution> getResolutions() {
+		return(m_resolutions);
+	}
+	
+	public int hashCode() {
+		return(m_message.hashCode());
+	}
+	
+	public boolean equals(Object obj) {
+		boolean ret=false;
+		
+		if (obj instanceof ModelIssue) {
+			ModelIssue other=(ModelIssue)obj;
+			
+			if (getMessage() != null && other.getMessage() != null &&
+					getMessage().equals(other.getMessage()) &&
+					getModelObject() != null &&
+					getModelObject().getSource() != null &&
+					other.getModelObject() != null &&
+					other.getModelObject().getSource() != null) {
+				ret = getModelObject().getSource().equals(other.getModelObject().getSource());
+			}
+		}
+		
+		return(ret);
+	}
+	
+	private ModelObject m_modelObject=null;
+	private String m_message=null;
+	private java.util.Map<String,Object> m_properties=
+					new java.util.HashMap<String,Object>();
+	private java.util.List<Resolution> m_resolutions=
+					new java.util.Vector<Resolution>();
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/admin/ModelListener.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/admin/ModelListener.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/admin/ModelListener.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 20 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.model.admin;
+
+
+/**
+ * This interface represents a listener for model feedback.
+ * 
+ */
+public interface ModelListener {
+
+	/**
+	 * This method reports errors detected in model analysis.
+	 * 
+	 * @param issue The issue
+	 */
+	public void error(ModelIssue issue);
+	
+	/**
+	 * This method reports warnings detected in model analysis.
+	 * 
+	 * @param issue The issue
+	 */
+	public void warning(ModelIssue issue);
+
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/admin/ModelRepository.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/admin/ModelRepository.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/admin/ModelRepository.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 16 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.model.admin;
+
+import org.scribble.model.Model;
+import org.scribble.model.ModelReference;
+
+/**
+ * This is the interface for the model repository. This is a generic
+ * interface used to access Scribble models from within an
+ * environment. The repository has the responsibility for understanding
+ * how Scribble descriptions are organised, accessed and monitored
+ * for change.
+ */
+public interface ModelRepository {
+	
+	/**
+	 * This method returns the model associated with the supplied
+	 * Scribble reference. A single reference may return multiple
+	 * models, either because the resource content can be interpreted
+	 * differently depending on the model type of interest, or
+	 * because the model reference is abstract, and has more than
+	 * one concrete implementation model.
+	 * 
+	 * @param ref The model reference
+	 * @param l The model listener
+	 * @return The scribble model
+	 */
+	public Model getModel(ModelReference ref, ModelListener l);
+
+	/**
+	 * This method updates the model, associated with the
+	 * supplied reference, with the contents of the specified
+	 * model.
+	 * 
+	 * @param ref The model reference
+	 * @param model The model
+	 * @throws java.io.IOException Failed to update the model
+	 */
+	public void updateModel(ModelReference ref, Model model)
+								throws java.io.IOException;
+
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/admin/ModelResource.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/admin/ModelResource.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/admin/ModelResource.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 14 Feb 2008 : Initial version created by gary
+ */
+package org.scribble.model.admin;
+
+import org.scribble.model.ModelReference;
+
+/**
+ * This interface represents the resource associated with a model
+ * definition.
+ */
+public interface ModelResource {
+
+	/**
+	 * This method returns the URI of the model resource.
+	 * 
+	 * @return The URI
+	 */
+	public java.net.URI getURI();
+	
+	/**
+	 * This method returns the contents associated with
+	 * the model resource.
+	 * 
+	 * @return The contents
+	 * @exception IOException Failed to obtain content
+	 */
+	public java.io.InputStream getContents() throws java.io.IOException;
+	
+	/**
+	 * This method returns the reference associated with the resource.
+	 * 
+	 * @return The model reference associated with the resource
+	 */
+	public ModelReference getReference();
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/analysis/BlockLookaheadRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/analysis/BlockLookaheadRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/analysis/BlockLookaheadRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 30 Jul 2008 : Initial version created by gary
+ */
+package org.scribble.model.analysis;
+
+import org.scribble.extensions.*;
+import org.scribble.model.*;
+
+/**
+ * This class provides the lookahead rule for the Block.
+ * 
+ */
+ at RegistryInfo(extension=LookaheadRule.class)
+public class BlockLookaheadRule implements LookaheadRule {
+
+	/**
+	 * The default constructor.
+	 */
+	public BlockLookaheadRule() {
+	}
+	
+	/**
+	 * This method determines whether the rule supports
+	 * the supplied object.
+	 * 
+	 * @param mobj The model object
+	 * @return Whether the rule supports the model object
+	 */
+	public boolean isSupported(ModelObject mobj) {
+		return(mobj instanceof Block);
+	}
+	
+	/**
+	 * This method returns the set of interactions that
+	 * will occur next, related to the supplied model
+	 * object.
+	 * 
+	 * @param context The context
+	 * @param mobj The model object
+	 * @return The set of interactions that occur next
+	 */
+	public java.util.Set<Interaction> getInteractions(LookaheadContext context,
+							ModelObject mobj) {
+		Block act=(Block)mobj;
+		
+		java.util.Set<Interaction> ret=new java.util.HashSet<Interaction>();
+		boolean f_end=false;
+		
+		for (int i=0; f_end == false &&
+				i < act.getContents().size(); i++) {
+			
+			if (context.isStopAtConditionalInitiator() &&
+					act.isConditional() &&
+					act.getEnclosingDefinition() != null &&
+					act.getInitiatorRoles().contains(
+							act.getEnclosingDefinition().
+							getLocatedName().getRole())) {
+				f_end = true;
+			} else {
+				java.util.Set<Interaction> interactions=
+						context.getInteractions(act.getContents().get(i));
+				
+				if (interactions != null) {
+					ret.addAll(interactions);
+					
+					if (act.getContents().get(i).isConditional() == false) {
+						f_end = true;
+					}
+				}
+			}
+		}
+				
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/analysis/DefaultLookaheadAnalyser.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/analysis/DefaultLookaheadAnalyser.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/analysis/DefaultLookaheadAnalyser.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 30 Jul 2008 : Initial version created by gary
+ */
+package org.scribble.model.analysis;
+
+import java.util.Set;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+
+/**
+ * The default implementation of the Lookahead Analyser.
+ */
+ at RegistryInfo(extension=LookaheadAnalyser.class,isService=true)
+public class DefaultLookaheadAnalyser implements LookaheadAnalyser {
+
+	/**
+	 * This method returns the set of interactions that
+	 * will occur next, related to the supplied model
+	 * object.
+	 * 
+	 * @param mobj The model object
+	 * @return The set of interactions that occur next
+	 */
+	public Set<Interaction> getInteractions(ModelObject mobj) {
+		return(getInteractions(mobj, false));
+	}
+		
+	/**
+	 * This method returns the set of interactions that
+	 * will occur next, related to the supplied model
+	 * object.
+	 * 
+	 * @param mobj The model object
+	 * @param stopAtConditionalInitiator Whether to lookahead
+	 * 			past decision points
+	 * @return The set of interactions that occur next
+	 */
+	public Set<Interaction> getInteractions(ModelObject mobj,
+					boolean stopAtConditionalInitiator) {
+		
+		DefaultLookaheadContext context=new DefaultLookaheadContext();
+		
+		context.setStopAtConditionalInitiator(stopAtConditionalInitiator);
+		
+		return(context.getInteractions(mobj));
+	}
+
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/analysis/DefaultLookaheadContext.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/analysis/DefaultLookaheadContext.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/analysis/DefaultLookaheadContext.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 30 Jul 2008 : Initial version created by gary
+ */
+package org.scribble.model.analysis;
+
+import org.scribble.model.*;
+
+/**
+ * This class provides a default implementation for the model
+ * lookahead analysis context interface.
+ */
+public class DefaultLookaheadContext implements LookaheadContext {
+
+	/**
+	 * This is the constructor for the model lookahead context.
+	 * 
+	 */
+	public DefaultLookaheadContext() {
+		
+		// Obtain the relevant rules
+		java.util.List<Object> rules=
+			org.scribble.extensions.RegistryFactory.getRegistry().
+						getExtensions(LookaheadRule.class, null);
+		
+		// Transfer to typed list
+		for (int i=0; i < rules.size(); i++) {
+			if (rules.get(i) instanceof LookaheadRule) {
+				m_rules.add((LookaheadRule)rules.get(i));
+			}
+		}
+	}
+	
+	/**
+	 * This method returns a list of model lookahead analysis
+	 * rules appropriate for the notation being changed.
+	 * 
+	 * @return The list of model lookahead analysis rules
+	 */
+	public java.util.List<LookaheadRule> getRules() {
+		return(m_rules);
+	}
+	
+	/**
+	 * This method determines whether the lookahead analysis
+	 * should stop when it comes across a conditional activity
+	 * that is an initiator.
+	 * 
+	 * This is necessary to determine whether
+	 * at runtime the occurrence of a message would cause
+	 * progression, or whether a local decision needs to be
+	 * made first.
+	 * 
+	 * However, when monitoring a process, lookahead messages
+	 * may be used across conditional points, to understand
+	 * when particular decisions have been taken.
+	 * 
+	 * @return Whether lookahead analysis should stop at
+	 * 				a conditional initiator
+	 */
+	public boolean isStopAtConditionalInitiator() {
+		return(m_stopAtConditionalInitiator);
+	}
+	
+	/**
+	 * This method sets the 'stop at conditional initiator' flag.
+	 * 
+	 * @param stop Whether to stop
+	 */
+	public void setStopAtConditionalInitiator(boolean stop) {
+		m_stopAtConditionalInitiator = stop;
+	}
+	
+	/**
+	 * This method returns the set of interactions that
+	 * will occur next, related to the supplied model
+	 * object.
+	 * 
+	 * @param mobj The model object
+	 * @return The set of interactions that occur next
+	 */
+	public java.util.Set<Interaction> getInteractions(ModelObject mobj) {
+		java.util.Set<Interaction> ret=null;
+		
+		for (int i=0; ret == null && i < m_rules.size(); i++) {
+			if (m_rules.get(i).isSupported(mobj)) {
+				ret = m_rules.get(i).getInteractions(this, mobj);
+			}
+		}
+
+		return(ret);
+	}
+	
+	private java.util.List<LookaheadRule> m_rules=new java.util.Vector<LookaheadRule>();
+	private boolean m_stopAtConditionalInitiator=false;
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/analysis/InteractionLookaheadRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/analysis/InteractionLookaheadRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/analysis/InteractionLookaheadRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 30 Jul 2008 : Initial version created by gary
+ */
+package org.scribble.model.analysis;
+
+import org.scribble.extensions.*;
+import org.scribble.model.*;
+
+/**
+ * This class provides the lookahead rule for the Interaction.
+ * 
+ */
+ at RegistryInfo(extension=LookaheadRule.class)
+public class InteractionLookaheadRule implements LookaheadRule {
+
+	/**
+	 * The default constructor.
+	 */
+	public InteractionLookaheadRule() {
+	}
+	
+	/**
+	 * This method determines whether the rule supports
+	 * the supplied object.
+	 * 
+	 * @param mobj The model object
+	 * @return Whether the rule supports the model object
+	 */
+	public boolean isSupported(ModelObject mobj) {
+		return(mobj instanceof Interaction);
+	}
+	
+	/**
+	 * This method returns the set of interactions that
+	 * will occur next, related to the supplied model
+	 * object.
+	 * 
+	 * @param context The context
+	 * @param mobj The model object
+	 * @return The set of interactions that occur next
+	 */
+	public java.util.Set<Interaction> getInteractions(LookaheadContext context,
+							ModelObject mobj) {
+		java.util.Set<Interaction> ret=new java.util.HashSet<Interaction>();
+		
+		ret.add((Interaction)mobj);
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/analysis/LookaheadAnalyser.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/analysis/LookaheadAnalyser.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/analysis/LookaheadAnalyser.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 30 Jul 2008 : Initial version created by gary
+ */
+package org.scribble.model.analysis;
+
+import org.scribble.model.Interaction;
+import org.scribble.model.ModelObject;
+
+/**
+ * This interface represents a lookahead analyser.
+ */
+public interface LookaheadAnalyser {
+
+	/**
+	 * This method returns the set of interactions that
+	 * will occur next, related to the supplied model
+	 * object.
+	 * 
+	 * @param mobj The model object
+	 * @return The set of interactions that occur next
+	 */
+	public java.util.Set<Interaction> getInteractions(ModelObject mobj);
+	
+	/**
+	 * This method returns the set of interactions that
+	 * will occur next, related to the supplied model
+	 * object.
+	 * 
+	 * @param mobj The model object
+	 * @param stopAtConditionalInitiator Whether to lookahead
+	 * 			past decision points
+	 * @return The set of interactions that occur next
+	 */
+	public java.util.Set<Interaction> getInteractions(ModelObject mobj,
+					boolean stopAtConditionalInitiator);
+
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/analysis/LookaheadContext.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/analysis/LookaheadContext.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/analysis/LookaheadContext.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 30 Jul 2008 : Initial version created by gary
+ */
+package org.scribble.model.analysis;
+
+import org.scribble.model.*;
+
+/**
+ * This interface represents the capabilities made available
+ * to the model lookahead analysis rules.
+ */
+public interface LookaheadContext {
+
+	/**
+	 * This method determines whether the lookahead analysis
+	 * should stop when it comes across a conditional activity
+	 * that is an initiator.
+	 * 
+	 * This is necessary to determine whether
+	 * at runtime the occurrence of a message would cause
+	 * progression, or whether a local decision needs to be
+	 * made first.
+	 * 
+	 * However, when monitoring a process, lookahead messages
+	 * may be used across conditional points, to understand
+	 * when particular decisions have been taken.
+	 * 
+	 * @return Whether lookahead analysis should stop at
+	 * 				a conditional initiator
+	 */
+	public boolean isStopAtConditionalInitiator();
+	
+	/**
+	 * This method returns the set of interactions that
+	 * will occur next, related to the supplied model
+	 * object.
+	 * 
+	 * @param mobj The model object
+	 * @return The set of interactions that occur next
+	 */
+	public java.util.Set<Interaction> getInteractions(ModelObject mobj);
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/analysis/LookaheadRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/analysis/LookaheadRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/analysis/LookaheadRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 30 Jul 2008 : Initial version created by gary
+ */
+package org.scribble.model.analysis;
+
+import org.scribble.model.*;
+
+/**
+ * This interface represents the lookahead capability
+ * for identifying the next set of potential interactions.
+ */
+public interface LookaheadRule {
+
+	/**
+	 * This method determines whether the rule supports
+	 * the supplied object.
+	 * 
+	 * @param mobj The model object
+	 * @return Whether the rule supports the model object
+	 */
+	public boolean isSupported(ModelObject mobj);
+	
+	/**
+	 * This method returns the set of interactions that
+	 * will occur next, related to the supplied model
+	 * object.
+	 * 
+	 * @param context The context
+	 * @param mobj The model object
+	 * @return The set of interactions that occur next
+	 */
+	public java.util.Set<Interaction> getInteractions(LookaheadContext context,
+							ModelObject mobj);
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/analysis/ModelIncludeLookaheadRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/analysis/ModelIncludeLookaheadRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/analysis/ModelIncludeLookaheadRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 31 Jul 2008 : Initial version created by gary
+ */
+package org.scribble.model.analysis;
+
+import org.scribble.extensions.*;
+import org.scribble.model.*;
+
+/**
+ * This class provides the lookahead rule for the Model Include.
+ * 
+ */
+ at RegistryInfo(extension=LookaheadRule.class)
+public class ModelIncludeLookaheadRule implements LookaheadRule {
+
+	/**
+	 * The default constructor.
+	 */
+	public ModelIncludeLookaheadRule() {
+	}
+	
+	/**
+	 * This method determines whether the rule supports
+	 * the supplied object.
+	 * 
+	 * @param mobj The model object
+	 * @return Whether the rule supports the model object
+	 */
+	public boolean isSupported(ModelObject mobj) {
+		return(mobj instanceof ModelInclude);
+	}
+	
+	/**
+	 * This method returns the set of interactions that
+	 * will occur next, related to the supplied model
+	 * object.
+	 * 
+	 * @param context The context
+	 * @param mobj The model object
+	 * @return The set of interactions that occur next
+	 */
+	public java.util.Set<Interaction> getInteractions(LookaheadContext context,
+							ModelObject mobj) {
+		ModelInclude act=(ModelInclude)mobj;
+		java.util.Set<Interaction> ret=null;
+		
+		if (act.getDefinition() != null) {
+			ret = context.getInteractions(act.getDefinition().getBlock());
+		}
+				
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/analysis/MultiPathBehaviourLookaheadRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/analysis/MultiPathBehaviourLookaheadRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/analysis/MultiPathBehaviourLookaheadRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 30 Jul 2008 : Initial version created by gary
+ */
+package org.scribble.model.analysis;
+
+import org.scribble.extensions.*;
+import org.scribble.model.*;
+
+/**
+ * This class provides the lookahead rule for the Multi
+ * Path Behaviour.
+ * 
+ */
+ at RegistryInfo(extension=LookaheadRule.class)
+public class MultiPathBehaviourLookaheadRule implements LookaheadRule {
+
+	/**
+	 * The default constructor.
+	 */
+	public MultiPathBehaviourLookaheadRule() {
+	}
+	
+	/**
+	 * This method determines whether the rule supports
+	 * the supplied object.
+	 * 
+	 * @param mobj The model object
+	 * @return Whether the rule supports the model object
+	 */
+	public boolean isSupported(ModelObject mobj) {
+		return(mobj instanceof MultiPathBehaviour);
+	}
+	
+	/**
+	 * This method returns the set of interactions that
+	 * will occur next, related to the supplied model
+	 * object.
+	 * 
+	 * @param context The context
+	 * @param mobj The model object
+	 * @return The set of interactions that occur next
+	 */
+	public java.util.Set<Interaction> getInteractions(LookaheadContext context,
+							ModelObject mobj) {
+		MultiPathBehaviour act=(MultiPathBehaviour)mobj;
+		
+		java.util.Set<Interaction> ret=new java.util.HashSet<Interaction>();
+		
+		for (int i=0; i < act.getPaths().size(); i++) {
+			java.util.Set<Interaction> interactions=		
+				context.getInteractions(act.getPaths().get(i));
+			
+			if (interactions != null) {
+				ret.addAll(interactions);
+			}
+		}
+
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/analysis/SinglePathBehaviourLookaheadRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/analysis/SinglePathBehaviourLookaheadRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/analysis/SinglePathBehaviourLookaheadRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 30 Jul 2008 : Initial version created by gary
+ */
+package org.scribble.model.analysis;
+
+import org.scribble.extensions.*;
+import org.scribble.model.*;
+
+/**
+ * This class provides the lookahead rule for the Single
+ * Path Behaviour.
+ * 
+ */
+ at RegistryInfo(extension=LookaheadRule.class)
+public class SinglePathBehaviourLookaheadRule implements LookaheadRule {
+
+	/**
+	 * The default constructor.
+	 */
+	public SinglePathBehaviourLookaheadRule() {
+	}
+	
+	/**
+	 * This method determines whether the rule supports
+	 * the supplied object.
+	 * 
+	 * @param mobj The model object
+	 * @return Whether the rule supports the model object
+	 */
+	public boolean isSupported(ModelObject mobj) {
+		return(mobj instanceof SinglePathBehaviour);
+	}
+	
+	/**
+	 * This method returns the set of interactions that
+	 * will occur next, related to the supplied model
+	 * object.
+	 * 
+	 * @param context The context
+	 * @param mobj The model object
+	 * @return The set of interactions that occur next
+	 */
+	public java.util.Set<Interaction> getInteractions(LookaheadContext context,
+							ModelObject mobj) {
+		SinglePathBehaviour act=(SinglePathBehaviour)mobj;
+		
+		java.util.Set<Interaction> ret=
+				context.getInteractions(act.getBlock());
+				
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/change/AbstractModelChangeRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/change/AbstractModelChangeRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/change/AbstractModelChangeRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,136 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 28 Jul 2008 : Initial version created by gary
+ */
+package org.scribble.model.change;
+
+import org.scribble.model.*;
+
+public abstract class AbstractModelChangeRule implements ModelChangeRule {
+
+	/**
+	 * This method determines whether the rule is appropriate
+	 * for the supplied type of model, parent (in the context) and inserted
+	 * model object.
+	 *
+	 * @param context The context
+	 * @param model The model
+	 * @param mobj The model object being inserted
+	 * @param ref The optional reference model object
+	 * @return Whether the rule supports the supplied information
+	 */
+	public boolean isInsertSupported(ModelChangeContext context,
+					Model model, ModelObject mobj, ModelObject ref) {
+		return(false);
+	}
+	
+	/**
+	 * This method adds a new model object, within a
+	 * parent model object, with the details supplied in
+	 * another model object. The supplied model object
+	 * will usually be from a different model representation
+	 * (e.g. due to a merge), so the details will be
+	 * copied and placed in the representation associated
+	 * with the supplied model and parent model object.<p>
+	 * <p>
+	 * If a reference model object is supplied, then the
+	 * insertion will occur relative to it. If the reference
+	 * object is a block, then it means that the insertion
+	 * should occur at the end of the block. Otherwise the
+	 * new model object should be inserted before the
+	 * reference object, within the containing block.<p>
+	 * <p>
+	 * If the reference object is not supplied, then the
+	 * new model object should be inserted at the end of
+	 * the behaviour associated with the parent in the model
+	 * change context.
+	 * 
+	 * @param context The context
+	 * @param model The model being changed
+	 * @param mobj The model object details to be inserted
+	 * @param ref The optional reference model object
+	 * @return Whether the change has been applied
+	 */
+	public boolean insert(ModelChangeContext context,
+				Model model, ModelObject mobj, ModelObject ref) {
+		return(false);
+	}
+	
+	/**
+	 * This method determines whether the rule is appropriate
+	 * for the supplied type of model, parent (in the context)
+	 * and deleted model object.
+	 * 
+	 * @param context The context
+	 * @param model The model
+	 * @param mobj The model object to be removed
+	 * @return Whether the rule supports the supplied information
+	 */
+	public boolean isDeleteSupported(ModelChangeContext context,
+						Model model, ModelObject mobj) {
+		return(false);
+	}
+	
+	/**
+	 * This method removes the supplied model object from the
+	 * supplied model. The model object representation must
+	 * contain the necessary model specific to remove the 
+	 * object from the underlying model representation.
+	 * 
+	 * @param context The context
+	 * @param model The model being changed
+	 * @param mobj The model object to be deleted
+	 * @return Whether the change has been applied
+	 */
+	public boolean delete(ModelChangeContext context,
+				Model model, ModelObject mobj) {
+		return(false);
+	}
+	
+	/**
+	 * This method determines whether the rule is appropriate
+	 * for the supplied type of model, parent (in the context)
+	 * and modified model object.
+	 *
+	 * @param context The context
+	 * @param model The model
+	 * @param fromObj The source model object
+	 * @param toObj The model object to be updated
+	 * @return Whether the rule supports the supplied information
+	 */
+	public boolean isUpdateSupported(ModelChangeContext context,
+					Model model, ModelObject fromObj, ModelObject toObj) {
+		return(false);
+	}
+	
+	/**
+	 * This method modifies an existing model object, within a
+	 * parent model object, with the details supplied in
+	 * another model object.
+	 * 
+	 * @param context The context
+	 * @param model The model being changed
+	 * @param fromObj The source model object
+	 * @param toObj The model object to be updated
+	 * @return Whether the change has been applied
+	 */
+	public boolean update(ModelChangeContext context,
+				Model model, ModelObject fromObj, ModelObject toObj) {
+		return(false);
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/change/DefaultModelChangeContext.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/change/DefaultModelChangeContext.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/change/DefaultModelChangeContext.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,189 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 24 Jul 2008 : Initial version created by gary
+ */
+package org.scribble.model.change;
+
+import org.scribble.model.*;
+
+/**
+ * This class provides a default implementation for the model
+ * change context interface.
+ */
+public class DefaultModelChangeContext implements ModelChangeContext {
+
+	/**
+	 * This is the constructor for the model change context.
+	 * 
+	 * @param ref The reference for the model being changed
+	 * @param role The role associated with the model
+	 */
+	public DefaultModelChangeContext(ModelReference ref, Role role) {
+		
+		m_reference = ref;
+		m_role = role;
+		
+		if (ref != null) {
+			// Obtain the relevant rules
+			java.util.List<Object> rules=
+				org.scribble.extensions.RegistryFactory.getRegistry().
+							getExtensions(ModelChangeRule.class,
+									m_reference.getNotation());
+			
+			// Transfer to typed list
+			for (int i=0; i < rules.size(); i++) {
+				if (rules.get(i) instanceof ModelChangeRule) {
+					m_rules.add((ModelChangeRule)rules.get(i));
+				}
+			}
+		}
+	}
+	
+	/**
+	 * This method returns a list of model change rules appropriate
+	 * for the notation being changed.
+	 * 
+	 * @return The list of model change rules
+	 */
+	public java.util.List<ModelChangeRule> getRules() {
+		return(m_rules);
+	}
+	
+	/**
+	 * This method returns the role associated with the local
+	 * model.
+	 * 
+	 * @return The role
+	 */
+	public Role getRole() {
+		return(m_role);
+	}
+	
+	/**
+	 * This method returns the current parent component.
+	 * 
+	 * @return The parent
+	 */
+	public Object getParent() {
+		return(m_parent);
+	}
+	
+	/**
+	 * This method sets the new parent component.
+	 * 
+	 * @param parent The parent
+	 */
+	public void setParent(Object parent) {
+		m_parent = parent;
+	}
+	
+	/**
+	 * This method adds a new model object, within a
+	 * parent model object, with the details supplied in
+	 * another model object. The supplied model object
+	 * will usually be from a different model representation
+	 * (e.g. due to a merge), so the details will be
+	 * copied and placed in the representation associated
+	 * with the supplied model and parent model object.<p>
+	 * <p>
+	 * If a reference model object is supplied, then the
+	 * insertion will occur relative to it. If the reference
+	 * object is a block, then it means that the insertion
+	 * should occur at the end of the block. Otherwise the
+	 * new model object should be inserted before the
+	 * reference object, within the containing block. 
+	 * 
+	 * @param model The model being changed
+	 * @param mobj The model object details to be inserted
+	 * @param ref The optional reference model object
+	 * @return Whether the change has been applied
+	 */
+	public boolean insert(Model model, ModelObject mobj, ModelObject ref) {
+		boolean ret=false;
+		
+		for (int i=0; ret == false && i < m_rules.size(); i++) {
+			if (m_rules.get(i).isInsertSupported(this, model, mobj, ref)) {
+				ret = m_rules.get(i).insert(this, model,
+						mobj, ref);
+			}
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method removes an existing model object, within a
+	 * parent model object, with the details supplied in
+	 * another model object.
+	 * 
+	 * @param model The model being changed
+	 * @param mobj The model object details to be deleted
+	 * @param position The position, where relevant
+	 * @return Whether the change has been applied
+	 */
+	public boolean delete(Model model, ModelObject mobj) {
+		boolean ret=false;
+		
+		for (int i=0; ret == false && i < m_rules.size(); i++) {
+			if (m_rules.get(i).isDeleteSupported(this, model, mobj)) {
+				ret = m_rules.get(i).delete(this, model, mobj);
+			}
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method modifies an existing model object, within a
+	 * parent model object, with the details supplied in
+	 * another model object.
+	 * 
+	 * @param model The model being changed
+	 * @param fromObj The source model object
+	 * @param toObj The model object to be updated
+	 * @return Whether the change has been applied
+	 */
+	public boolean update(Model model, ModelObject fromObj, ModelObject toObj) {
+		boolean ret=false;
+		
+		for (int i=0; ret == false && i < m_rules.size(); i++) {
+			if (m_rules.get(i).isUpdateSupported(this, model, fromObj, toObj)) {
+				ret = m_rules.get(i).update(this, model,
+						fromObj, toObj);
+			}
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns a set of properties used during model change
+	 * processing.
+	 * 
+	 * @return The properties
+	 */
+	public java.util.Map<String,Object> getProperties() {
+		return(m_properties);
+	}
+	
+	private ModelReference m_reference=null;
+	private Role m_role=null;
+	private Object m_parent=null;
+	private java.util.List<ModelChangeRule> m_rules=new java.util.Vector<ModelChangeRule>();
+	private java.util.Map<String,Object> m_properties=new java.util.HashMap<String,Object>();
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/change/DefaultModelGenerator.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/change/DefaultModelGenerator.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/change/DefaultModelGenerator.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 24 Jul 2008 : Initial version created by gary
+ */
+package org.scribble.model.change;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+
+/**
+ * This class represents a default implementation of the model
+ * generator interface.
+ */
+ at RegistryInfo(extension=ModelGenerator.class,isService=true)
+public class DefaultModelGenerator implements ModelGenerator {
+
+	/**
+	 * This method generates the contents of the target
+	 * model using information in the source model. This
+	 * mechanism is used to create a new instance of the
+	 * model, but with a specific underlying representation.
+	 * 
+	 * @param targetRef The target model's reference
+	 * @param role The role associated with the model
+	 * @param target The model being generated
+	 * @param source The reference model
+	 */
+	public void generate(ModelReference targetRef, Role role,
+					Model target, Model source) {
+		
+		DefaultModelChangeContext context=
+			new DefaultModelChangeContext(targetRef, role);
+		context.setParent(target);
+		
+		context.insert(target, source, null);
+	}
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/change/ModelChangeContext.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/change/ModelChangeContext.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/change/ModelChangeContext.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,107 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 24 Jul 2008 : Initial version created by gary
+ */
+package org.scribble.model.change;
+
+import org.scribble.model.*;
+
+/**
+ * This interface represents the capabilities made available
+ * to the model change rules.
+ */
+public interface ModelChangeContext {
+
+	/**
+	 * This method returns the role associated with the local
+	 * model.
+	 * 
+	 * @return The role
+	 */
+	public Role getRole();
+	
+	/**
+	 * This method returns the current parent component.
+	 * 
+	 * @return The parent
+	 */
+	public Object getParent();
+	
+	/**
+	 * This method sets the new parent component.
+	 * 
+	 * @param parent The parent
+	 */
+	public void setParent(Object parent);
+	
+	/**
+	 * This method adds a new model object, within a
+	 * parent model object, with the details supplied in
+	 * another model object. The supplied model object
+	 * will usually be from a different model representation
+	 * (e.g. due to a merge), so the details will be
+	 * copied and placed in the representation associated
+	 * with the supplied model and parent model object.<p>
+	 * <p>
+	 * If a reference model object is supplied, then the
+	 * insertion will occur relative to it. If the reference
+	 * object is a block, then it means that the insertion
+	 * should occur at the end of the block. Otherwise the
+	 * new model object should be inserted before the
+	 * reference object, within the containing block. 
+	 * 
+	 * @param model The model being changed
+	 * @param mobj The model object details to be inserted
+	 * @param ref The optional reference model object
+	 * @return Whether the change has been applied
+	 */
+	public boolean insert(Model model, ModelObject mobj, ModelObject ref);
+	
+	/**
+	 * This method removes the supplied model object from the
+	 * supplied model. The model object representation must
+	 * contain the necessary model specific to remove the 
+	 * object from the underlying model representation.
+	 * 
+	 * @param model The model being changed
+	 * @param mobj The model object to be deleted
+	 * @return Whether the change has been applied
+	 */
+	public boolean delete(Model model, ModelObject mobj);
+	
+	/**
+	 * This method modifies an existing model object, within a
+	 * parent model object, with the details supplied in
+	 * another model object.
+	 * 
+	 * @param model The model being changed
+	 * @param fromObj The source model object
+	 * @param toObj The model object to be updated
+	 * @return Whether the change has been applied
+	 */
+	public boolean update(Model model, ModelObject fromObj, ModelObject toObj);
+	
+	/**
+	 * This method returns a set of properties used during model change
+	 * processing.
+	 * 
+	 * @return The properties
+	 */
+	public java.util.Map<String,Object> getProperties();
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/change/ModelChangeRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/change/ModelChangeRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/change/ModelChangeRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 23 Jul 2008 : Initial version created by gary
+ */
+package org.scribble.model.change;
+
+import org.scribble.model.*;
+
+/**
+ * This interface represents a rule that can be used
+ * to insert a new model object into the current model.
+ */
+public interface ModelChangeRule {
+
+	/**
+	 * This method determines whether the rule is appropriate
+	 * for the supplied type of model, parent (in the context)
+	 * and inserted model object.
+	 * 
+	 * @param context The model change context
+	 * @param model The model
+	 * @param mobj The model object being inserted
+	 * @param ref The optional reference model object
+	 * @return Whether the rule supports the supplied information
+	 */
+	public boolean isInsertSupported(ModelChangeContext context,
+					Model model, ModelObject mobj,
+					ModelObject ref);
+	
+	/**
+	 * This method adds a new model object, within a
+	 * parent model object, with the details supplied in
+	 * another model object. The supplied model object
+	 * will usually be from a different model representation
+	 * (e.g. due to a merge), so the details will be
+	 * copied and placed in the representation associated
+	 * with the supplied model and parent model object.<p>
+	 * <p>
+	 * If a reference model object is supplied, then the
+	 * insertion will occur relative to it. If the reference
+	 * object is a block, then it means that the insertion
+	 * should occur at the end of the block. Otherwise the
+	 * new model object should be inserted before the
+	 * reference object, within the containing block.<p>
+	 * <p>
+	 * If the reference object is not supplied, then the
+	 * new model object should be inserted at the end of
+	 * the behaviour associated with the parent in the model
+	 * change context.
+	 * 
+	 * @param context The context
+	 * @param model The model being changed
+	 * @param mobj The model object details to be inserted
+	 * @param ref The optional reference model object
+	 * @return Whether the change has been applied
+	 */
+	public boolean insert(ModelChangeContext context,
+				Model model, ModelObject mobj, ModelObject ref);
+	
+	/**
+	 * This method determines whether the rule is appropriate
+	 * for the supplied type of model, parent (in the context)
+	 * and deleted model object.
+	 *
+	 * @param context The context
+	 * @param model The model
+	 * @param mobj The model object to be removed
+	 * @return Whether the rule supports the supplied information
+	 */
+	public boolean isDeleteSupported(ModelChangeContext context,
+					Model model, ModelObject mobj);
+	
+	/**
+	 * This method removes the supplied model object from the
+	 * supplied model. The model object representation must
+	 * contain the necessary model specific to remove the 
+	 * object from the underlying model representation.
+	 * 
+	 * @param context The context
+	 * @param model The model being changed
+	 * @param mobj The model object to be deleted
+	 * @return Whether the change has been applied
+	 */
+	public boolean delete(ModelChangeContext context,
+				Model model, ModelObject mobj);
+	
+	/**
+	 * This method determines whether the rule is appropriate
+	 * for the supplied type of model, parent (in the context)
+	 * and modified model object.
+	 *
+	 * @param context The context
+	 * @param model The model
+	 * @param fromObj The source model object
+	 * @param toObj The model object to be updated
+	 * @return Whether the rule supports the supplied information
+	 */
+	public boolean isUpdateSupported(ModelChangeContext context,
+					Model model, ModelObject fromObj, ModelObject toObj);
+	
+	/**
+	 * This method modifies an existing model object, within a
+	 * parent model object, with the details supplied in
+	 * another model object.
+	 * 
+	 * @param context The context
+	 * @param model The model being changed
+	 * @param fromObj The source model object
+	 * @param toObj The model object to be updated
+	 * @return Whether the change has been applied
+	 */
+	public boolean update(ModelChangeContext context,
+				Model model, ModelObject fromObj, ModelObject toObj);
+
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/change/ModelGenerator.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/change/ModelGenerator.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/change/ModelGenerator.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 24 Jul 2008 : Initial version created by gary
+ */
+package org.scribble.model.change;
+
+import org.scribble.model.*;
+
+/**
+ * This interface represents a model generator.
+ */
+public interface ModelGenerator {
+
+	/**
+	 * This method generates the contents of the target
+	 * model using information in the source model. This
+	 * mechanism is used to create a new instance of the
+	 * model, but with a specific underlying representation.
+	 * 
+	 * @param targetRef The target model's reference
+	 * @param role The role associated with the model
+	 * @param target The model being generated
+	 * @param source The reference model
+	 */
+	public void generate(ModelReference targetRef, Role role,
+					Model target, Model source);
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/filter/DefaultModelFilter.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/filter/DefaultModelFilter.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/filter/DefaultModelFilter.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,119 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 21 Jan 2009 : Initial version created by gary
+ */
+package org.scribble.model.filter;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+
+/**
+ * This class provides the default implementation of the
+ * model filter capability.
+ */
+ at RegistryInfo(extension=ModelFilter.class)
+public class DefaultModelFilter implements ModelFilter {
+
+	/**
+	 * This method filters the supplied model based on the list
+	 * of roles.
+	 * 
+	 * @param model The model
+	 * @param roles The list of roles
+	 */
+	public void filter(Model model, java.util.List<Role> roles) {
+		
+		for (int i=0; i < model.getDefinitions().size(); i++) {
+			filterBlock(model.getDefinitions().get(i).getBlock(), roles);
+		}
+	}
+
+	/**
+	 * This method filters the block of activities to only include
+	 * activities relevant to the supplied roles.
+	 * 
+	 * @param block The block of activities to be filtered
+	 * @param roles The list of roles
+	 */
+	protected void filterBlock(Block block, java.util.List<Role> roles) {
+		
+		for (int i=0; i < block.getContents().size(); i++) {
+			Activity act=block.getContents().get(i);
+			boolean f_remove=false;
+			
+			if (act instanceof RoleList) {
+				RoleList rl=(RoleList)act;
+				
+				rl.getRoles().retainAll(roles);
+				
+			} else if (act instanceof ModelInclude) {
+				//ModelInclude mi=(ModelInclude)act;
+				
+				// TODO: Need to check what roles are mapped
+				// in all uses of a particular sub-definition
+				// and then make sure all used roles are
+				// retained for the sub-definition
+				
+			} else if (act instanceof MultiPathBehaviour) {
+				MultiPathBehaviour mpb=(MultiPathBehaviour)act;
+				java.util.List<Block> paths=mpb.getPaths();
+				
+				for (int j=0; j < paths.size(); j++) {
+					Block path=paths.get(j);
+					
+					filterBlock(path, roles);
+					
+					// Is path empty?
+					if (path.getContents().size() == 0) {
+						mpb.removePath(path);
+					}
+				}
+				
+				// TODO: Should we check if empty multi-path
+				// behaviour should be removed?
+								
+			} else if (act instanceof SinglePathBehaviour) {
+				SinglePathBehaviour spb=(SinglePathBehaviour)act;
+				
+				filterBlock(spb.getBlock(), roles);
+				
+				// TODO: Should we check if empty single-path
+				// behaviour should be removed?
+
+			} else if (act instanceof Behaviour) {
+				
+				java.util.List<Role> associated=
+						((Behaviour)act).getAssociatedRoles();
+				
+				// Make sure all roles associated with the
+				// behaviour are contained in the supplied list
+				for (int j=0; f_remove == false &&
+						j < associated.size(); j++) {
+					if (roles.contains(associated.get(j)) == false) {
+						f_remove = true;
+					}
+				}
+			}
+			
+			if (f_remove) {
+				block.getContents().remove(i);
+				i--;
+			}
+		}
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/filter/ModelFilter.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/filter/ModelFilter.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/filter/ModelFilter.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 21 Jan 2009 : Initial version created by gary
+ */
+package org.scribble.model.filter;
+
+import org.scribble.model.*;
+
+/**
+ * This component provides a filtering capability for
+ * processing models.
+ */
+public interface ModelFilter {
+
+	/**
+	 * This method filters the supplied model based on the list
+	 * of roles.
+	 * 
+	 * @param model The model
+	 * @param roles The list of roles
+	 */
+	public void filter(Model model, java.util.List<Role> roles);
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/resolutions/DeleteFromModel.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/resolutions/DeleteFromModel.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/resolutions/DeleteFromModel.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,131 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 30 Sep 2008 : Initial version created by gary
+ */
+package org.scribble.model.resolutions;
+
+//import java.util.logging.Logger;
+
+import java.io.IOException;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.DefaultModelListener;
+import org.scribble.model.admin.DefaultResolution;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.change.*;
+
+/**
+ * This class represents a resolution for deleting a model object
+ * from a target model.
+ *
+ */
+public class DeleteFromModel extends DefaultResolution {
+
+	/**
+	 * The default constructor for the 'show reference
+	 * description'.
+	 */
+	public DeleteFromModel() {
+		setName(java.util.PropertyResourceBundle.getBundle(
+				"org.scribble.model.resolutions.Messages").
+					getString("_DELETE_FROM_MODEL_NAME"));
+		setDescription(java.util.PropertyResourceBundle.getBundle(
+				"org.scribble.model.resolutions.Messages").
+					getString("_DELETE_FROM_MODEL_DESC"));
+	}
+		
+	/**
+	 * This method is invoked to perform the resolution
+	 * on the identified model, associated with the model
+	 * object located using the supplied source reference
+	 * information. Further details regarding the issue
+	 * to be resolved is provided by the model issue -
+	 * although the 'model object' part of the model
+	 * issue may not be defined. This will have to be
+	 * recovered using the supplied model and source
+	 * reference.
+	 * 
+	 * @param ref The model reference
+	 * @param obj The source reference of the model object
+	 * @param issue The issue
+	 * @exception ResolutionException Failed to resolve
+	 */
+	@Override
+	public void resolve(ModelReference ref, SourceRef obj,
+					ModelIssue issue) throws ResolutionException {
+			
+		org.scribble.model.admin.ModelRepository mrep=
+				(org.scribble.model.admin.ModelRepository)
+			org.scribble.extensions.RegistryFactory.getRegistry().getExtension(
+					org.scribble.model.admin.ModelRepository.class, null);
+
+		DefaultModelChangeContext context=
+					new DefaultModelChangeContext(ref,
+							ref.getLocatedRole()==null?null :
+								new Role(ref.getLocatedRole()));
+
+		// Retrieve source and reference models and identify
+		// the relevant model objects
+		Model model=mrep.getModel(ref, new DefaultModelListener());
+		ModelObject refObj=null;
+		
+		// NOTE: Should only really be one model that matches
+		// the reference - i.e. the source model reference, and
+		// therefore this single model should provide access
+		// to the required model object. If a model reference
+		// is abstract/derived, then it may provide multiple models
+		// that might incorrectly return a model object for the URI.
+		
+		if (model != null) {
+			refObj = model.findModelObject(obj.getModelObjectURI());
+		}
+		
+		boolean f_deleted=false;
+		
+		if (model != null && refObj != null) {
+			
+			if (f_deleted = context.delete(model, refObj)) {
+			
+				// Update the model
+				try {
+					mrep.updateModel(ref, model);
+				} catch (IOException e) {
+					throw new ResolutionException(java.util.PropertyResourceBundle.getBundle(
+								"org.scribble.model.resolutions.Messages").
+								getString("_COULD_NOT_SAVE"));
+				}
+			}
+		}
+		
+		if (f_deleted == false) {
+			throw new ResolutionException(java.util.PropertyResourceBundle.getBundle(
+					"org.scribble.model.resolutions.Messages").
+					getString("_COULD_NOT_DELETE"));
+		}
+	}
+	
+	public int hashCode() {
+		return(0);
+	}
+	
+	public boolean equals(Object obj) {
+		return(obj instanceof DeleteFromModel);
+	}
+	
+	//private static Logger logger = Logger.getLogger("org.scribble.model.resolutions");
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/resolutions/InsertFromReferencedDescription.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/resolutions/InsertFromReferencedDescription.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/resolutions/InsertFromReferencedDescription.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,222 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 26 Sep 2008 : Initial version created by gary
+ */
+package org.scribble.model.resolutions;
+
+//import java.util.logging.Logger;
+
+import java.io.IOException;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.DefaultModelListener;
+import org.scribble.model.admin.DefaultResolution;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.change.*;
+
+/**
+ * This class represents a resolution for inserting a model object
+ * from a referenced description into the target model.
+ *
+ */
+public class InsertFromReferencedDescription extends DefaultResolution {
+
+	private static final String SOURCE_REF_END_POSITION = "sourceRefEndPosition";
+	private static final String SOURCE_REF_START_POSITION = "sourceRefStartPosition";
+	private static final String SOURCE_REF_MODEL_OBJECT_URI = "sourceRefModelObjectURI";
+	private static final String SOURCE_REF_COMPONENT_URI = "sourceRefComponentURI";
+	private static final String IFRD_SRC_REF_PREFIX = "_ifrdSrcRef_";
+	private static final String IFRD_MODEL_PREFIX = "_ifrdModel_";
+	private static final String MODEL_NOTATION = "modelNotation";
+	private static final String MODEL_LOCATED_ROLE = "modelLocatedRole";
+	private static final String MODEL_LOCALPART = "modelLocalpart";
+	private static final String MODEL_NAMESPACE = "modelNamespace";
+
+	/**
+	 * The default constructor for the 'show reference
+	 * description'.
+	 */
+	public InsertFromReferencedDescription() {
+		setName(java.util.PropertyResourceBundle.getBundle(
+				"org.scribble.model.resolutions.Messages").
+					getString("_INSERT_FROM_REFERENCED_DESCRIPTION_NAME"));
+		setDescription(java.util.PropertyResourceBundle.getBundle(
+				"org.scribble.model.resolutions.Messages").
+					getString("_INSERT_FROM_REFERENCED_DESCRIPTION_DESC"));
+	}
+		
+	/**
+	 * This method sets the model's reference.
+	 * 
+	 * @param ref The model's reference
+	 */
+	public void setModel(ModelReference ref) {
+		getProperties().put(MODEL_NAMESPACE, ref.getNamespace());
+		getProperties().put(MODEL_LOCALPART, ref.getLocalpart());
+		getProperties().put(MODEL_LOCATED_ROLE, ref.getLocatedRole());
+		getProperties().put(MODEL_NOTATION, ref.getNotation());
+		
+		java.util.Iterator<String> iter=ref.getPropertyNames().iterator();
+		
+		while (iter.hasNext()) {
+			String name=iter.next();
+			getProperties().put(IFRD_MODEL_PREFIX+name, ref.getProperty(name));
+		}
+	}
+	
+	/**
+	 * This method sets the source reference associated with the
+	 * referenced model object.
+	 * 
+	 * @param sref The source reference
+	 */
+	public void setSourceReference(SourceRef sref) {
+		getProperties().put(SOURCE_REF_COMPONENT_URI, sref.getComponentURI());
+		getProperties().put(SOURCE_REF_MODEL_OBJECT_URI, sref.getModelObjectURI());
+		getProperties().put(SOURCE_REF_START_POSITION, sref.getStartPosition());
+		getProperties().put(SOURCE_REF_END_POSITION, sref.getEndPosition());
+
+		java.util.Iterator<String> iter=sref.getProperties().keySet().iterator();
+		
+		while (iter.hasNext()) {
+			String name=iter.next();
+			getProperties().put(IFRD_SRC_REF_PREFIX+name, sref.getProperties().get(name));
+		}
+	}
+
+	/**
+	 * This method is invoked to perform the resolution
+	 * on the identified model, associated with the model
+	 * object located using the supplied source reference
+	 * information. Further details regarding the issue
+	 * to be resolved is provided by the model issue -
+	 * although the 'model object' part of the model
+	 * issue may not be defined. This will have to be
+	 * recovered using the supplied model and source
+	 * reference.
+	 * 
+	 * @param ref The model reference
+	 * @param obj The source reference of the model object
+	 * @param issue The issue
+	 * @exception ResolutionException Failed to resolve
+	 */
+	@Override
+	public void resolve(ModelReference ref, SourceRef obj,
+					ModelIssue issue) throws ResolutionException {
+			
+		// Recover the model reference
+		ModelReference modelRef=new ModelReference(
+				(String)getProperties().get(MODEL_NAMESPACE),
+				(String)getProperties().get(MODEL_LOCALPART),
+				(String)getProperties().get(MODEL_LOCATED_ROLE),
+				(String)getProperties().get(MODEL_NOTATION));
+		
+		// Recover the source reference
+		SourceRef sref=new SourceRef();
+		sref.setComponentURI((String)getProperties().get(SOURCE_REF_COMPONENT_URI));
+		sref.setModelObjectURI((String)getProperties().get(SOURCE_REF_MODEL_OBJECT_URI));
+		sref.setStartPosition((Integer)getProperties().get(SOURCE_REF_START_POSITION));
+		sref.setEndPosition((Integer)getProperties().get(SOURCE_REF_END_POSITION));
+		
+		// Recover the properties for model and source ref
+		java.util.Iterator<String> iter=getProperties().keySet().iterator();
+		while (iter.hasNext()) {
+			String name=iter.next();
+			
+			if (name.startsWith(IFRD_MODEL_PREFIX)) {
+				Object value=getProperties().get(name);
+				
+				name = name.substring(IFRD_MODEL_PREFIX.length());
+				
+				modelRef.setProperty(name, value);
+			} else if (name.startsWith(IFRD_SRC_REF_PREFIX)) {
+				Object value=getProperties().get(name);
+				
+				name = name.substring(IFRD_SRC_REF_PREFIX.length());
+				
+				sref.getProperties().put(name, value);
+			}
+		}		
+		
+		org.scribble.model.admin.ModelRepository mrep=
+				(org.scribble.model.admin.ModelRepository)
+			org.scribble.extensions.RegistryFactory.getRegistry().getExtension(
+					org.scribble.model.admin.ModelRepository.class, null);
+
+		DefaultModelChangeContext context=
+					new DefaultModelChangeContext(ref,
+							ref.getLocatedRole()==null?null :
+								new Role(ref.getLocatedRole()));
+
+		// Retrieve source and reference models and identify
+		// the relevant model objects
+		Model model=mrep.getModel(ref, new DefaultModelListener());
+		ModelObject refObj=null;
+		
+		// NOTE: Should only really be one model that matches
+		// the reference - i.e. the source model reference, and
+		// therefore this single model should provide access
+		// to the required model object. If a model reference
+		// is abstract/derived, then it may provide multiple models
+		// that might incorrectly return a model object for the URI.
+		
+		if (model != null) {
+			refObj = model.findModelObject(obj.getModelObjectURI());
+		}
+		
+		Model refModel = mrep.getModel(modelRef, new DefaultModelListener());
+		ModelObject fromObj=null;
+		
+		if (refModel != null) {
+			fromObj = refModel.findModelObject(sref.getModelObjectURI());
+		}
+		
+		boolean f_inserted=false;
+		
+		if (model != null && fromObj != null && refObj != null) {
+			
+			if (f_inserted = context.insert(model, fromObj, refObj)) {
+			
+				try {
+					// Update the model
+					mrep.updateModel(ref, model);
+				} catch (IOException e) {
+					throw new ResolutionException(java.util.PropertyResourceBundle.getBundle(
+								"org.scribble.model.resolutions.Messages").
+								getString("_COULD_NOT_SAVE"));
+				}
+			}
+		}
+		
+		if (f_inserted == false) {
+			throw new ResolutionException(java.util.PropertyResourceBundle.getBundle(
+					"org.scribble.model.resolutions.Messages").
+					getString("_COULD_NOT_INSERT"));
+		}
+	}
+	
+	public int hashCode() {
+		return(0);
+	}
+	
+	public boolean equals(Object obj) {
+		return(obj instanceof InsertFromReferencedDescription);
+	}
+	
+	//private static Logger logger = Logger.getLogger("org.scribble.model.resolutions");
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/resolutions/Messages.properties
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/resolutions/Messages.properties	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/resolutions/Messages.properties	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,34 @@
+# /*
+# * Copyright 2007-8 Pi4 Technologies Ltd
+# *
+# * 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.
+# *
+# *
+# * Change History:
+# * 11 Sept 2008 : Initial version created by gary
+# */
+
+_COULD_NOT_DELETE=Could not delete activities from the model
+_COULD_NOT_INSERT=Could not insert activities found in referenced description
+_COULD_NOT_SAVE=Could not save the model
+_COULD_NOT_UPDATE=Could not update activity with information from referenced description
+_DELETE_FROM_MODEL_NAME=Delete unnecessary activities from model
+_DELETE_FROM_MODEL_DESC=Unnecessary activities, not present in the referenced description, will be deleted from model
+_INSERT_FROM_REFERENCED_DESCRIPTION_NAME=Insert missing behaviour from referenced description
+_INSERT_FROM_REFERENCED_DESCRIPTION_DESC=Insert the missing behaviour from the referenced description
+_SHOW_COMPOSED_ISSUE_NAME=Show composed issue
+_SHOW_COMPOSED_ISSUE_DESC=Display the erronous activity in the composed description
+_SHOW_REFERENCED_DESCRIPTION_NAME=Show referenced description
+_SHOW_REFERENCED_DESCRIPTION_DESC=Display the area in the referenced description being used for conformance analysis
+_UPDATE_FROM_REFERENCED_DESCRIPTION_NAME=Update from referenced description
+_UPDATE_FROM_REFERENCED_DESCRIPTION_DESC=Update the affected behaviour from the referenced description

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/resolutions/Resolution.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/resolutions/Resolution.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/resolutions/Resolution.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 7 Sep 2008 : Initial version created by gary
+ */
+package org.scribble.model.resolutions;
+
+import org.scribble.model.ModelReference;
+import org.scribble.model.SourceRef;
+import org.scribble.model.admin.ModelIssue;
+
+/**
+ * This interface represents a resolution to a reported
+ * model issue.
+ */
+public interface Resolution {
+
+	/**
+	 * This method returns the name of the resolution.
+	 * 
+	 * @return The name
+	 */
+	public String getName();
+	
+	/**
+	 * This method returns the description of the resolution.
+	 * 
+	 * @return The description
+	 */
+	public String getDescription();
+	
+	/**
+	 * This method returns the class associated with the
+	 * resolution. This class must have a default constructor.
+	 * 
+	 * @return The resolution class
+	 */
+	public String getResolutionClass();
+	
+	/**
+	 * This method returns the properties used to configure
+	 * the resolution.
+	 * 
+	 * @return The properties
+	 */
+	public java.util.Map<String, Object> getProperties();
+	
+	/**
+	 * This method is invoked to perform the resolution
+	 * on the identified model, associated with the model
+	 * object located using the supplied source reference
+	 * information. Further details regarding the issue
+	 * to be resolved is provided by the model issue -
+	 * although the 'model object' part of the model
+	 * issue may not be defined. This will have to be
+	 * recovered using the supplied model and source
+	 * reference.
+	 * 
+	 * @param ref The model reference
+	 * @param obj The source reference of the model object
+	 * @param issue The issue
+	 * @exception ResolutionException Failed to resolve
+	 */
+	public void resolve(ModelReference ref, SourceRef obj,
+					ModelIssue issue) throws ResolutionException;
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/resolutions/ResolutionException.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/resolutions/ResolutionException.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/resolutions/ResolutionException.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 29 Sep 2008 : Initial version created by gary
+ */
+package org.scribble.model.resolutions;
+
+/**
+ * This class represents an exception that occurs while
+ * executing a resolution.
+ */
+public class ResolutionException extends Exception {
+
+	private static final long serialVersionUID = -1579952405094467030L;
+
+	/**
+	 * This constructor initializes the exception with a
+	 * message.
+	 * 
+	 * @param mesg The message
+	 */
+	public ResolutionException(String mesg) {
+		super(mesg);
+	}
+	
+	/**
+	 * This constructor initializes the exception with a
+	 * message and associated exception.
+	 * 
+	 * @param mesg The message
+	 * @param t The associated exception
+	 */
+	public ResolutionException(String mesg, Throwable t) {
+		super(mesg, t);
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/resolutions/ShowComposedIssue.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/resolutions/ShowComposedIssue.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/resolutions/ShowComposedIssue.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,181 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 7 Sep 2008 : Initial version created by gary
+ */
+package org.scribble.model.resolutions;
+
+import java.util.logging.Logger;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.DefaultResolution;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.util.ResourceUtil;
+
+/**
+ * This class represents a resolution for navigating to an external
+ * issue.
+ *
+ */
+public class ShowComposedIssue extends DefaultResolution {
+
+	private static final String COMPOSED_SOURCE_REF_END_POSITION = "composedSourceRefEndPosition";
+	private static final String COMPOSED_SOURCE_REF_START_POSITION = "composedSourceRefStartPosition";
+	private static final String COMPOSED_SOURCE_REF_MODEL_OBJECT_URI = "composedSourceRefModelObjectURI";
+	private static final String COMPOSED_SOURCE_REF_COMPONENT_URI = "composedSourceRefComponentURI";
+	private static final String SEI_SRC_REF_PREFIX = "_seiSrcRef_";
+	private static final String SEI_MODEL_PREFIX = "_seiModel_";
+	private static final String COMPOSED_NOTATION = "composedNotation";
+	private static final String COMPOSED_LOCATED_ROLE = "composedLocatedRole";
+	private static final String COMPOSED_LOCALPART = "composedLocalpart";
+	private static final String COMPOSED_NAMESPACE = "composedNamespace";
+
+	/**
+	 * This is the default constructor for the 'show
+	 * external issue' resolution.
+	 */
+	public ShowComposedIssue() {
+		setName(java.util.PropertyResourceBundle.getBundle(
+				"org.scribble.model.resolutions.Messages").
+			getString("_SHOW_COMPOSED_ISSUE_NAME"));
+		setDescription(java.util.PropertyResourceBundle.getBundle(
+				"org.scribble.model.resolutions.Messages").
+			getString("_SHOW_COMPOSED_ISSUE_DESC"));
+	}
+	
+	/**
+	 * This method sets the composed model's reference.
+	 * 
+	 * @param ref The composed model's reference
+	 */
+	public void setComposedModel(ModelReference ref) {
+		getProperties().put(COMPOSED_NAMESPACE, ref.getNamespace());
+		getProperties().put(COMPOSED_LOCALPART, ref.getLocalpart());
+		getProperties().put(COMPOSED_LOCATED_ROLE, ref.getLocatedRole());
+		getProperties().put(COMPOSED_NOTATION, ref.getNotation());
+		
+		java.util.Iterator<String> iter=ref.getPropertyNames().iterator();
+		
+		while (iter.hasNext()) {
+			String name=iter.next();
+			getProperties().put(SEI_MODEL_PREFIX+name, ref.getProperty(name));
+		}
+	}
+
+	/**
+	 * This method sets the source reference associated with the
+	 * referenced model object.
+	 * 
+	 * @param sref The source reference
+	 */
+	public void setSourceReference(SourceRef sref) {
+		getProperties().put(COMPOSED_SOURCE_REF_COMPONENT_URI, sref.getComponentURI());
+		getProperties().put(COMPOSED_SOURCE_REF_MODEL_OBJECT_URI, sref.getModelObjectURI());
+		getProperties().put(COMPOSED_SOURCE_REF_START_POSITION, sref.getStartPosition());
+		getProperties().put(COMPOSED_SOURCE_REF_END_POSITION, sref.getEndPosition());
+
+		java.util.Iterator<String> iter=sref.getProperties().keySet().iterator();
+		
+		while (iter.hasNext()) {
+			String name=iter.next();
+			getProperties().put(SEI_SRC_REF_PREFIX+name, sref.getProperties().get(name));
+		}
+	}
+
+	/**
+	 * This method is invoked to perform the resolution
+	 * on the identified model, associated with the model
+	 * object located using the supplied source reference
+	 * information. Further details regarding the issue
+	 * to be resolved is provided by the model issue -
+	 * although the 'model object' part of the model
+	 * issue may not be defined. This will have to be
+	 * recovered using the supplied model and source
+	 * reference.
+	 * 
+	 * @param ref The model reference
+	 * @param obj The source reference of the model object
+	 * @param issue The issue
+	 * @exception ResolutionException Failed to resolve
+	 */
+	@Override
+	public void resolve(ModelReference ref, SourceRef obj,
+					ModelIssue issue) throws ResolutionException {
+		
+		ModelReference extRef=new ModelReference(
+				(String)getProperties().get(COMPOSED_NAMESPACE),
+				(String)getProperties().get(COMPOSED_LOCALPART),
+				(String)getProperties().get(COMPOSED_LOCATED_ROLE),
+				(String)getProperties().get(COMPOSED_NOTATION));
+		
+		// Recover the source reference
+		SourceRef sref=new SourceRef();
+		sref.setComponentURI((String)getProperties().get(COMPOSED_SOURCE_REF_COMPONENT_URI));
+		sref.setModelObjectURI((String)getProperties().get(COMPOSED_SOURCE_REF_MODEL_OBJECT_URI));
+		sref.setStartPosition((Integer)getProperties().get(COMPOSED_SOURCE_REF_START_POSITION));
+		sref.setEndPosition((Integer)getProperties().get(COMPOSED_SOURCE_REF_END_POSITION));
+		
+		// Recover the properties for model and source ref
+		java.util.Iterator<String> iter=getProperties().keySet().iterator();
+		while (iter.hasNext()) {
+			String name=iter.next();
+			
+			if (name.startsWith(SEI_MODEL_PREFIX)) {
+				Object value=getProperties().get(name);
+				
+				name = name.substring(SEI_MODEL_PREFIX.length());
+				
+				extRef.setProperty(name, value);
+			} else if (name.startsWith(SEI_SRC_REF_PREFIX)) {
+				Object value=getProperties().get(name);
+				
+				name = name.substring(SEI_SRC_REF_PREFIX.length());
+				
+				sref.getProperties().put(name, value);
+			}
+		}		
+		
+		// Find notation for the URI
+		org.scribble.model.Notation notation=
+				ResourceUtil.getNotation(extRef.getNotation());
+				
+		if (notation != null) {
+			org.scribble.editor.EditorManager em=(org.scribble.editor.EditorManager)
+					org.scribble.extensions.RegistryFactory.getRegistry().getExtension(
+							org.scribble.editor.EditorManager.class, notation.getCode());
+			
+			if (em != null) {
+				try {
+					em.focus(extRef, sref, issue.getProperties());
+				} catch(Exception e) {
+					logger.log(java.util.logging.Level.SEVERE,
+							"Failed to focus on model reference: "+extRef, e);
+				}
+			}
+		}
+	}
+	
+	public int hashCode() {
+		return(0);
+	}
+	
+	public boolean equals(Object obj) {
+		return(obj instanceof ShowComposedIssue);
+	}
+	
+	private static Logger logger = Logger.getLogger("org.scribble.osgi.resolutions");
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/resolutions/ShowReferencedDescription.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/resolutions/ShowReferencedDescription.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/resolutions/ShowReferencedDescription.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,188 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 7 Sep 2008 : Initial version created by gary
+ */
+package org.scribble.model.resolutions;
+
+import java.util.logging.Logger;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.DefaultResolution;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.util.ResourceUtil;
+
+/**
+ * This class represents a resolution for navigating to a referenced
+ * description.
+ *
+ */
+public class ShowReferencedDescription extends DefaultResolution {
+
+	private static final String SOURCE_REF_END_POSITION = "sourceRefEndPosition";
+	private static final String SOURCE_REF_START_POSITION = "sourceRefStartPosition";
+	private static final String SOURCE_REF_MODEL_OBJECT_URI = "sourceRefModelObjectURI";
+	private static final String SOURCE_REF_COMPONENT_URI = "sourceRefComponentURI";
+	private static final String SRD_SRC_REF_PREFIX = "_srdSrcRef_";
+	private static final String SRD_MODEL_PREFIX = "_srdModel_";
+	private static final String MODEL_NOTATION = "modelNotation";
+	private static final String MODEL_LOCATED_ROLE = "modelLocatedRole";
+	private static final String MODEL_LOCALPART = "modelLocalpart";
+	private static final String MODEL_NAMESPACE = "modelNamespace";
+
+	/**
+	 * The default constructor for the 'show reference
+	 * description'.
+	 */
+	public ShowReferencedDescription() {
+		setName(java.util.PropertyResourceBundle.getBundle(
+				"org.scribble.model.resolutions.Messages").
+			getString("_SHOW_REFERENCED_DESCRIPTION_NAME"));
+		setDescription(java.util.PropertyResourceBundle.getBundle(
+				"org.scribble.model.resolutions.Messages").
+			getString("_SHOW_REFERENCED_DESCRIPTION_DESC"));
+	}
+		
+	/**
+	 * This method sets the model's reference.
+	 * 
+	 * @param ref The model's reference
+	 */
+	public void setModel(ModelReference ref) {
+		getProperties().put(MODEL_NAMESPACE, ref.getNamespace());
+		getProperties().put(MODEL_LOCALPART, ref.getLocalpart());
+		getProperties().put(MODEL_LOCATED_ROLE, ref.getLocatedRole());
+		getProperties().put(MODEL_NOTATION, ref.getNotation());
+		
+		java.util.Iterator<String> iter=ref.getPropertyNames().iterator();
+		
+		while (iter.hasNext()) {
+			String name=iter.next();
+			getProperties().put(SRD_MODEL_PREFIX+name, ref.getProperty(name));
+		}
+	}
+	
+	/**
+	 * This method sets the source reference associated with the
+	 * referenced model object.
+	 * 
+	 * @param sref The source reference
+	 */
+	public void setSourceReference(SourceRef sref) {
+		getProperties().put(SOURCE_REF_COMPONENT_URI, sref.getComponentURI());
+		getProperties().put(SOURCE_REF_MODEL_OBJECT_URI, sref.getModelObjectURI());
+		getProperties().put(SOURCE_REF_START_POSITION, sref.getStartPosition());
+		getProperties().put(SOURCE_REF_END_POSITION, sref.getEndPosition());
+
+		java.util.Iterator<String> iter=sref.getProperties().keySet().iterator();
+		
+		while (iter.hasNext()) {
+			String name=iter.next();
+			getProperties().put(SRD_SRC_REF_PREFIX+name, sref.getProperties().get(name));
+		}
+	}
+
+	/**
+	 * This method is invoked to perform the resolution
+	 * on the identified model, associated with the model
+	 * object located using the supplied source reference
+	 * information. Further details regarding the issue
+	 * to be resolved is provided by the model issue -
+	 * although the 'model object' part of the model
+	 * issue may not be defined. This will have to be
+	 * recovered using the supplied model and source
+	 * reference.
+	 * 
+	 * @param ref The model reference
+	 * @param obj The source reference of the model object
+	 * @param issue The issue
+	 * @exception ResolutionException Failed to resolve
+	 */
+	@Override
+	public void resolve(ModelReference ref, SourceRef obj,
+					ModelIssue issue) throws ResolutionException {
+			
+		// Recover the model reference
+		ModelReference modelRef=new ModelReference(
+				(String)getProperties().get(MODEL_NAMESPACE),
+				(String)getProperties().get(MODEL_LOCALPART),
+				(String)getProperties().get(MODEL_LOCATED_ROLE),
+				(String)getProperties().get(MODEL_NOTATION));
+		
+		// Recover the source reference
+		SourceRef sref=new SourceRef();
+		sref.setComponentURI((String)getProperties().get(SOURCE_REF_COMPONENT_URI));
+		sref.setModelObjectURI((String)getProperties().get(SOURCE_REF_MODEL_OBJECT_URI));
+		
+		if (getProperties().containsKey(SOURCE_REF_START_POSITION)) {
+			sref.setStartPosition((Integer)getProperties().get(SOURCE_REF_START_POSITION));
+		}
+		
+		if (getProperties().containsKey(SOURCE_REF_END_POSITION)) {
+			sref.setEndPosition((Integer)getProperties().get(SOURCE_REF_END_POSITION));
+		}
+		
+		// Recover the properties for model and source ref
+		java.util.Iterator<String> iter=getProperties().keySet().iterator();
+		while (iter.hasNext()) {
+			String name=iter.next();
+			
+			if (name.startsWith(SRD_MODEL_PREFIX)) {
+				Object value=getProperties().get(name);
+				
+				name = name.substring(SRD_MODEL_PREFIX.length());
+				
+				modelRef.setProperty(name, value);
+			} else if (name.startsWith(SRD_SRC_REF_PREFIX)) {
+				Object value=getProperties().get(name);
+				
+				name = name.substring(SRD_SRC_REF_PREFIX.length());
+				
+				sref.getProperties().put(name, value);
+			}
+		}		
+		
+		// Find notation for the URI
+		org.scribble.model.Notation notation=
+				ResourceUtil.getNotation(modelRef.getNotation());
+		
+		if (notation != null) {
+			org.scribble.editor.EditorManager em=(org.scribble.editor.EditorManager)
+					org.scribble.extensions.RegistryFactory.getRegistry().getExtension(
+							org.scribble.editor.EditorManager.class, notation.getCode());
+						
+			if (em != null) {
+				try {
+					em.focus(modelRef, sref, issue.getProperties());
+				} catch(Exception e) {
+					logger.log(java.util.logging.Level.SEVERE,
+							"Failed to focus on model reference: "+modelRef, e);
+				}
+			}
+		}
+	}
+	
+	public int hashCode() {
+		return(0);
+	}
+	
+	public boolean equals(Object obj) {
+		return(obj instanceof ShowReferencedDescription);
+	}
+	
+	private static Logger logger = Logger.getLogger("org.scribble.model.resolutions");
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/resolutions/UpdateFromReferencedDescription.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/resolutions/UpdateFromReferencedDescription.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/resolutions/UpdateFromReferencedDescription.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,223 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 7 Sep 2008 : Initial version created by gary
+ */
+package org.scribble.model.resolutions;
+
+//import java.util.logging.Logger;
+
+import java.io.IOException;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.DefaultModelListener;
+import org.scribble.model.admin.DefaultResolution;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.change.*;
+
+/**
+ * This class represents a resolution for navigating to a referenced
+ * description.
+ *
+ */
+public class UpdateFromReferencedDescription extends DefaultResolution {
+
+	private static final String SOURCE_REF_END_POSITION = "sourceRefEndPosition";
+	private static final String SOURCE_REF_START_POSITION = "sourceRefStartPosition";
+	private static final String SOURCE_REF_MODEL_OBJECT_URI = "sourceRefModelObjectURI";
+	private static final String SOURCE_REF_COMPONENT_URI = "sourceRefComponentURI";
+	private static final String UFRD_SRC_REF_PREFIX = "_ufrdSrcRef_";
+	private static final String UFRD_MODEL_PREFIX = "_ufrdModel_";
+	private static final String MODEL_NOTATION = "modelNotation";
+	private static final String MODEL_LOCATED_ROLE = "modelLocatedRole";
+	private static final String MODEL_LOCALPART = "modelLocalpart";
+	private static final String MODEL_NAMESPACE = "modelNamespace";
+
+	/**
+	 * The default constructor for the 'show reference
+	 * description'.
+	 */
+	public UpdateFromReferencedDescription() {
+		setName(java.util.PropertyResourceBundle.getBundle(
+				"org.scribble.model.resolutions.Messages").
+					getString("_UPDATE_FROM_REFERENCED_DESCRIPTION_NAME"));
+		setDescription(java.util.PropertyResourceBundle.getBundle(
+				"org.scribble.model.resolutions.Messages").
+					getString("_UPDATE_FROM_REFERENCED_DESCRIPTION_DESC"));
+	}
+		
+	/**
+	 * This method sets the model's reference.
+	 * 
+	 * @param ref The model's reference
+	 */
+	public void setModel(ModelReference ref) {
+		getProperties().put(MODEL_NAMESPACE, ref.getNamespace());
+		getProperties().put(MODEL_LOCALPART, ref.getLocalpart());
+		getProperties().put(MODEL_LOCATED_ROLE, ref.getLocatedRole());
+		getProperties().put(MODEL_NOTATION, ref.getNotation());
+		
+		java.util.Iterator<String> iter=ref.getPropertyNames().iterator();
+		
+		while (iter.hasNext()) {
+			String name=iter.next();
+			getProperties().put(UFRD_MODEL_PREFIX+name, ref.getProperty(name));
+		}
+	}
+	
+	/**
+	 * This method sets the source reference associated with the
+	 * referenced model object.
+	 * 
+	 * @param sref The source reference
+	 */
+	public void setSourceReference(SourceRef sref) {
+		getProperties().put(SOURCE_REF_COMPONENT_URI, sref.getComponentURI());
+		getProperties().put(SOURCE_REF_MODEL_OBJECT_URI, sref.getModelObjectURI());
+		getProperties().put(SOURCE_REF_START_POSITION, sref.getStartPosition());
+		getProperties().put(SOURCE_REF_END_POSITION, sref.getEndPosition());
+
+		java.util.Iterator<String> iter=sref.getProperties().keySet().iterator();
+		
+		while (iter.hasNext()) {
+			String name=iter.next();
+			getProperties().put(UFRD_SRC_REF_PREFIX+name, sref.getProperties().get(name));
+		}
+	}
+
+	/**
+	 * This method is invoked to perform the resolution
+	 * on the identified model, associated with the model
+	 * object located using the supplied source reference
+	 * information. Further details regarding the issue
+	 * to be resolved is provided by the model issue -
+	 * although the 'model object' part of the model
+	 * issue may not be defined. This will have to be
+	 * recovered using the supplied model and source
+	 * reference.
+	 * 
+	 * @param ref The model reference
+	 * @param obj The source reference of the model object
+	 * @param issue The issue
+	 * @exception ResolutionException Failed to resolve
+	 */
+	@Override
+	public void resolve(ModelReference ref, SourceRef obj,
+					ModelIssue issue) throws ResolutionException {
+			
+		// Recover the model reference
+		ModelReference modelRef=new ModelReference(
+				(String)getProperties().get(MODEL_NAMESPACE),
+				(String)getProperties().get(MODEL_LOCALPART),
+				(String)getProperties().get(MODEL_LOCATED_ROLE),
+				(String)getProperties().get(MODEL_NOTATION));
+		
+		// Recover the source reference
+		SourceRef sref=new SourceRef();
+		sref.setComponentURI((String)getProperties().get(SOURCE_REF_COMPONENT_URI));
+		sref.setModelObjectURI((String)getProperties().get(SOURCE_REF_MODEL_OBJECT_URI));
+		sref.setStartPosition((Integer)getProperties().get(SOURCE_REF_START_POSITION));
+		sref.setEndPosition((Integer)getProperties().get(SOURCE_REF_END_POSITION));
+		
+		// Recover the properties for model and source ref
+		java.util.Iterator<String> iter=getProperties().keySet().iterator();
+		while (iter.hasNext()) {
+			String name=iter.next();
+			
+			if (name.startsWith(UFRD_MODEL_PREFIX)) {
+				Object value=getProperties().get(name);
+				
+				name = name.substring(UFRD_MODEL_PREFIX.length());
+				
+				modelRef.setProperty(name, value);
+			} else if (name.startsWith(UFRD_SRC_REF_PREFIX)) {
+				Object value=getProperties().get(name);
+				
+				name = name.substring(UFRD_SRC_REF_PREFIX.length());
+				
+				sref.getProperties().put(name, value);
+			}
+		}		
+		
+		org.scribble.model.admin.ModelRepository mrep=
+				(org.scribble.model.admin.ModelRepository)
+			org.scribble.extensions.RegistryFactory.getRegistry().getExtension(
+					org.scribble.model.admin.ModelRepository.class, null);
+
+		DefaultModelChangeContext context=
+					new DefaultModelChangeContext(ref,
+							ref.getLocatedRole()==null?null :
+								new Role(ref.getLocatedRole()));
+
+		// Retrieve source and reference models and identify
+		// the relevant model objects
+		
+		// NOTE: Should only really be one model that matches
+		// the reference - i.e. the source model reference, and
+		// therefore this single model should provide access
+		// to the required model object. If a model reference
+		// is abstract/derived, then it may provide multiple models
+		// that might incorrectly return a model object for the URI.
+		
+		Model model=mrep.getModel(ref, new DefaultModelListener());
+		ModelObject toObj=null;
+		
+		if (model != null) {
+			toObj = model.findModelObject(obj.getModelObjectURI());
+		}
+				
+		Model refModel = mrep.getModel(modelRef, new DefaultModelListener());
+		ModelObject fromObj=null;
+		
+		if (refModel != null) {
+			fromObj = refModel.findModelObject(sref.getModelObjectURI());
+		}
+
+		boolean f_updated=false;
+		
+		if (model != null && fromObj != null && toObj != null) {
+
+			if (f_updated=context.update(model, fromObj, toObj)) {
+			
+				try {
+					// Update the model
+					mrep.updateModel(ref, model);
+				} catch (IOException e) {
+					throw new ResolutionException(java.util.PropertyResourceBundle.getBundle(
+								"org.scribble.model.resolutions.Messages").
+								getString("_COULD_NOT_SAVE"));
+				}
+			}
+		}
+		
+		if (f_updated == false) {
+			throw new ResolutionException(java.util.PropertyResourceBundle.getBundle(
+					"org.scribble.model.resolutions.Messages").
+					getString("_COULD_NOT_UPDATE"));
+		}
+	}
+	
+	public int hashCode() {
+		return(0);
+	}
+	
+	public boolean equals(Object obj) {
+		return(obj instanceof UpdateFromReferencedDescription);
+	}
+	
+	//private static Logger logger = Logger.getLogger("org.scribble.model.resolutions");
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/types/DefaultTypeResolver.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/types/DefaultTypeResolver.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/types/DefaultTypeResolver.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 25 Jan 2009 : Initial version created by gary
+ */
+package org.scribble.model.types;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+
+/**
+ * This interface provides type reference resolution
+ * capabilities.
+ */
+ at RegistryInfo(extension=TypeResolver.class)
+public class DefaultTypeResolver implements TypeResolver {
+
+	/**
+	 * This method returns the type reference associated
+	 * with the supplied model object.
+	 * 
+	 * @param modelObject The model object
+	 * @return The type reference associated with the
+	 * 			model object, or null if unknown
+	 */
+	public TypeReference resolve(ModelObject modelObject) {
+		TypeReference ret=null;
+		
+		java.util.List<Object> typeResolverRules=
+			org.scribble.extensions.RegistryFactory.getRegistry().getExtensions(
+						TypeResolverRule.class, null);
+
+		for (int i=0; ret == null &&
+					i < typeResolverRules.size(); i++) {
+			TypeResolverRule resolver=(TypeResolverRule)
+						typeResolverRules.get(i);
+			
+			if (resolver.isSupported(modelObject)) {
+				ret = resolver.resolve(modelObject);
+			}
+		}
+
+		return(ret);
+	}
+
+	/**
+	 * This method resolves additional type information about the
+	 * supplied model object.
+	 * 
+	 * @param modelObject The model object
+	 * @return The set of type information associated with the
+	 * 					supplied type reference
+	 */
+	public java.util.Set<TypeInformation> getTypeInformation(ModelObject modelObject) {
+		java.util.Set<TypeInformation> ret=null;
+		Model model=null;
+		
+		// Derive model from the supplied model object
+		ModelObject cur=modelObject;
+		
+		while (cur != null && model == null) {
+			if (cur instanceof Model) {
+				model = (Model)cur;
+			} else {
+				cur = cur.getParent();
+			}
+		}
+		
+		// Resolve type reference for model object
+		TypeReference tref=resolve(modelObject);
+		
+		if (tref != null && model != null) {
+			java.util.List<Object> tsysList=
+				org.scribble.extensions.RegistryFactory.getRegistry().getExtensions(
+							TypeSystem.class, null);
+			
+			for (int i=0; ret == null && i < tsysList.size(); i++) {
+				TypeSystem tsys=(TypeSystem)tsysList.get(i);
+				
+				ret = tsys.getInformation(model, tref);
+			}
+		}
+	
+		if (ret == null) {
+			ret = new java.util.HashSet<TypeInformation>();
+		}
+		
+		return(ret);
+	}
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/types/TypeInformation.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/types/TypeInformation.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/types/TypeInformation.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 25 Jan 2009 : Initial version created by gary
+ */
+package org.scribble.model.types;
+
+public class TypeInformation {
+
+	/**
+	 * This method returns the type system associated with
+	 * the type information.
+	 * 
+	 * @return The type system
+	 */
+	public TypeSystem getTypeSystem() {
+		return(m_typeSystem);
+	}
+
+	/**
+	 * This method sets the type system.
+	 * 
+	 * @param tsys The type system
+	 */
+	public void setTypeSystem(TypeSystem tsys) {
+		m_typeSystem = tsys;
+	}
+	
+	/**
+	 * This method determines if the type, associated with this
+	 * reference, is a boolean.
+	 * 
+	 * @return Whether the referenced type is a boolean
+	 */
+	public boolean isBoolean() {
+		return(m_boolean);
+	}
+	
+	/**
+	 * This method sets whether the referenced type is
+	 * a boolean.
+	 * 
+	 * @param bool Whether the referenced type is a boolean
+	 */
+	public void setBoolean(boolean bool) {
+		m_boolean = bool;
+	}
+	
+	private TypeSystem m_typeSystem=null;
+	private boolean m_boolean=false;
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/types/TypeResolver.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/types/TypeResolver.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/types/TypeResolver.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 25 Jan 2009 : Initial version created by gary
+ */
+package org.scribble.model.types;
+
+import org.scribble.model.*;
+
+/**
+ * This interface provides type reference resolution
+ * capabilities.
+ */
+public interface TypeResolver {
+
+	/**
+	 * This method returns the type reference associated
+	 * with the supplied model object.
+	 * 
+	 * @param modelObject The model object
+	 * @return The type reference associated with the
+	 * 			model object, or null if unknown
+	 */
+	public TypeReference resolve(ModelObject modelObject);
+	
+	/**
+	 * This method resolves additional type information about the
+	 * supplied model object.
+	 * 
+	 * @param modelObject The model object
+	 * @return The set of type information associated with the
+	 * 					supplied type reference
+	 */
+	public java.util.Set<TypeInformation> getTypeInformation(ModelObject modelObject);
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/types/TypeResolverRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/types/TypeResolverRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/types/TypeResolverRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 25 Jan 2009 : Initial version created by gary
+ */
+package org.scribble.model.types;
+
+import org.scribble.model.*;
+
+/**
+ * This interface provides type reference resolution
+ * rule.
+ */
+public interface TypeResolverRule {
+
+	/**
+	 * This method determines if the type resolver rule
+	 * is appropriate for the supplied model object.
+	 * 
+	 * @param modelObject The model object
+	 * @return Whether the rule is appropriate
+	 */
+	public boolean isSupported(ModelObject modelObject);
+	
+	/**
+	 * This method returns the type reference associated
+	 * with the supplied model object.
+	 * 
+	 * @param modelObject The model object
+	 * @return The type reference associated with the
+	 * 			model object, or null if unknown
+	 */
+	public TypeReference resolve(ModelObject modelObject);
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/types/TypeSystem.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/types/TypeSystem.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/types/TypeSystem.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 25 Jan 2009 : Initial version created by gary
+ */
+package org.scribble.model.types;
+
+import org.scribble.model.*;
+
+/**
+ * This interface represents functionality associated with a type
+ * system.
+ */
+public interface TypeSystem {
+
+	/**
+	 * This method returns the name of the type system.
+	 * 
+	 * @return The type system
+	 */
+	public String getName();
+	
+	/**
+	 * This method resolves additional information about the
+	 * supplied type. The information is obtained using binding
+	 * information defined in the supplied model.
+	 * 
+	 * @param model The model
+	 * @param type The type
+	 * @return The set of type information associated with the
+	 * 					supplied type reference
+	 */
+	public java.util.Set<TypeInformation> getInformation(Model model,
+							TypeReference type);
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/util/InteractionUtil.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/util/InteractionUtil.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/model/util/InteractionUtil.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,113 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 28 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.model.util;
+
+import org.scribble.model.*;
+
+/**
+ * This class provides utility functions related to
+ * interactions.
+ * 
+ */
+public class InteractionUtil {
+
+	/**
+	 * This method returns the list of initial interactions associated with the supplied
+	 * definition.
+	 * 
+	 * @param defn The definition
+	 * @return The list of initial interactions
+	 */
+	public static java.util.List<Interaction> getInitialInteractions(Definition defn) {
+		java.util.List<Interaction> ret=new java.util.Vector<Interaction>();
+		
+		// Find first behaviour in the block
+		for (int i=0; i < defn.getBlock().getContents().size(); i++) {
+			if (defn.getBlock().getContents().get(i) instanceof Behaviour) {
+				findInitialInteractions((Behaviour)defn.getBlock().getContents().get(i),
+									ret);
+				break;
+			}
+		}		
+		
+		return(ret);
+	}
+	
+	protected static void findInitialInteractions(Behaviour behaviour,
+								java.util.List<Interaction> interactions) {
+		if (behaviour instanceof Interaction) {
+			interactions.add((Interaction)behaviour);
+		} else if (behaviour instanceof SinglePathBehaviour) {
+			SinglePathBehaviour spb=(SinglePathBehaviour)behaviour;
+			
+			// Find first behaviour in the block
+			for (int i=0; i < spb.getBlock().getContents().size(); i++) {
+				if (spb.getBlock().getContents().get(i) instanceof Behaviour) {
+					findInitialInteractions((Behaviour)spb.getBlock().getContents().get(i),
+										interactions);
+				}
+			}
+			
+			if (spb.isConditional()) {
+				// TODO: Process behaviour following the single behaviour path
+				
+			}
+		} else if (behaviour instanceof MultiPathBehaviour) {
+			MultiPathBehaviour mpb=(MultiPathBehaviour)behaviour;
+			
+			// Scan the multiple paths
+			for (int i=0; i < mpb.getPaths().size(); i++) {
+				Block path=mpb.getPaths().get(i);
+				
+				for (int j=0; j < path.getContents().size(); j++) {
+					if (path.getContents().get(j) instanceof Behaviour) {
+						findInitialInteractions((Behaviour)path.getContents().get(j),
+											interactions);
+						break;
+					}
+				}
+			}
+		}
+	}
+	
+	/**
+	 * This method determines whether this is an initial interaction
+	 * associated with the definition.
+	 * 
+	 * @param interaction The interaction
+	 * @return Whether the interaction is an initial in the definition
+	 */
+	public static boolean isInitialInteraction(Interaction interaction) {
+		boolean ret=false;
+		
+		// Get definition
+		Definition defn=interaction.getEnclosingDefinition();
+		
+		// Check if top level
+		if (defn.getParent() instanceof Model) {
+			java.util.List<Interaction> interactions=
+				org.scribble.model.util.InteractionUtil.getInitialInteractions(defn);
+			
+			ret = interactions.contains(interaction);
+		}
+		
+		return(ret);
+	}	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/osgi/Activator.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/osgi/Activator.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/osgi/Activator.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 16 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.osgi;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.scribble.extensions.OSGiRegistry;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator implements BundleActivator {
+
+	// The plug-in ID
+	public static final String PLUGIN_ID = "org.scribble";
+
+	// The shared instance
+	private static Activator plugin;
+	
+	/**
+	 * The constructor
+	 */
+	public Activator() {
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+	 */
+	public void start(BundleContext context) throws Exception {
+		plugin = this;
+		
+		// Create the OSGiRegistry
+		OSGiRegistry registry=new OSGiRegistry(context);
+		registry.initialize();
+		
+		org.scribble.extensions.RegistryFactory.setRegistry(registry);
+		
+		// Initialize model repository and dependency manager
+		org.scribble.extensions.RegistryFactory.getRegistry().getExtension(
+					org.scribble.model.admin.ModelRepository.class,
+								null);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+	 */
+	public void stop(BundleContext context) throws Exception {
+		plugin = null;
+	}
+
+	/**
+	 * Returns the shared instance
+	 *
+	 * @return the shared instance
+	 */
+	public static Activator getDefault() {
+		return plugin;
+	}
+
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/AbstractImplementsReferenceParserRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/AbstractImplementsReferenceParserRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/AbstractImplementsReferenceParserRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,166 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 1 Feb 2008 : Initial version created by gary
+ */
+package org.scribble.parser;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class provides the parser rule for the Implements Reference
+ * between a global model and a local model.
+ */
+public abstract class AbstractImplementsReferenceParserRule extends AbstractModelReferenceParserRule {
+
+	/**
+	 * This is the default constructor.
+	 */
+	public AbstractImplementsReferenceParserRule() {
+		super(true);
+	}
+	
+	/**
+	 * This method returns the class associated with the
+	 * concrete model reference.
+	 * 
+	 * @return The model reference class
+	 */
+	protected Class<?> getReferenceClass() {
+		return(ImplementsReference.class);
+	}
+
+	/**
+	 * This method instantiates an instance of the model
+	 * reference.
+	 * 
+	 * @param context The parser context
+	 * @param l The model listener
+	 * @return The instantiated model reference
+	 */
+	protected ModelReference createReference(ParserContext context, ModelListener l) {
+		return(new ImplementsReference(getNotation(context, l)));
+	}
+	
+	/**
+	 * This method returns the notation that should be used for the
+	 * 'implements' reference.
+	 * 
+	 * @param context The parser context
+	 * @param l The model listener
+	 * @return The notation code
+	 */
+	protected abstract String getNotation(ParserContext context, ModelListener l);
+
+	/**
+	 * This method parses the description to obtain
+	 * a model object of the appropriate type.
+	 * 
+	 * @param context The context
+	 * @param l The listener
+	 * @return The model object
+	 */
+	public Object parse(ParserContext context, ModelListener l) {
+		Object ret=super.parse(context, l);
+		
+		if (ret instanceof ImplementsReference) {
+			ImplementsReference ref=(ImplementsReference)ret;
+		
+			Token t=context.lookahead(0);
+			
+			if (t.isToken("(", TokenType.Symbol)) {
+				boolean f_error=false;
+				
+				do {
+					// Consume token
+					context.nextToken();
+					
+					// Read next token, which should be an identifier
+					t = context.lookahead(0);
+				
+					if (t.getType() == TokenType.Identifier) {
+						String main=null;
+						String binding=null;
+						
+						// Consume token
+						context.nextToken();
+					
+						main = t.getText();
+						
+						t = context.lookahead(0);
+						
+						if (t.isToken("for", TokenType.Keyword)) {
+							
+							context.nextToken();
+							
+							t = context.lookahead(0);
+							
+							if (t.getType() == TokenType.Identifier) {
+								
+								context.nextToken();
+								
+								binding = t.getText();
+							} else {
+								l.error(new ModelIssue(t, java.util.PropertyResourceBundle.getBundle(
+										"org.scribble.parser.Messages").
+											getString("_EXPECTING_IDENTIFIER")));
+								f_error = true;
+							}
+						} else {
+							l.error(new ModelIssue(t,
+									org.scribble.util.MessageUtil.format(
+											java.util.PropertyResourceBundle.getBundle(
+													"org.scribble.parser.Messages"),
+											"_EXPECTING_KEYWORD",
+											new String[]{"for"})));
+							f_error = true;
+						}
+						
+						if (main != null && binding != null) {
+							ref.getNameMapping().put(binding, main);
+						}
+					} else {
+						l.error(new ModelIssue(t, java.util.PropertyResourceBundle.getBundle(
+							"org.scribble.parser.Messages").
+							getString("_EXPECTING_IDENTIFIER")));
+						f_error = true;
+					}
+					
+					t = context.lookahead(0);
+				
+				} while (f_error == false &&
+						t.isToken(ParserConstants.LIST_SEPARATOR,
+								TokenType.Symbol));			
+				
+				if (t.isToken(")", TokenType.Symbol)) {
+					
+					ref.getSource().setEndPosition(t.getSource().getEndPosition());
+					
+					context.nextToken();
+				} else {
+					l.error(new ModelIssue(t, java.util.PropertyResourceBundle.getBundle(
+							"org.scribble.parser.Messages").
+							getString("_EXPECTING_PARAMETER_LIST_DELIMITER")));
+				}
+			}
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/AbstractModelParserRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/AbstractModelParserRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/AbstractModelParserRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,150 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 21 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.parser;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class provides the generic parsing for the model class.
+ * Specific notations specialise the class to parse the specific
+ * notation.
+ */
+public abstract class AbstractModelParserRule extends AbstractParserRule {
+
+	/**
+	 * The default constructor.
+	 */
+	public AbstractModelParserRule() {
+		super(ParserRuleType.File);
+	}
+	
+	/**
+	 * This method determines whether the parser rules is
+	 * appropriate to return a model object of the required
+	 * type.
+	 * 
+	 * @param type The required type
+	 * @return Whether the parser rule returns a
+	 * 				model object of the required type
+	 */
+	public boolean isSupported(Class<?> type) {
+		return(type.isAssignableFrom(Model.class));
+	}
+	
+	/**
+	 * This method creates the initial empty model.
+	 * 
+	 * @return The model
+	 */
+	protected abstract Model createModel();
+
+	/**
+	 * This method parses the description to obtain
+	 * a model object of the appropriate type.
+	 * 
+	 * @param context The context
+	 * @param l The listener
+	 * @return The model object
+	 */
+	public Object parse(ParserContext context, ModelListener l) {
+		Model ret=createModel();
+		
+		// Parse namespace
+		ret.setNamespace((Namespace)context.parse(Namespace.class, l));
+		
+		// Parse model header items
+		Token t=context.lookahead(0);
+		boolean parsed=true;
+		
+		while (parsed && t.getType() == TokenType.Keyword &&
+				isDefinitionKeyword(t.getText()) == false) {
+			Token prev = context.lookahead(0);
+
+			parseModelHeaderItem(context, l, ret);
+			
+			t = context.lookahead(0);
+			
+			if (t == prev) {
+				parsed = false;
+				
+				do {
+					t = context.nextToken();
+					
+				} while (t.getType() != TokenType.EndOfLine &&
+						t.getType() != TokenType.EndOfFile);
+				
+				t = context.lookahead(0);
+			}
+		}
+		
+		// Parse the model
+		parseModelBody(context, l, ret);
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method determines whether the keyword is associated
+	 * with the model.
+	 * 
+	 * @param keyword The model keyword
+	 * @return Whether the keyword is associated with the definition
+	 */
+	protected abstract boolean isDefinitionKeyword(String keyword);
+
+	/**
+	 * This method parsers the model header items.
+	 * 
+	 * @param context The context
+	 * @param l The model listener
+	 * @param model The model
+	 * @return The item has been parsed
+	 */
+	protected boolean parseModelHeaderItem(ParserContext context,
+			ModelListener l, Model model) {
+		boolean ret=false;
+		
+		Token t = context.lookahead(0);
+		
+		if (t.isToken("import", TokenType.Keyword)) {
+			ret = true;
+			
+			Import imp=(Import)context.parse(Import.class, l);
+		
+			if (imp != null) {
+				model.getImports().add(imp);
+			}
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method parsers the model body.
+	 * 
+	 * @param context The context
+	 * @param l The model listener
+	 * @param model The model
+	 */
+	protected abstract void parseModelBody(ParserContext context,
+			ModelListener l, Model model);
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/AbstractModelReferenceParserRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/AbstractModelReferenceParserRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/AbstractModelReferenceParserRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,194 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 24 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.parser;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class provides the parser rule for the Type Reference.
+ */
+public abstract class AbstractModelReferenceParserRule extends AbstractParserRule {
+
+	/**
+	 * This is the default constructor.
+	 */
+	public AbstractModelReferenceParserRule(boolean located) {
+		super(ParserRuleType.Clause);
+		
+		m_located = located;
+	}
+	
+	/**
+	 * This method determines whether the parser rules is
+	 * appropriate to return a model object of the required
+	 * type.
+	 * 
+	 * @param type The required type
+	 * @return Whether the parser rule returns a
+	 * 				model object of the required type
+	 */
+	public boolean isSupported(Class<?> type) {
+		return(type.isAssignableFrom(getReferenceClass()));
+	}
+
+	/**
+	 * This method returns whether the model reference parser
+	 * should check for a located role.
+	 * 
+	 * @return Whether model reference may be located
+	 */
+	protected boolean isLocated() {
+		return(m_located);
+	}
+	
+	/**
+	 * This method returns the class associated with the
+	 * concrete model reference.
+	 * 
+	 * @return The model reference class
+	 */
+	protected abstract Class<?> getReferenceClass();
+
+	/**
+	 * This method instantiates an instance of the model
+	 * reference.
+	 * 
+	 * @param context The parser context
+	 * @param l The model listener
+	 * @return The instantiated model reference
+	 */
+	protected abstract ModelReference createReference(ParserContext context, ModelListener l);
+	
+	/**
+	 * This method parses the description to obtain
+	 * a model object of the appropriate type.
+	 * 
+	 * @param context The context
+	 * @param l The listener
+	 * @return The model object
+	 */
+	public Object parse(ParserContext context, ModelListener l) {
+		ModelReference ret=null;
+		
+		Token t=context.nextToken();
+		
+		if (t.getType() == TokenType.Identifier) {
+			int startpos=t.getSource().getStartPosition();
+
+			ret = createReference(context, l);
+			
+			//ret.setAlias(buf.toString());
+			int endpos = parseReference(context, l, t, ret);
+			
+			// Check if reference could be located
+			t = context.lookahead(0);
+			
+			if (isLocated() && t.isToken(ModelReference.LOCATED_REFERENCE_SEPARATOR,
+								TokenType.Symbol)) {
+				context.nextToken();
+				
+				t = context.lookahead(0);
+				
+				if (t.getType() == TokenType.Identifier) {
+					endpos = t.getSource().getEndPosition();
+					
+					context.nextToken();
+					
+					// TODO: Should this be role object
+					// rather than string - would need to move
+					// Role class from protocol to core??
+					// Not sure if should be role object
+					// on reference, but should possibly should
+					// have option for validating role.
+					
+					ret.setLocatedRole(t.getText());
+				} else {
+					l.error(new ModelIssue(t, java.util.PropertyResourceBundle.getBundle(
+							"org.scribble.parser.Messages").
+								getString("_EXPECTING_ROLE_NAME")));
+				}
+			}
+			
+			// Resolve reference
+			// 30/1/08: Now done by code retrieving the reference, so that it
+			// can register the appropriate dependency type
+			//resolveReference(context, l, ret);
+			
+			ret.getSource().setStartPosition(startpos);
+			ret.getSource().setEndPosition(endpos);
+		} else {
+			l.error(new ModelIssue(t, java.util.PropertyResourceBundle.getBundle(
+						"org.scribble.parser.Messages").
+						getString("_EXPECTING_IDENTIFIER")));
+		}
+		
+		return(ret);
+	}
+	
+	protected int parseReference(ParserContext context, ModelListener l,
+			Token initialToken, ModelReference ref) {
+		int ret=initialToken.getSource().getEndPosition();
+		StringBuffer namespace=new StringBuffer();
+		Token prevToken=initialToken;
+		
+		// Check if next token is a '.'
+		Token t=context.lookahead(0);
+		boolean f_error=false;
+		
+		while (f_error==false && t.isToken(".", TokenType.Symbol)) {
+			
+			context.nextToken();
+			
+			t = context.nextToken();
+			
+			if (t.getType() == TokenType.Identifier) {
+			
+				if (namespace.length() > 0) {
+					namespace.append(".");
+				}
+				namespace.append(prevToken.getText());
+				
+				prevToken = t;
+				
+				t = context.lookahead(0);
+				
+				ret = t.getSource().getEndPosition();
+				
+			} else {
+				f_error = true;
+			}
+		}
+		
+		if (namespace.length() == 0) {
+			ref.setAlias(prevToken.getText());
+		} else {
+			ref.setNamespace(namespace.toString());
+			ref.setLocalpart(prevToken.getText());
+			
+			ref.setFullyQualified(true);
+		}
+		
+		return(ret);
+	}
+	
+	private boolean m_located=false;
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/AbstractParserRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/AbstractParserRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/AbstractParserRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,379 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 22 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.parser;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class is the abstract parser rule.
+ */
+public abstract class AbstractParserRule implements ParserRule {
+
+	/**
+	 * This constructor initializes the parser rule type.
+	 * 
+	 * @param type The parser rule type
+	 */
+	public AbstractParserRule(ParserRuleType type) {
+		m_type = type;
+	}
+	
+	/**
+	 * This method returns the parser rule type.
+	 * 
+	 * @return The parser rule type
+	 */
+	public ParserRuleType getType() {
+		return(m_type);
+	}
+	
+	/**
+	 * This method parses a group of model objects contained within
+	 * a block delimited by curly braces.
+	 * 
+	 * @param context The context
+	 * @param l The model listener
+	 * @param block The block to add the model objects
+	 * @param isolatedState The group should be parsed within an
+	 * 					isolated scope
+	 * @return The number of model objects added
+	 */
+	protected int parseGroup(ParserContext context, ModelListener l,
+					Block block, boolean isolatedState) {
+		int ret=0;
+		
+		// Store current state
+		if (isolatedState) {
+			context.pushState();
+		}
+		
+		Token t=context.nextToken();
+		
+		//if (t.isToken(ParserConstants.BLOCK_START, TokenType.Symbol)) {
+		if (t.getType() == TokenType.StartOfBlock) {
+			Token errorStart=null;
+			Token errorEnd=null;
+			
+			block.getSource().setStartPosition(t.getSource().getStartPosition());
+			
+			// Remove 'end of line' tokens
+			while ((t = context.lookahead(0)).getType() ==
+								TokenType.EndOfLine) {
+				context.nextToken();
+			}
+			
+			// Iterate until end of group reported			
+			while (//t.isToken(ParserConstants.BLOCK_END, TokenType.Symbol) == false &&
+					t.getType() != TokenType.EndOfBlock &&
+					context.moreTokens()) {
+						
+				Object obj=context.parse(Activity.class, l);
+				
+				if (obj instanceof Activity) {
+					block.getContents().add((Activity)obj);
+					ret++;
+					
+					// Check if previous error token was identified
+					if (errorStart != null) {
+						Token errorToken=new Token("", TokenType.Identifier,
+								errorStart.getSource().getStartPosition(),
+								errorEnd.getSource().getEndPosition());
+						
+						l.error(new ModelIssue(errorToken,
+								org.scribble.util.MessageUtil.format(
+										java.util.PropertyResourceBundle.getBundle(
+												"org.scribble.parser.Messages"),
+										"_EXPECTING_ACTIVITY",
+										new String[]{errorStart.getText()})));
+						
+						errorStart = null;
+						errorEnd = null;
+					}
+				} else {
+					
+					if (errorStart == null) {
+						errorStart = context.lookahead(0);
+					}
+					
+					// Move to next token
+					errorEnd = context.nextToken();
+				}
+				
+				/* GPB: 25/3/08 - not sure need end of line check
+				 * just move to next token if component not found
+				if (obj == null) {
+					
+					// Need to consume up to next terminator
+					// NOTE: Must also consume the terminator
+					// as this would normally be done as part of
+					// parsing the specific line or group type.
+					Token terminator=context.nextToken();
+					while (//terminator.isToken(ParserConstants.BLOCK_END, TokenType.Symbol) == false &&
+							//terminator.isToken(ParserConstants.LINE_TERMINATOR, TokenType.Symbol) == false &&
+							terminator.getType() != TokenType.EndOfBlock &&
+							terminator.getType() != TokenType.EndOfLine &&
+							terminator.getType() != TokenType.EndOfFile) {
+						terminator = context.nextToken();
+					}
+		
+					l.error(preActivity,
+							"Expecting an activity, but found '"+
+							preActivity.getText()+"'", null);
+				}
+				*/
+		
+				// Remove 'end of line' tokens
+				while ((t = context.lookahead(0)).getType() ==
+									TokenType.EndOfLine) {
+					context.nextToken();
+				}
+			}
+			
+			if (t.getType() == TokenType.EndOfBlock) {
+				context.nextToken();
+			} else if (context.moreTokens() == false) {
+				l.error(new ModelIssue(t, "Missing '"+ParserConstants.BLOCK_END+"'"));
+			}
+
+			block.getSource().setEndPosition(t.getSource().getEndPosition());
+			
+		} else {
+			l.error(new ModelIssue(t, "Expecting '"+ParserConstants.BLOCK_START+"'"));
+		}
+		
+		// Pop state
+		if (isolatedState) {
+			context.popState();
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method resolves the supplied model reference, using the import
+	 * information defined in the definition.
+	 * 
+	 * @param context The parser context
+	 * @param l The model listener
+	 * @param ref The model reference to be resolved
+	 */
+	/* GPB: TO REMOVE
+	public static void resolveReference(ParserContext context, ModelListener l,
+								ModelReference ref, DependencyType dependencyType) {
+		java.util.List<String> namespacesToMonitor=new java.util.Vector<String>();
+		
+		if (logger.isLoggable(Level.FINEST)) {
+			logger.finest("Resolve reference: "+ref+" dependency="+dependencyType);
+		}
+		
+		// Use the import information in the definition (available via
+		// the context) to locate the referenced definition
+		// TODO: model repository needs an existence operation
+		// TODO: iterate through list of imports - if namespace.* then
+		// test the namespace with the alias to see if locates a definition
+		// else if namespace.localpart, where localpart is the same as
+		// the alias - or the alias is associated with the import.
+		// Else check the local namespace.
+		
+		// NOTE: parsing is to resolve the reference, not report on whether
+		// the definition is found - this should be the task of the
+		// validation rule
+		
+		org.scribble.model.admin.ModelRepository mrep=
+			(org.scribble.model.admin.ModelRepository)
+			org.scribble.extensions.RegistryFactory.getRegistry().getExtension(
+					org.scribble.model.admin.ModelRepository.class,
+								null);
+		
+		org.scribble.model.admin.DependencyManager dm=
+			(org.scribble.model.admin.DependencyManager)
+			org.scribble.extensions.RegistryFactory.getRegistry().getExtension(
+					org.scribble.model.admin.DependencyManager.class, null);
+		
+		if (mrep != null && ref.isResolved() == false) {
+			boolean f_end=false;
+			
+			// Need to check local namespace
+			ModelReference tmpref=new ModelReference(context.getSource().getNamespace(),
+					ref.getAlias(), ref.getLocatedRole(), ref.getNotation());
+			
+			mrep.locate(tmpref, context.getSource());
+	
+			boolean f_exists=mrep.exists(tmpref, context.getSource());
+			
+			// Check if local reference
+			if (f_exists == false && tmpref.getLocatedRole() != null) {
+				tmpref.setLocatedRole(null);
+			
+				// If global model exists
+				f_exists = mrep.exists(tmpref, context.getSource());
+			}
+			
+			if (f_exists == false && ref.useImplementations()) {
+				
+				if (dm != null) {
+					java.util.List<ModelReference> impls=
+							dm.getDependents(tmpref, DependencyType.Implements);
+					
+					if (logger.isLoggable(Level.FINEST)) {
+						logger.finest("Checking for implements dependent: "+impls.size());
+					}
+					
+					for (int i=0; f_exists == false &&
+								i < impls.size(); i++) {
+						f_exists = mrep.exists(impls.get(i), context.getSource());
+					}
+				}				
+			}
+	
+			if (f_exists) {
+				ref.setNamespace(context.getSource().getNamespace());
+				ref.setLocalpart(ref.getAlias());
+				
+				f_end = true;
+			} else {
+				namespacesToMonitor.add(context.getSource().getNamespace());
+			}
+			
+			if (logger.isLoggable(Level.FINEST)) {
+				logger.finest("Number of imports="+context.getImports().size());
+			}
+			
+			// Check imports
+			for (int i=0; f_end == false &&
+						i < context.getImports().size(); i++) {
+				Import imp=context.getImports().get(i);
+				
+				if (logger.isLoggable(Level.FINEST)) {
+					logger.finest("Checking import: "+imp.getName());
+				}
+	
+				if (imp.getName() != null) {
+					int ind=imp.getName().lastIndexOf('.');
+					String lastelem=null;
+					String firstpart=null;
+					
+					if (ind == -1) {
+						firstpart = "";
+						lastelem = imp.getName();
+					} else {
+						firstpart = imp.getName().substring(0, ind);
+						lastelem = imp.getName().substring(ind+1);
+					}
+					
+					if (lastelem.equals("*")) {
+						// Wildcard, so will need to check repository
+						
+						tmpref = new ModelReference(firstpart,
+								ref.getAlias(), ref.getLocatedRole(),
+								ref.getNotation());
+						
+						mrep.locate(tmpref, context.getSource());
+	
+						f_exists=mrep.exists(tmpref, context.getSource());
+						
+						// Check if local reference
+						if (f_exists == false && tmpref.getLocatedRole() != null) {
+							tmpref.setLocatedRole(null);
+						
+							// If global model exists
+							f_exists = mrep.exists(tmpref, context.getSource());
+						}
+						
+						if (f_exists == false && ref.useImplementations()) {
+													
+							if (dm != null) {
+								java.util.List<ModelReference> impls=
+										dm.getDependents(tmpref, DependencyType.Implements);
+								
+								if (logger.isLoggable(Level.FINEST)) {
+									logger.finest("Checking for implements dependent: "+impls.size());
+								}
+	
+								for (int j=0; f_exists == false &&
+											j < impls.size(); j++) {
+									f_exists = mrep.exists(impls.get(j),
+											context.getSource());
+								}
+							}				
+						}
+						
+						if (f_exists) {
+							
+							ref.setNamespace(firstpart);
+							ref.setLocalpart(ref.getAlias());
+							
+							f_end = true;
+						} else {
+							if (logger.isLoggable(Level.FINEST)) {
+								logger.finest("Monitor namespace: "+firstpart);
+							}
+							
+							namespacesToMonitor.add(firstpart);
+						}
+						
+					} else if ((imp.getAlias() != null &&
+							imp.getAlias().equals(ref.getAlias())) ||
+							(imp.getAlias() == null &&
+							lastelem.equals(ref.getAlias()))) {
+						ref.setNamespace(firstpart);
+						ref.setLocalpart(lastelem);
+						
+						if (logger.isLoggable(Level.FINEST)) {
+							logger.finest("Resolved from specific import: "+ref);
+						}
+	
+						f_end = true;
+					}	
+				}
+			}
+			
+			// Check if reference was resolved
+			if (ref.isResolved() == false) {
+				if (logger.isLoggable(Level.FINEST)) {
+					logger.finest("Not resolved - add namespaces to monitor: "+
+							namespacesToMonitor);
+				}
+				
+				ref.setProperty(ModelReference.NAMESPACES_TO_MONITOR,
+									namespacesToMonitor);
+			}
+		}
+
+		if (mrep != null) {
+			mrep.locate(ref, context.getSource());			
+		}
+		
+		// Establish dependency on the reference
+		if (dm != null) {
+			dm.recordDependency(context.getSource(), ref, dependencyType);
+		}		
+	}
+	*/
+	
+	private static Logger logger = Logger.getLogger("org.scribble.parser");
+
+	private ParserRuleType m_type=null;
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/ChannelListParserRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/ChannelListParserRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/ChannelListParserRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,197 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 27 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.parser;
+
+import org.scribble.extensions.*;
+import org.scribble.model.Channel;
+import org.scribble.model.ChannelList;
+import org.scribble.model.Role;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class provides the parser rule for the Channel List
+ * declaration.
+ */
+ at RegistryInfo(extension=ParserRule.class)
+public class ChannelListParserRule extends org.scribble.parser.AbstractParserRule {
+
+	/**
+	 * The default constructor.
+	 */
+	public ChannelListParserRule() {
+		super(ParserRuleType.Line);
+	}
+	
+	/**
+	 * This method determines whether the parser rules is
+	 * appropriate to return a model object of the required
+	 * type.
+	 * 
+	 * @param type The required type
+	 * @return Whether the parser rule returns a
+	 * 				model object of the required type
+	 */
+	public boolean isSupported(Class<?> type) {
+		return(type.isAssignableFrom(ChannelList.class));
+	}
+
+	/**
+	 * This method parses the description to obtain
+	 * a model object of the appropriate type.
+	 * 
+	 * @param context The context
+	 * @param l The listener
+	 * @return The model object
+	 */
+	public Object parse(ParserContext context, ModelListener l) {
+		ChannelList ret=null;
+		
+		Token t=context.lookahead(0);
+		
+		if (t.isToken("channel", TokenType.Keyword)) {
+			boolean f_error=false;
+			
+			ret = new ChannelList();
+			
+			do {
+				// Consume token
+				context.nextToken();
+				
+				// Read next token, which should be an identifier
+				t = context.lookahead(0);
+			
+				if (t.getType() == TokenType.Identifier) {
+					
+					// Consume token
+					context.nextToken();
+				
+					Channel ch=new Channel();
+					ch.getSource().setStartPosition(t.getSource().getStartPosition());
+				
+					ch.setName(t.getText());
+					
+					ch.getSource().setEndPosition(t.getSource().getEndPosition());
+					
+					ret.getChannels().add(ch);
+					
+					// Check if name has already been defined in state
+					if (context.getState(t.getText()) != null) {
+						l.error(new ModelIssue(t,
+								org.scribble.util.MessageUtil.format(
+										java.util.PropertyResourceBundle.getBundle(
+												"org.scribble.parser.Messages"),
+										"_DUPLICATE_DECLARATION",
+										new String[]{t.getText()})));
+					} else {
+					
+						// Add to state
+						context.setState(ch.getName(), ch);
+					}
+					
+					t = context.lookahead(0);
+					
+					if (t.isToken("from", TokenType.Keyword)) {
+					
+						// Consume
+						context.nextToken();
+						
+						t = context.lookahead(0);
+						
+						if (t.getType() == TokenType.Identifier) {
+							
+							// Consume
+							context.nextToken();
+							
+							// Locate the role definition
+							Object part=context.getState(t.getText());
+							
+							if (part == null) {
+								l.error(new ModelIssue(t,
+									org.scribble.util.MessageUtil.format(
+											java.util.PropertyResourceBundle.getBundle(
+													"org.scribble.parser.Messages"),
+											"_UNKNOWN_ROLE",
+											new String[]{t.getText()})));
+							} else if (part instanceof Role) {
+								ch.setFromRole((Role)part);
+							} else {
+								l.error(new ModelIssue(t,
+									org.scribble.util.MessageUtil.format(
+											java.util.PropertyResourceBundle.getBundle(
+													"org.scribble.parser.Messages"),
+											"_REQUIRED_ROLE",
+											new String[]{t.getText()})));
+							}
+							
+							t = context.lookahead(0);
+						}
+					}
+					
+					if (t.isToken("to", TokenType.Keyword)) {
+						
+						// Consume
+						context.nextToken();
+
+						t = context.lookahead(0);
+
+						if (t.getType() == TokenType.Identifier) {
+							
+							// Consume
+							context.nextToken();
+							
+							// Locate the role definition
+							Object part=context.getState(t.getText());
+							
+							if (part == null) {
+								l.error(new ModelIssue(t,
+									org.scribble.util.MessageUtil.format(
+											java.util.PropertyResourceBundle.getBundle(
+													"org.scribble.parser.Messages"),
+											"_UNKNOWN_ROLE",
+											new String[]{t.getText()})));
+							} else if (part instanceof Role) {
+								ch.setToRole((Role)part);
+							} else {
+								l.error(new ModelIssue(t,
+									org.scribble.util.MessageUtil.format(
+											java.util.PropertyResourceBundle.getBundle(
+													"org.scribble.parser.Messages"),
+											"_REQUIRED_ROLE",
+											new String[]{t.getText()})));
+							}
+							
+							t = context.lookahead(0);
+						}
+					}
+				} else {
+					l.error(new ModelIssue(t, java.util.PropertyResourceBundle.getBundle(
+								"org.scribble.parser.Messages").
+								getString("_EXPECTING_CHANNEL_NAME")));
+					f_error = true;
+				}
+			} while (f_error == false &&
+					t.isToken(ParserConstants.LIST_SEPARATOR,
+							TokenType.Symbol));				
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/ConformanceReferenceParserRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/ConformanceReferenceParserRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/ConformanceReferenceParserRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,165 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 12 Dec 2007 : Initial version created by gary
+ */
+package org.scribble.parser;
+
+import org.scribble.extensions.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class provides the parser rule for the Conformance Reference
+ * between a global model and a local model.
+ */
+ at RegistryInfo(extension=ParserRule.class) //,category=ConformanceReference.class)
+public class ConformanceReferenceParserRule extends AbstractModelReferenceParserRule {
+
+	/**
+	 * This is the default constructor.
+	 */
+	public ConformanceReferenceParserRule() {
+		super(true);
+	}
+	
+	/**
+	 * This method returns the class associated with the
+	 * concrete model reference.
+	 * 
+	 * @return The model reference class
+	 */
+	protected Class<?> getReferenceClass() {
+		return(ConformanceReference.class);
+	}
+
+	/**
+	 * This method instantiates an instance of the model
+	 * reference.
+	 * 
+	 * @param context The parser context
+	 * @param l The model listener
+	 * @return The instantiated model reference
+	 */
+	protected ModelReference createReference(ParserContext context, ModelListener l) {
+		return(new ConformanceReference(context.getSource().getNotation()));
+	}
+
+	/**
+	 * This method parses the description to obtain
+	 * a model object of the appropriate type.
+	 * 
+	 * @param context The context
+	 * @param l The listener
+	 * @return The model object
+	 */
+	public Object parse(ParserContext context, ModelListener l) {
+		Object ret=super.parse(context, l);
+		
+		if (ret instanceof ConformanceReference) {
+			ConformanceReference ref=(ConformanceReference)ret;
+		
+			// Check that referenced model is a local model
+			if (ref.getLocatedRole() == null) {
+				l.error(new ModelIssue(ref, java.util.PropertyResourceBundle.getBundle(
+						"org.scribble.parser.Messages").
+							getString("_EXPECTING_LOCATED_REFERENCE")));
+			}
+			
+			Token t=context.lookahead(0);
+			
+			if (t.isToken("(", TokenType.Symbol)) {
+				boolean f_error=false;
+				
+				do {
+					// Consume token
+					context.nextToken();
+					
+					// Read next token, which should be an identifier
+					t = context.lookahead(0);
+				
+					if (t.getType() == TokenType.Identifier) {
+						String main=null;
+						String binding=null;
+						
+						// Consume token
+						context.nextToken();
+					
+						main = t.getText();
+						
+						t = context.lookahead(0);
+						
+						if (t.isToken("for", TokenType.Keyword)) {
+							
+							context.nextToken();
+							
+							t = context.lookahead(0);
+							
+							if (t.getType() == TokenType.Identifier) {
+								
+								context.nextToken();
+								
+								binding = t.getText();
+							} else {
+								l.error(new ModelIssue(t, java.util.PropertyResourceBundle.getBundle(
+										"org.scribble.parser.Messages").
+											getString("_EXPECTING_IDENTIFIER")));
+								f_error = true;
+							}
+						} else {
+							l.error(new ModelIssue(t,
+									org.scribble.util.MessageUtil.format(
+											java.util.PropertyResourceBundle.getBundle(
+													"org.scribble.parser.Messages"),
+											"_EXPECTING_KEYWORD",
+											new String[]{"for"})));
+							f_error = true;
+						}
+						
+						if (main != null && binding != null) {
+							ref.getNameMapping().put(binding, main);
+						}
+					} else {
+						l.error(new ModelIssue(t, java.util.PropertyResourceBundle.getBundle(
+							"org.scribble.parser.Messages").
+							getString("_EXPECTING_IDENTIFIER")));
+						f_error = true;
+					}
+					
+					t = context.lookahead(0);
+				
+				} while (f_error == false &&
+						t.isToken(ParserConstants.LIST_SEPARATOR,
+								TokenType.Symbol));			
+				
+				if (t.isToken(")", TokenType.Symbol)) {
+					
+					ref.getSource().setEndPosition(t.getSource().getEndPosition());
+					
+					context.nextToken();
+				} else {
+					l.error(new ModelIssue(t, java.util.PropertyResourceBundle.getBundle(
+							"org.scribble.parser.Messages").
+							getString("_EXPECTING_PARAMETER_LIST_DELIMITER")));
+				}
+			}
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/DefaultKeyWordProvider.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/DefaultKeyWordProvider.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/DefaultKeyWordProvider.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 17 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.parser;
+
+/**
+ * This class provides a default implementation of the keyword provider. Derived
+ * classes can supply the list of keywords appropriate for the notation they
+ * represent.
+ */
+public class DefaultKeyWordProvider implements org.scribble.parser.KeyWordProvider {
+
+	/**
+	 * This is the constructor for the default keyword provider. This
+	 * construct is supplied the list of keywords it represents.
+	 * 
+	 * @param keywords The list of keywords
+	 */
+	public DefaultKeyWordProvider(String[] keywords) {
+		m_keywords = keywords;
+	}
+	
+	/**
+	 * This method returns the list of keywords.
+	 * 
+	 * @return The list of keywords
+	 */
+	public String[] getKeyWords() {
+		return(m_keywords);
+	}
+
+	/**
+	 * This method determines whether the supplied value is
+	 * a keyword.
+	 * 
+	 * @return Whether the supplied word is a keyword
+	 */
+	public boolean isKeyWord(String keyword) {
+		boolean ret=false;
+		
+		for (int i=0; ret == false && i < m_keywords.length; i++) {
+			if (keyword.equals(m_keywords[i])) {
+				ret = true;
+			}
+		}
+		
+		return(ret);
+	}
+	
+	private String[] m_keywords=null;
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/DefaultParser.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/DefaultParser.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/DefaultParser.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 18 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.parser;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.model.admin.Context;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class represents a default parser, for use
+ * with a range of Scribble notations.
+ *
+ */
+ at RegistryInfo(extension=Parser.class,isService=true)
+public class DefaultParser implements Parser {
+
+	/**
+	 * This is the constructor for the default parser.
+	 * 
+	 */
+	public DefaultParser() {
+	}
+	
+	/**
+	 * This method parses the source located using the supplied
+	 * scribble reference, to return a typed model. If any
+	 * errors are detected, they will be reported to the parser
+	 * listener.
+	 * 
+	 */
+	public Model parse(ModelReference ref, java.io.InputStream is,
+								ModelListener l, Context context) {
+		Model ret=null;
+		
+		Tokenizer tokenizer=(Tokenizer)
+					org.scribble.extensions.RegistryFactory.getRegistry().
+						getExtension(Tokenizer.class, ref.getNotation());
+
+		DefaultParserContext parserContext=
+				new DefaultParserContext(ref, is, tokenizer, context);
+		
+		ret = (Model)parserContext.parse(Model.class, l);
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/DefaultParserContext.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/DefaultParserContext.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/DefaultParserContext.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,450 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 21 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.parser;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.Context;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.util.Scope;
+
+/**
+ * This class provides the default implementation of the parser
+ * context.
+ */
+class DefaultParserContext implements ParserContext {
+
+	/**
+	 * This is the constructor for the default parser context.
+	 * 
+	 * @param ref The model reference
+	 * @param is The input stream
+	 * @param tokenizer The optional tokenizer to use
+	 * @param context The environment context
+	 */
+	public DefaultParserContext(ModelReference ref, java.io.InputStream is,
+						Tokenizer tokenizer, Context context) {
+		m_modelReference = ref;
+		m_environmentContext = context;
+		
+		initializeScope(m_scope);
+		
+		initialize(is, tokenizer);
+	}
+	
+	/**
+	 * This method initializes the tokens from the supplied input stream.
+	 * 
+	 * @param is The input stream
+	 * @param tokenizer The optional tokenizer to use
+	 */
+	protected void initialize(java.io.InputStream is, Tokenizer tokenizer) {
+		
+		// Initialize the tokens
+		if (tokenizer == null) {
+			tokenizer = (Tokenizer)
+					org.scribble.extensions.RegistryFactory.getRegistry().
+							getExtension(Tokenizer.class, getNotation());
+		}
+		
+		if (tokenizer != null) {
+			try {
+				m_tokens = tokenizer.getTokens(getSource(), is);
+			} catch(Exception e) {
+				logger.log(Level.SEVERE, "Failed to get tokens: "+e, e);
+			}
+		} else {
+			logger.severe("Failed to get tokenizer");
+		}
+	}
+		
+	/**
+	 * This method returns the notation.
+	 * 
+	 * @return The notation
+	 */
+	protected String getNotation() {
+		return(m_modelReference.getNotation());
+	}
+	
+	/**
+	 * This method provides the environment's context.
+	 * 
+	 * @return The environment context
+	 */
+	public Context getEnvironmentContext() {
+		return(m_environmentContext);
+	}
+	
+	/**
+	 * This method returns the source model reference associated
+	 * with the definition being parsed.
+	 * 
+	 * @return The model reference
+	 */
+	public ModelReference getSource() {
+		return(m_modelReference);
+	}
+	
+	/**
+	 * This method retrieves the contents of the resource at the 
+	 * specified URI. If the URI is relative, then the path will
+	 * be considered relative to the resource associated with
+	 * the source model reference.
+	 * 
+	 * @param uri The URI
+	 * @return The input stream, or null if not found
+	 */
+	public java.io.InputStream getResource(String uri) {
+		return(m_environmentContext.getResource(getSource(), uri));
+	}
+
+	/**
+	 * This method returns the located role associated with the
+	 * current scope.
+	 * 
+	 * @return The located role
+	 */
+	public String getLocatedRole() {
+		return(m_scope.getLocatedRole());
+	}
+	
+	/**
+	 * This method sets the located role associated with the
+	 * current scope.
+	 * 
+	 * @param located The located role
+	 */
+	public void setLocatedRole(String located) {
+		m_scope.setLocatedRole(located);
+	}
+	
+	/**
+	 * This method returns whether there are more tokens
+	 * available.
+	 * 
+	 * @return Whether more tokens are available
+	 */
+	public boolean moreTokens() {
+		return(m_tokens == null ? false : m_position < m_tokens.size());
+	}
+	
+	/**
+	 * This method returns the number of tokens.
+	 * 
+	 * @return The number of tokens
+	 */
+	protected int getTokenCount() {
+		return(m_tokens == null ? 0 : m_tokens.size());
+	}
+
+	/**
+	 * This method returns the next available token.
+	 * 
+	 * @return The next token
+	 */
+	public Token nextToken() {
+		Token ret=null;
+		
+		if (m_tokens != null && m_position < m_tokens.size()) {
+			ret = m_tokens.get(m_position++);
+		}
+
+		logger.fine("Consume: "+ret);
+		
+		if (ret == null) {
+			ret = new Token("", TokenType.EndOfFile, 0, 0);
+		}
+
+		return(ret);
+	}
+
+	/**
+	 * This method peeks a specified number of tokens ahead.
+	 * 
+	 * @param num The number of lookahead
+	 * @return The token
+	 */
+	public Token lookahead(int num) {
+		Token ret=null;
+		
+		if (m_tokens != null && (m_position+num) < m_tokens.size()) {
+			ret = m_tokens.get(m_position+num);
+		}
+		
+		if (ret == null) {
+			ret = new Token("", TokenType.EndOfFile, 0, 0);
+		}
+
+		return(ret);
+	}
+	
+	/**
+	 * This method parses the description to determine if a
+	 * model object associated with the supplied type can be
+	 * 
+	 * @param modelType The model type
+	 * @param l The model listener
+	 * @return The model object, or null if not found
+	 */
+	public Object parse(Class<?> modelType, ModelListener l) {
+		Object ret=null;
+		
+		// Look up parser rules appropriate for this model type
+		java.util.List<Object> allrules=
+				org.scribble.extensions.RegistryFactory.getRegistry().
+							getExtensions(ParserRule.class, getNotation());
+	
+		if (allrules != null) {
+			java.util.List<ParserRule> rules=new java.util.Vector<ParserRule>();
+		
+			for (int i=0; i < allrules.size(); i++) {
+				ParserRule rule=(ParserRule)allrules.get(i);
+				
+				if (rule.isSupported(modelType)) {
+					rules.add(rule);
+				}
+			}
+			
+			if (rules.size() > 0) {
+				ret = parseUsingRules(rules, l);
+			}
+		}
+		
+		// Retain imports
+		if (ret instanceof Import) {
+			m_imports.add((Import)ret);
+		}
+		
+		return(ret);
+	}
+
+	/**
+	 * This method parses the current tokens against the list of
+	 * rules, to identify an appropriate rule.
+	 * 
+	 * @param rules The list of possible rules
+	 * @param l The model listener
+	 * @return The model object, or null if no rules matched the
+	 * 						current tokens
+	 */
+	protected Object parseUsingRules(java.util.List<ParserRule> rules,
+										ModelListener l) {
+		Object ret=null;
+		int checkPoint=getPosition();
+		
+		m_errorReported = false;
+
+		if (rules != null) {
+			for (int i=0; m_errorReported == false &&
+					ret == null && i < rules.size(); i++) {
+				ParserRule rule=(ParserRule)rules.get(i);
+				
+				ret = rule.parse(this, l);
+				
+				if (ret != null) {
+					// Check that terminator appropriate for rule
+					// was specified
+					if (rule.getType() == ParserRuleType.Line) {
+						Token terminator=nextToken();
+						
+						if (m_errorReported == false &&
+								terminator.getType() != TokenType.EndOfLine) {
+								//terminator.isToken(ParserConstants.LINE_TERMINATOR,
+								//		TokenType.Symbol) == false) {
+							l.error(new ModelIssue(terminator, "Expecting terminator '"+
+									ParserConstants.LINE_TERMINATOR+"'"));
+							
+							do {
+								terminator = nextToken();
+							//} while (terminator.isToken(ParserConstants.LINE_TERMINATOR,
+							//			TokenType.Symbol) == false &&
+							} while (terminator.getType() != TokenType.EndOfLine &&
+									terminator.getType() != TokenType.EndOfFile);							
+						}
+					} else if (rule.getType() == ParserRuleType.Group) {
+						Token terminator=lookahead(-1);
+						
+						if (m_errorReported == false &&
+								terminator.getType() != TokenType.EndOfBlock) {
+								//terminator.isToken(ParserConstants.BLOCK_END,
+								//			TokenType.Symbol) == false) {
+							l.error(new ModelIssue(terminator, "Expecting terminator '"+
+									ParserConstants.BLOCK_END+"'"));
+
+							do {
+								terminator = nextToken();
+							} while (//terminator.isToken(ParserConstants.BLOCK_END,
+										//	TokenType.Symbol) == false &&
+									terminator.getType() != TokenType.EndOfBlock &&
+									terminator.getType() != TokenType.EndOfFile);
+						}
+					}
+				}
+				
+				if (ret == null) {
+					// Reset position
+					resetPosition(checkPoint);
+				}
+			}
+		}
+		
+		return(ret);
+	}
+
+	/**
+	 * This method resets the token position.
+	 * 
+	 * @param position The position
+	 */
+	protected void resetPosition(int position) {
+		m_position = position;
+	}
+	
+	/**
+	 * This method returns the current token position.
+	 * 
+	 * @return The position
+	 */
+	protected int getPosition() {
+		return(m_position);
+	}
+	
+	/**
+	 * This method returns the named state from the current
+	 * scope.
+	 * 
+	 * @param name The state name
+	 * @return The state value, or null if not found
+	 */
+	public Object getState(String name) {
+		return(m_scope.getState(name));
+	}
+	
+	/**
+	 * This method sets the value associated with the supplied
+	 * name in the current state scope.
+	 * 
+	 * @param name The state name
+	 * @param value The state value
+	 */
+	public void setState(String name, Object value) {
+		m_scope.setState(name, value);
+	}
+
+	/**
+	 * This method pushes the current state onto a stack.
+	 */
+	public void pushState() {
+		m_scope.pushState();
+	}
+	
+	/**
+	 * This method pops the current state from the stack.
+	 */
+	public void popState() {
+		m_scope.popState();
+	}
+		
+	/**
+	 * This method pushes the current scope onto a stack.
+	 */
+	public void pushScope() {
+		m_scopeStack.add(0, m_scope);
+		m_scope = new Scope();
+		
+		initializeScope(m_scope);
+	}
+	
+	protected void initializeScope(Scope scope) {
+		// Add unresolved references property
+		scope.getProperties().put(UNRESOLVED_REFERENCES,
+				new java.util.Vector<ModelReference>());
+	}
+	
+	/**
+	 * This method pops the current scope from the stack.
+	 */
+	public void popScope() {
+		if (m_scopeStack.size() > 0) {
+			java.util.List<ModelReference> oldUnresolved=
+				(java.util.List<ModelReference>)
+				m_scope.getProperties().get(UNRESOLVED_REFERENCES);
+			
+			m_scope = m_scopeStack.remove(0);
+			
+			java.util.List<ModelReference> newUnresolved=
+				(java.util.List<ModelReference>)
+				m_scope.getProperties().get(UNRESOLVED_REFERENCES);
+			
+			// Transfer the unresolved references from the
+			// sub-scope to the parent scope
+			newUnresolved.addAll(oldUnresolved);
+			
+		} else {
+			logger.severe("No state entry to pop from stack");
+		}
+	}
+	
+	/**
+	 * This method determines whether the context is associated
+	 * with the outer scope.
+	 * 
+	 * @return Whether the context is for the outer scope
+	 */
+	public boolean isOuterScope() {
+		return(m_scopeStack.size() < 2);
+	}
+
+	/**
+	 * This method returns the import declarations.
+	 * 
+	 * @return The imports
+	 */
+	public java.util.List<Import> getImports() {
+		return(m_imports);
+	}
+	
+	/**
+	 * This method returns the list of unresolved references.
+	 * 
+	 * @return The list of unresolved references
+	 */
+	public java.util.List<ModelReference> getUnresolvedReferences() {
+		return((java.util.List<ModelReference>)
+				m_scope.getProperties().get(UNRESOLVED_REFERENCES));
+	}
+		
+	private static Logger logger = Logger.getLogger("org.scribble.parser");
+
+	private static final String UNRESOLVED_REFERENCES="UnresolvedReferences";
+	
+	private ModelReference m_modelReference=null;
+	private Context m_environmentContext=null;
+	private int m_position=0;
+	private java.util.List<Token> m_tokens=null;
+	private boolean m_errorReported=false;
+	private Scope m_scope=new Scope();
+	private java.util.List<Scope> m_scopeStack=new java.util.Vector<Scope>();
+	private java.util.List<Import> m_imports=new java.util.Vector<Import>();
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/DefaultTokenizer.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/DefaultTokenizer.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/DefaultTokenizer.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,191 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 6 May 2009 : Initial version created by gary
+ */
+package org.scribble.parser;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.ModelReference;
+
+/**
+ * This is the text based implementation of the tokenizer
+ * interface.
+ */
+ at RegistryInfo(extension=Tokenizer.class)
+public class DefaultTokenizer implements Tokenizer {
+
+	/**
+	 * The default constructor.
+	 */
+	public DefaultTokenizer() {
+	}
+	
+	/**
+	 * This method obtains a list of tokens based on the
+	 * contents of the input stream.
+	 * 
+	 * @param ref The model reference for the input source
+	 * @param is The input stream
+	 * @return The list of tokens
+	 * @throws java.io.IOException Failed to derive 
+	 */
+	public java.util.List<Token> getTokens(ModelReference ref,
+			java.io.InputStream is)	throws java.io.IOException {
+		java.util.List<Token> ret=new java.util.Vector<Token>();
+		
+		java.util.List<Object> kwproviders=org.scribble.extensions.RegistryFactory.
+				getRegistry().getExtensions(KeyWordProvider.class, ref.getNotation());
+
+		try {
+			byte[] b=new byte[is.available()];
+			is.read(b);
+			
+			String text=new String(b);
+			
+			// Initialize the tokens
+			java.util.StringTokenizer st=new java.util.StringTokenizer(text,
+					" {}:;,.&|-+=()@'\"\r\n\t", true);
+			int pos=0;
+			
+			while (st.hasMoreTokens()) {
+				String token=st.nextToken();
+				int newpos=text.indexOf(token, pos);
+							
+				if (token.length() == 1 &&
+						Character.isWhitespace(token.charAt(0))) {
+					// Ignore
+				} else if (isKeyWord(kwproviders, token)) {
+					ret.add(new Token(token, TokenType.Keyword,
+							newpos, newpos+token.length()));
+					
+					if (newpos >= 0) {
+						pos = newpos+token.length();
+					}
+					
+				} else if (token.startsWith("//")) {
+					do {
+						token = st.nextToken();
+						
+					} while (st.hasMoreTokens() &&
+							token.equals("\n") == false &&
+							token.equals("\r") == false);
+					
+				} else if (token.equals(ParserConstants.BLOCK_START)) {
+	
+					ret.add(new Token(token, TokenType.StartOfBlock,
+							newpos, newpos+token.length()));
+	
+					if (newpos >= 0) {
+						pos = newpos+token.length();
+					}
+				} else if (token.equals(ParserConstants.LINE_TERMINATOR)) {
+	
+					ret.add(new Token(token, TokenType.EndOfLine,
+							newpos, newpos+token.length()));
+	
+					if (newpos >= 0) {
+						pos = newpos+token.length();
+					}
+				} else if (token.equals(ParserConstants.BLOCK_END)) {
+	
+					ret.add(new Token(token, TokenType.EndOfBlock,
+							newpos, newpos+token.length()));
+	
+					if (newpos >= 0) {
+						pos = newpos+token.length();
+					}
+				} else if (token.startsWith("\"")) {
+					
+					do {
+						token = st.nextToken();
+						
+					} while (st.hasMoreTokens() &&
+							token.equals("\"") == false &&
+							token.equals("\n") == false &&
+							token.equals("\r") == false);
+	
+					int endpos=text.indexOf('\"', newpos+1);
+					int tmppos=text.indexOf('\r', newpos);
+					
+					if (endpos == -1 || (tmppos != -1 && tmppos < endpos)) {
+						endpos = tmppos;
+					}
+					
+					tmppos=text.indexOf('\n', newpos);
+					
+					if (endpos == -1 || (tmppos != -1 && tmppos < endpos)) {
+						endpos = tmppos;
+					}
+					
+					ret.add(new Token(text.substring(newpos+1, endpos),
+							TokenType.StringLiteral, newpos,
+							endpos));
+					
+					if (endpos != -1) {
+						pos = endpos+1;
+					}
+									
+				} else if (token.length() == 1 &&
+						" ,.:&|-+*/=()@'".indexOf(token) != -1) {
+	
+					ret.add(new Token(token, TokenType.Symbol,
+							newpos, newpos+token.length()));
+	
+					if (newpos >= 0) {
+						pos = newpos+token.length();
+					}
+				} else {
+	
+					ret.add(new Token(token, TokenType.Identifier,
+							newpos, newpos+token.length()));
+	
+					if (newpos >= 0) {
+						pos = newpos+token.length();
+					}
+				}
+			}
+		} catch(Exception e) {
+			e.printStackTrace();
+		}
+		
+		return(ret);
+	}
+
+	/**
+	 * This method determines whether the supplied text is a keyword.
+	 * 
+	 * @param providers The list of keyword providers
+	 * @param keyword The text
+	 * @return Whether the text is a keyword
+	 */
+	protected boolean isKeyWord(java.util.List<Object> providers,
+						String keyword) {
+		boolean ret=false;
+		
+		if (providers != null) {
+			for (int i=0; ret == false &&
+					i < providers.size(); i++) {
+				KeyWordProvider provider=(KeyWordProvider)providers.get(i);
+				
+				ret = provider.isKeyWord(keyword);
+			}
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/ImportParserRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/ImportParserRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/ImportParserRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,140 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 2 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.parser;
+
+import org.scribble.extensions.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class provides the parser rule for the Import statement.
+ */
+ at RegistryInfo(extension=ParserRule.class)
+public class ImportParserRule extends AbstractParserRule {
+
+	/**
+	 * This is the default constructor.
+	 */
+	public ImportParserRule() {
+		super(ParserRuleType.Line);
+	}
+	
+	/**
+	 * This method determines whether the parser rules is
+	 * appropriate to return a model object of the required
+	 * type.
+	 * 
+	 * @param type The required type
+	 * @return Whether the parser rule returns a
+	 * 				model object of the required type
+	 */
+	public boolean isSupported(Class<?> type) {
+		return(type.isAssignableFrom(Import.class));
+	}
+
+	/**
+	 * This method parses the description to obtain
+	 * a model object of the appropriate type.
+	 * 
+	 * @param context The context
+	 * @param l The listener
+	 * @return The model object
+	 */
+	public Object parse(ParserContext context, ModelListener l) {
+		Import ret=null;
+		
+		Token t=context.lookahead(0);
+		
+		if (t.isToken("import", TokenType.Keyword)) {
+			ret = new Import();
+			
+			ret.getSource().setStartPosition(t.getSource().getStartPosition());
+			
+			// Consume token
+			context.nextToken();
+			
+			t = context.lookahead(0);
+			
+			String fqname="";
+			boolean f_end=false;
+			
+			do {
+				if (t.getType() == TokenType.Identifier) {
+					Token id=context.nextToken();
+					fqname += id.getText();
+				
+					t = context.lookahead(0);
+				
+					if (t.isToken(".", TokenType.Symbol)) {
+					
+						context.nextToken();
+						
+						fqname += ".";
+					
+						t = context.lookahead(0);
+					} else {
+						f_end = true;
+					}
+				} else if (t.isToken("*", TokenType.Symbol)) {
+					
+					context.nextToken();
+					
+					fqname += "*";
+					
+					f_end = true;
+				} else {
+					
+					l.error(new ModelIssue(t, java.util.PropertyResourceBundle.getBundle(
+							"org.scribble.parser.Messages").
+								getString("_EXPECTING_IDENTIFIER")));
+					
+					f_end = true;
+				}
+			} while (f_end == false);
+			
+			if (fqname.length() > 0) {
+				ret.setName(fqname);
+			}
+			
+			if (t.isToken("as", TokenType.Keyword)) {
+				context.nextToken();
+				
+				t = context.lookahead(0);
+				
+				if (t.getType() == TokenType.Identifier) {
+					
+					context.nextToken();
+					
+					ret.setAlias(t.getText());
+				} else {
+					l.error(new ModelIssue(t, java.util.PropertyResourceBundle.getBundle(
+							"org.scribble.parser.Messages").
+							getString("_EXPECTING_IDENTIFIER")));
+				}
+			}
+			
+			ret.getSource().setEndPosition(t.getSource().getEndPosition());
+		}
+		
+		return(ret);
+	}
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/InteractionParserRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/InteractionParserRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/InteractionParserRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,292 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 24 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.parser;
+
+import org.scribble.extensions.*;
+import org.scribble.model.Channel;
+import org.scribble.model.Interaction;
+import org.scribble.model.MessageSignature;
+import org.scribble.model.Role;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class provides the parser rule for the Interaction.
+ * 
+ */
+ at RegistryInfo(extension=ParserRule.class) //,category=Interaction.class)
+public class InteractionParserRule extends org.scribble.parser.AbstractParserRule {
+
+	/**
+	 * The default constructor.
+	 */
+	public InteractionParserRule() {
+		super(ParserRuleType.Line);
+	}
+	
+	/**
+	 * This method determines whether the parser rules is
+	 * appropriate to return a model object of the required
+	 * type.
+	 * 
+	 * @param type The required type
+	 * @return Whether the parser rule returns a
+	 * 				model object of the required type
+	 */
+	public boolean isSupported(Class<?> type) {
+		return(type.isAssignableFrom(Interaction.class));
+	}
+	
+	/**
+	 * This method creates a new interaction instance.
+	 * 
+	 * @return The interaction instance
+	 */
+	protected Interaction createInteraction() {
+		return(new Interaction());
+	}
+
+	/**
+	 * This method parses the description to obtain
+	 * a model object of the appropriate type.
+	 * 
+	 * @param context The context
+	 * @param l The listener
+	 * @return The model object
+	 */
+	public Object parse(ParserContext context, ModelListener l) {
+		Interaction ret=null;
+		boolean f_processed=false;
+		int firstpos=0;
+		int lastpos=0;
+		MessageSignature sig=null;
+		
+		do {
+			f_processed = false;
+			
+			Token t=context.lookahead(0);
+			
+			if (firstpos == 0) {
+				firstpos = t.getSource().getStartPosition();
+			}
+			
+			lastpos = t.getSource().getEndPosition();
+
+			// TODO: Need to determine if the identifier is a channel
+			// or an operation name or type in a type based message signature
+			if (t.getType() == TokenType.Identifier) {
+							
+				// Only check for message signature if it has
+				// not already been found
+				if (sig == null) {
+					sig = (MessageSignature)
+							context.parse(MessageSignature.class, l);
+					
+					if (sig != null) {					
+						f_processed = true;
+						
+						// If signature has more than just one type, then
+						// could assume this is an interaction
+						if (ret == null && (sig.getTypes().size() > 1 ||
+								sig.getOperation() != null)) {
+							ret = createInteraction();
+						}
+					}
+				}
+			} else if (t.getType() == TokenType.Keyword) {
+				Interaction before=ret;
+				
+				if (ret == null) {
+					ret = createInteraction();
+				}
+				
+				if ((f_processed = parseKeyword(t.getText(), ret,
+							context, l)) == false) {
+					
+					// Reset the return value if the keyword is
+					// not processed
+					ret = before;
+				}
+			}
+		} while(f_processed);
+		
+		if (ret != null) {
+			ret.getSource().setStartPosition(firstpos);
+			ret.getSource().setEndPosition(lastpos);
+			
+			// Associate message signature (which may be null)
+			ret.setMessageSignature(sig);
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method parses the set of tokens associated with an interaction
+	 * based on the supplied keyword.
+	 * 
+	 * @param keyword The keyword
+	 * @param interaction The interaction being constructed
+	 * @param context The context
+	 * @param l The model listener
+	 * @return Whether the supplied keyword was processed
+	 */
+	protected boolean parseKeyword(String keyword, Interaction interaction,
+					ParserContext context, ModelListener l) {
+		boolean f_processed=false;
+		
+		if (keyword.equals("via")) {
+
+			// Consume
+			context.nextToken();
+			
+			Token channelName=context.nextToken();
+			
+			Object channel=context.getState(channelName.getText());
+			
+			if (channel == null) {
+				l.error(new ModelIssue(channelName,
+						org.scribble.util.MessageUtil.format(
+								java.util.PropertyResourceBundle.getBundle(
+										"org.scribble.parser.Messages"),
+								"_UNKNOWN_CHANNEL",
+								new String[]{channelName.getText()})));
+			} else if (channel instanceof Channel) {
+				Channel c=new Channel();
+				c.setName(channelName.getText());
+				
+				c.derivedFrom(channelName);
+				
+				interaction.setChannel(c);
+			} else {
+				l.error(new ModelIssue(channelName,
+						org.scribble.util.MessageUtil.format(
+								java.util.PropertyResourceBundle.getBundle(
+										"org.scribble.parser.Messages"),
+								"_REQUIRED_CHANNEL",
+								new String[]{channelName.getText()})));
+			}
+			
+			f_processed = true;
+
+		} else if (keyword.equals("from")) {
+						
+			// Consume
+			context.nextToken();
+			
+			Token role=context.nextToken();
+			
+			if (role.getType() == TokenType.Identifier) {
+				
+				// Locate the role definition
+				Object part=context.getState(role.getText());
+				
+				if (part == null) {
+					l.error(new ModelIssue(role,
+							org.scribble.util.MessageUtil.format(
+									java.util.PropertyResourceBundle.getBundle(
+											"org.scribble.parser.Messages"),
+									"_UNKNOWN_ROLE",
+									new String[]{role.getText()})));
+				} else if (part instanceof Role) {					
+					Role r=new Role();
+					r.setName(role.getText());
+					
+					r.derivedFrom(role);
+					
+					interaction.setFromRole(r);
+				} else {
+					l.error(new ModelIssue(role,
+							org.scribble.util.MessageUtil.format(
+									java.util.PropertyResourceBundle.getBundle(
+											"org.scribble.parser.Messages"),
+									"_REQUIRED_ROLE",
+									new String[]{role.getText()})));
+				}
+				
+				f_processed = true;
+			}
+		} else if (keyword.equals("to")) {
+						
+			// Consume
+			context.nextToken();
+			
+			Token role=context.nextToken();
+			
+			if (role.getType() == TokenType.Identifier) {
+				
+				// Locate the role definition
+				Object part=context.getState(role.getText());
+				
+				if (part == null) {
+					l.error(new ModelIssue(role,
+							org.scribble.util.MessageUtil.format(
+									java.util.PropertyResourceBundle.getBundle(
+											"org.scribble.parser.Messages"),
+									"_UNKNOWN_ROLE",
+									new String[]{role.getText()})));
+				} else if (part instanceof Role) {
+					Role r=new Role();
+					r.setName(role.getText());
+					
+					r.derivedFrom(role);
+					
+					interaction.setToRole(r);
+				} else {
+					l.error(new ModelIssue(role,
+							org.scribble.util.MessageUtil.format(
+									java.util.PropertyResourceBundle.getBundle(
+											"org.scribble.parser.Messages"),
+									"_REQUIRED_ROLE",
+									new String[]{role.getText()})));
+				}
+				
+				f_processed = true;
+			}
+		} else if (keyword.equals("request")) {
+			
+			// Consume
+			context.nextToken();
+			
+			Token label=context.lookahead(0);
+			
+			if (label.getType() == TokenType.StringLiteral) {
+				interaction.setRequestLabel(label.getText());
+				
+				context.nextToken();
+			}
+				
+		} else if (keyword.equals("replyTo")) {
+			
+			// Consume
+			context.nextToken();
+			
+			Token label=context.lookahead(0);
+			
+			if (label.getType() == TokenType.StringLiteral) {
+				interaction.setReplyToLabel(label.getText());
+				
+				context.nextToken();
+			}
+		}
+		
+		return(f_processed);
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/KeyWordProvider.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/KeyWordProvider.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/KeyWordProvider.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 17 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.parser;
+
+/**
+ * This interface represents a keyword provider associated with a
+ * particular notation. The keyword provider is responsible for returning
+ * information about the valid keywords associated with a particular
+ * Scribble notation.
+ */
+public interface KeyWordProvider {
+
+	/**
+	 * This method returns the list of keywords.
+	 * 
+	 * @return The list of keywords
+	 */
+	public String[] getKeyWords();
+	
+	/**
+	 * This method determines whether the supplied value is
+	 * a keyword.
+	 * 
+	 * @return Whether the supplied word is a keyword
+	 */
+	public boolean isKeyWord(String keyword);
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/MessageSignatureParserRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/MessageSignatureParserRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/MessageSignatureParserRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 24 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.parser;
+
+import org.scribble.extensions.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class provides the parser rule for the Message Signature.
+ * 
+ */
+ at RegistryInfo(extension=ParserRule.class)
+public class MessageSignatureParserRule extends org.scribble.parser.AbstractParserRule {
+
+	/**
+	 * The default constructor.
+	 */
+	public MessageSignatureParserRule() {
+		super(ParserRuleType.Clause);
+	}
+	
+	/**
+	 * This method determines whether the parser rules is
+	 * appropriate to return a model object of the required
+	 * type.
+	 * 
+	 * @param type The required type
+	 * @return Whether the parser rule returns a
+	 * 				model object of the required type
+	 */
+	public boolean isSupported(Class<?> type) {
+		return(type.isAssignableFrom(MessageSignature.class));
+	}
+
+	/**
+	 * This method parses the description to obtain
+	 * a model object of the appropriate type.
+	 * 
+	 * @param context The context
+	 * @param l The listener
+	 * @return The model object
+	 */
+	public Object parse(ParserContext context, ModelListener l) {
+		MessageSignature ret=null;
+		
+		Token t = context.lookahead(0);
+
+		TypeReference ref=(TypeReference)context.parse(TypeReference.class, l);
+		
+		if (ref != null) {
+			// GPB: TO REMOVE resolveReference(context, l, ref, DependencyType.Uses);
+
+			ret = new MessageSignature();
+			
+			String text=ref.getAlias();
+			
+			// Check next token before determining whether
+			// this is a message type or operation
+			t = context.lookahead(0);
+			
+			if (t.isToken("(", TokenType.Symbol)) {
+				// Consume '('
+				context.nextToken();
+				
+				ret.setOperation(text);
+				
+				boolean f_end=false;
+				do {
+					ref = (TypeReference)context.parse(TypeReference.class, l);
+					
+					//if (t.getType() == TokenType.Identifier) {
+					if (ref != null) {
+						// GPB: TO REMOVE resolveReference(context, l, ref, DependencyType.Uses);
+
+						ret.getTypes().add(ref);
+						
+						t = context.nextToken();
+						
+						if (t.isToken(",", TokenType.Symbol) == false &&
+								t.isToken(")", TokenType.Symbol) == false) {
+							
+							l.error(new ModelIssue(t, java.util.PropertyResourceBundle.getBundle(
+									"org.scribble.parser.Messages").
+									getString("_EXPECTING_PARAMETER_LIST_DELIMITER")));
+							f_end = true;
+						}
+					} else {
+						l.error(new ModelIssue(t, java.util.PropertyResourceBundle.getBundle(
+							"org.scribble.parser.Messages").
+							getString("_EXPECTING_TYPE")));
+						f_end = true;
+					}
+					
+					if (t.getType() == TokenType.EndOfFile ||
+								t.isToken(")", TokenType.Symbol)) {
+						f_end = true;
+					}
+				} while (f_end == false);
+				
+			} else {
+				ret.getTypes().add(ref);
+			}
+		} else {
+			l.error(new ModelIssue(t, java.util.PropertyResourceBundle.getBundle(
+					"org.scribble.parser.Messages").
+					getString("_EXPECTING_IDENTIFIER")));
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/Messages.properties
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/Messages.properties	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/Messages.properties	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,38 @@
+# /*
+# * Copyright 2007 Pi4 Technologies Ltd
+# *
+# * 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.
+# *
+# *
+# * Change History:
+# * 28 Oct 2007 : Initial version created by gary
+# */
+
+_DUPLICATE_DECLARATION=Name '{0}' has already been declared
+_EXISTING_DECLARATION=Duplicate declaration name '{0}'
+_EXPECTING_ACTIVITY=Expecting an activity, but found '{0}'
+_EXPECTING_CHANNEL_NAME=Expecting channel name
+_EXPECTING_IDENTIFIER=Expecting an identifier
+_EXPECTING_KEYWORD=Expecting keyword '{0}'
+_EXPECTING_LOCATED_REFERENCE=Expecting a located reference
+_EXPECTING_PARAMETER_LIST_DELIMITER=Expecting either ',' or ')'
+_EXPECTING_ROLE_NAME=Expecting role name
+_EXPECTING_SYMBOL=Expecting symbol '{0}'
+_EXPECTING_TYPE=Expecting type
+_INCOMPATIBLE_NAME=Name is incompatible with file name
+_REQUIRED_CHANNEL=Must specify a channel '{0}'
+_REQUIRED_DECLARATION=Must specify a declaration '{0}'
+_REQUIRED_ROLE=Must specify a role '{0}'
+_UNKNOWN_CHANNEL=Unknown channel '{0}'
+_UNKNOWN_DECLARATION=Unknown declaration '{0}'
+_UNKNOWN_ROLE=Unknown role '{0}'

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/ModelNameParserRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/ModelNameParserRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/ModelNameParserRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,115 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 24 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.parser;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class provides the parser rule for the Model Name.
+ */
+ at RegistryInfo(extension=ParserRule.class)
+public class ModelNameParserRule extends AbstractParserRule {
+
+	/**
+	 * This is the default constructor.
+	 */
+	public ModelNameParserRule() {
+		super(ParserRuleType.Clause);
+	}
+	
+	/**
+	 * This method determines whether the parser rules is
+	 * appropriate to return a model object of the required
+	 * type.
+	 * 
+	 * @param type The required type
+	 * @return Whether the parser rule returns a
+	 * 				model object of the required type
+	 */
+	public boolean isSupported(Class<?> type) {
+		return(type.isAssignableFrom(LocatedName.class));
+	}
+
+	/**
+	 * This method parses the description to obtain
+	 * a model object of the appropriate type.
+	 * 
+	 * @param context The context
+	 * @param l The listener
+	 * @return The model object
+	 */
+	public Object parse(ParserContext context, ModelListener l) {
+		LocatedName ret=null;
+		
+		Token t=context.lookahead(0);
+		
+		if (t.getType() == TokenType.Identifier) {
+			int startpos=t.getSource().getStartPosition();
+			int endpos=t.getSource().getEndPosition();
+			
+			context.nextToken();
+			
+			ret = new LocatedName();
+			
+			ret.setName(t.getText());
+			
+			// Check if name could be located
+			t = context.lookahead(0);
+			
+			if (t.isToken(ModelReference.LOCATED_REFERENCE_SEPARATOR,
+									TokenType.Symbol)) {
+				context.nextToken();
+				
+				t = context.lookahead(0);
+				
+				if (t.getType() == TokenType.Identifier) {
+					endpos = t.getSource().getEndPosition();
+					
+					context.nextToken();
+					
+					Role p=new Role();
+					
+					p.setName(t.getText());
+					
+					p.getSource().setStartPosition(t.getSource().getStartPosition());
+					p.getSource().setEndPosition(t.getSource().getEndPosition());
+
+					ret.setRole(p);
+				} else {
+					l.error(new ModelIssue(t, java.util.PropertyResourceBundle.getBundle(
+							"org.scribble.parser.Messages").
+								getString("_EXPECTING_ROLE_NAME")));
+				}
+			}
+			
+			ret.getSource().setStartPosition(startpos);
+			ret.getSource().setEndPosition(endpos);
+		} else {
+			l.error(new ModelIssue(t, java.util.PropertyResourceBundle.getBundle(
+						"org.scribble.parser.Messages").
+						getString("_EXPECTING_IDENTIFIER")));
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/NamespaceParserRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/NamespaceParserRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/NamespaceParserRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,121 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 22 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.parser;
+
+import org.scribble.extensions.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class provides the parser rule for the Namespace.
+ */
+ at RegistryInfo(extension=ParserRule.class)
+public class NamespaceParserRule extends AbstractParserRule {
+
+	/**
+	 * This is the default constructor.
+	 */
+	public NamespaceParserRule() {
+		super(ParserRuleType.Line);
+	}
+	
+	/**
+	 * This method determines whether the parser rules is
+	 * appropriate to return a model object of the required
+	 * type.
+	 * 
+	 * @param type The required type
+	 * @return Whether the parser rule returns a
+	 * 				model object of the required type
+	 */
+	public boolean isSupported(Class<?> type) {
+		return(type.isAssignableFrom(Namespace.class));
+	}
+
+	/**
+	 * This method parses the description to obtain
+	 * a model object of the appropriate type.
+	 * 
+	 * @param context The context
+	 * @param l The listener
+	 * @return The model object
+	 */
+	public Object parse(ParserContext context, ModelListener l) {
+		Namespace ret=null;
+		
+		Token t=context.lookahead(0);
+		
+		if (t.isToken("namespace", TokenType.Keyword)) {
+			
+			ret = new Namespace();
+			ret.getSource().setStartPosition(t.getSource().getStartPosition());
+
+			// Consume token
+			context.nextToken();
+			
+			t = context.lookahead(0);
+			
+			String fqname="";
+			boolean f_end=false;
+			int endpos=t.getSource().getEndPosition();
+			
+			do {
+				if (t.getType() == TokenType.Identifier) {
+					Token id=context.nextToken();
+					fqname += id.getText();
+				
+					endpos=t.getSource().getEndPosition();
+					
+					t = context.lookahead(0);
+				
+					if (t.isToken(".", TokenType.Symbol)) {
+					
+						context.nextToken();
+						
+						endpos=t.getSource().getEndPosition();
+						
+						fqname += ".";
+					
+						t = context.lookahead(0);
+					} else {
+						f_end = true;
+					}
+				} else {
+					
+					l.error(new ModelIssue(t, java.util.PropertyResourceBundle.getBundle(
+							"org.scribble.parser.Messages").
+								getString("_EXPECTING_IDENTIFIER")));
+					
+					f_end = true;
+				}
+			} while (f_end == false);
+			
+			if (fqname.length() > 0) {
+				ret.setName(fqname);
+			}
+			
+			ret.getSource().setEndPosition(endpos);
+		}
+		
+		return(ret);
+	}
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/Parser.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/Parser.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/Parser.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 18 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.parser;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.Context;
+import org.scribble.model.admin.ModelListener;
+
+public interface Parser {
+
+	/**
+	 * This method parses the source located using the supplied
+	 * scribble reference, to return a model. If any
+	 * errors are detected, they will be reported to the parser
+	 * listener.
+	 * 
+	 * @param ref The scribble source reference
+	 * @param is The input stream
+	 * @param l The model listener
+	 * @param context The environment context
+	 * @return The model, or null if not found
+	 */
+	public Model parse(ModelReference ref, java.io.InputStream is,
+								ModelListener l, Context context);
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/ParserConstants.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/ParserConstants.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/ParserConstants.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 22 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.parser;
+
+/**
+ * This class provides the parser constants.
+ */
+public class ParserConstants {
+
+	public static final String LINE_TERMINATOR=";";
+	
+	public static final String BLOCK_START="{";
+	public static final String BLOCK_END="}";
+	
+	public static final String LIST_SEPARATOR=",";
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/ParserContext.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/ParserContext.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/ParserContext.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,157 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 21 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.parser;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.Context;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This interface provides the services required by the parser
+ * rules.
+ */
+public interface ParserContext {
+
+	/**
+	 * This method provides the environment's context.
+	 * 
+	 * @return The environment context
+	 */
+	public Context getEnvironmentContext();
+	
+	/**
+	 * This method returns the source model reference associated
+	 * with the definition being parsed.
+	 * 
+	 * @return The model reference
+	 */
+	public ModelReference getSource();
+	
+	/**
+	 * This method returns the located role associated with the
+	 * current scope.
+	 * 
+	 * @return The located role
+	 */
+	public String getLocatedRole();
+	
+	/**
+	 * This method sets the located role associated with the
+	 * current scope.
+	 * 
+	 * @param located The located role
+	 */
+	public void setLocatedRole(String located);
+	
+	/**
+	 * This method parses the description to determine if a
+	 * model object associated with the supplied type can be
+	 * found.
+	 * 
+	 * @param modelType The model type
+	 * @param l The model listener
+	 * @return The model object, or null if not found
+	 */
+	public Object parse(Class<?> modelType, ModelListener l);
+	
+	/**
+	 * This method returns the next available token.
+	 * 
+	 * @return The next token
+	 */
+	public Token nextToken();
+
+	/**
+	 * This method peeks a specified number of tokens ahead.
+	 * 
+	 * @param num The number of lookahead
+	 * @return The token
+	 */
+	public Token lookahead(int num);
+
+	/**
+	 * This method returns whether there are more tokens
+	 * available.
+	 * 
+	 * @return Whether more tokens are available
+	 */
+	public boolean moreTokens();
+	
+	/**
+	 * This method returns the named state from the current
+	 * scope.
+	 * 
+	 * @param name The state name
+	 * @return The state value, or null if not found
+	 */
+	public Object getState(String name);
+	
+	/**
+	 * This method sets the value associated with the supplied
+	 * name in the current state.
+	 * 
+	 * @param name The state name
+	 * @param value The state value
+	 */
+	public void setState(String name, Object value);
+	
+	/**
+	 * This method pushes the current state onto a stack.
+	 */
+	public void pushState();
+	
+	/**
+	 * This method pops the current state from the stack.
+	 */
+	public void popState();
+	
+	/**
+	 * This method pushes the current scope onto a stack.
+	 */
+	public void pushScope();
+	
+	/**
+	 * This method pops the current scope from the stack.
+	 */
+	public void popScope();
+	
+	/**
+	 * This method determines whether the context is associated
+	 * with the outer scope.
+	 * 
+	 * @return Whether the context is for the outer scope
+	 */
+	public boolean isOuterScope();
+	
+	/**
+	 * This method returns the import declarations.
+	 * 
+	 * @return The imports
+	 */
+	public java.util.List<Import> getImports();
+	
+	/**
+	 * This method returns the list of unresolved references.
+	 * 
+	 * @return The list of unresolved references
+	 */
+	public java.util.List<ModelReference> getUnresolvedReferences();
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/ParserRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/ParserRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/ParserRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 16 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.parser;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This interface represents a parser rule associated with
+ * a Scribble language construct.
+ */
+public interface ParserRule {
+
+	/**
+	 * This method determines whether the parser rules is
+	 * appropriate to return a model object of the required
+	 * type.
+	 * 
+	 * @param type The required type
+	 * @return Whether the parser rule returns a
+	 * 				model object of the required type
+	 */
+	public boolean isSupported(Class<?> type);
+	
+	/**
+	 * This method returns the parser rule type.
+	 * 
+	 * @return The parser rule type
+	 */
+	public ParserRuleType getType();
+	
+	/**
+	 * This method parses the description to obtain
+	 * a model object of the appropriate type.
+	 * 
+	 * @param context The context
+	 * @param l The listener
+	 * @return The model object
+	 */
+	public Object parse(ParserContext context, ModelListener l);
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/ParserRuleType.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/ParserRuleType.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/ParserRuleType.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 22 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.parser;
+
+/**
+ * Enumeration of parser rule types.
+ */
+public enum ParserRuleType {
+	Clause,
+	Line,
+	Group,
+	File
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/RoleListParserRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/RoleListParserRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/RoleListParserRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,157 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 22 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.parser;
+
+import org.scribble.extensions.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class provides the parser rule for the Role
+ * declaration.
+ */
+ at RegistryInfo(extension=ParserRule.class) //,category=RoleList.class)
+public class RoleListParserRule extends org.scribble.parser.AbstractParserRule {
+
+	/**
+	 * The default constructor.
+	 */
+	public RoleListParserRule() {
+		super(ParserRuleType.Line);
+	}
+	
+	/**
+	 * This method determines whether the parser rules is
+	 * appropriate to return a model object of the required
+	 * type.
+	 * 
+	 * @param type The required type
+	 * @return Whether the parser rule returns a
+	 * 				model object of the required type
+	 */
+	public boolean isSupported(Class<?> type) {
+		return(type.isAssignableFrom(RoleList.class));
+	}
+
+	/**
+	 * This method parses the description to obtain
+	 * a model object of the appropriate type.
+	 * 
+	 * @param context The context
+	 * @param l The listener
+	 * @return The model object
+	 */
+	public Object parse(ParserContext context, ModelListener l) {
+		RoleList ret=null;
+		
+		Token t=context.lookahead(0);
+		
+		if (t.isToken("role", TokenType.Keyword)) {
+			boolean f_error=false;
+			
+			ret = new RoleList();
+			
+			ret.getSource().setStartPosition(t.getSource().getStartPosition());
+			
+			do {
+				// Consume token
+				context.nextToken();
+				
+				// Read next token, which should be an identifier
+				t = context.lookahead(0);
+			
+				if (t.getType() == TokenType.Identifier) {
+					
+					// Consume token
+					context.nextToken();
+				
+					Role part=new Role();
+					part.getSource().setStartPosition(t.getSource().getStartPosition());
+				
+					part.setName(t.getText());
+					
+					part.getSource().setEndPosition(t.getSource().getEndPosition());
+					
+					ret.getSource().setEndPosition(t.getSource().getEndPosition());
+					
+					ret.getRoles().add(part);
+					
+					// Check if name has already been defined in state
+					if (context.getState(t.getText()) != null) {
+						l.error(new ModelIssue(t,
+								org.scribble.util.MessageUtil.format(
+										java.util.PropertyResourceBundle.getBundle(
+												"org.scribble.parser.Messages"),
+										"_DUPLICATE_DECLARATION",
+										new String[]{t.getText()})));
+					} else {
+					
+						// Add to state
+						context.setState(part.getName(), part);
+
+						// If outer definition and not a local model,
+						// then add dependency on a local model for
+						// this role
+						
+/* GPB: TO REMOVE						
+						if (context.getLocatedRole() == null &&
+								context.isOuterScope()) {
+							// Establish dependency on the reference
+							org.scribble.model.admin.DependencyManager dm=
+								(org.scribble.model.admin.DependencyManager)
+								org.scribble.extensions.RegistryFactory.getRegistry().getExtension(
+										org.scribble.model.admin.DependencyManager.class, null);
+							
+							org.scribble.model.admin.ModelRepository mrep=
+								(org.scribble.model.admin.ModelRepository)
+								RegistryFactory.getRegistry().getExtension(
+										org.scribble.model.admin.ModelRepository.class, null);
+
+							if (dm != null && mrep != null) {
+								ModelReference ref=
+									new ModelReference(context.getSource().getNamespace(),
+										context.getSource().getLocalpart(), part.getName(),
+										context.getSource().getNotation());
+								
+								mrep.locate(ref, context.getSource());
+								
+								dm.recordDependency(context.getSource(), ref,
+										DependencyType.ConformsTo);
+							}
+						}
+*/						
+					}
+					
+					t = context.lookahead(0);
+				} else {
+					l.error(new ModelIssue(t, java.util.PropertyResourceBundle.getBundle(
+						"org.scribble.parser.Messages").
+						getString("_EXPECTING_ROLE_NAME")));
+					f_error = true;
+				}
+			} while (f_error == false &&
+					t.isToken(ParserConstants.LIST_SEPARATOR,
+							TokenType.Symbol));				
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/Token.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/Token.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/Token.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,112 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 21 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.parser;
+
+/**
+ * This class represents a token found within the
+ * source description.
+ */
+public class Token extends org.scribble.model.ModelObject {
+
+	private static final long serialVersionUID = 2131683235998230790L;
+
+	/**
+	 * This is the constructor for the token.
+	 * 
+	 * @param text The text
+	 * @param type The token type
+	 * @param startPos The start position
+	 * @param endPos The end position
+	 */
+	public Token(String text, TokenType type,
+			int startPos, int endPos) {
+		super(startPos, endPos);
+		
+		m_text = text;
+		m_type = type;
+	}
+	
+	/**
+	 * This constructor initializes the token with an
+	 * object.
+	 * 
+	 * @param obj The object representing the token
+	 */
+	public Token(Object obj) {
+		m_object = obj;
+		m_type = TokenType.Object;
+	}
+	
+	/**
+	 * This method returns the text.
+	 * 
+	 * @return The text
+	 */
+	public String getText() {
+		return(m_text);
+	}
+
+	/**
+	 * This method returns the object associated with
+	 * the token.
+	 * 
+	 * @return The object
+	 */
+	public Object getObject() {
+		return(m_object);
+	}
+	
+	/**
+	 * This method returns the token type.
+	 * 
+	 * @return The token type
+	 */
+	public TokenType getType() {
+		return(m_type);
+	}
+
+	/**
+	 * This method determines whether there is a match between
+	 * the supplied text and token type.
+	 * 
+	 * @param text The text
+	 * @param type The token type
+	 * @return Whether the supplied information matches the token
+	 */
+	public boolean isToken(String text, TokenType type) {
+		boolean ret=false;
+		
+		if (type == m_type && text != null &&
+				text.equals(m_text)) {
+			ret = true;
+		}
+		
+		return(ret);
+	}
+	
+	public String toString() {
+		return("Token[text="+m_text+",type="+m_type+
+				",start="+getSource().getStartPosition()+",end="+getSource().getEndPosition()+"]");
+	}
+
+	private String m_text=null;
+	private Object m_object=null;
+	private TokenType m_type=null;
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/TokenType.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/TokenType.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/TokenType.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 21 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.parser;
+
+/**
+ * This enum represents the token type.
+ */
+public enum TokenType {
+	Identifier,
+	Keyword,
+	Symbol,
+	StartOfBlock,
+	EndOfBlock,
+	EndOfLine,
+	EndOfFile,
+	StringLiteral,
+	Object,
+	Other
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/Tokenizer.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/Tokenizer.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/Tokenizer.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 6 May 2009 : Initial version created by gary
+ */
+package org.scribble.parser;
+
+import org.scribble.model.ModelReference;
+
+/**
+ * This interface represents a component that tokenizes the
+ * contents of an input stream, to provide a list of tokens
+ * to a parser.
+ */
+public interface Tokenizer {
+
+	/**
+	 * This method obtains a list of tokens based on the
+	 * contents of the input stream.
+	 * 
+	 * @param ref The model reference for the input source
+	 * @param is The input stream
+	 * @return The list of tokens
+	 * @throws java.io.IOException Failed to derive 
+	 */
+	public java.util.List<Token> getTokens(ModelReference ref,
+			java.io.InputStream is)	throws java.io.IOException;
+
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/TypeReferenceParserRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/TypeReferenceParserRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/parser/TypeReferenceParserRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 24 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.parser;
+
+import org.scribble.extensions.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class provides the parser rule for the Type Reference.
+ */
+ at RegistryInfo(extension=ParserRule.class)
+public class TypeReferenceParserRule extends AbstractModelReferenceParserRule {
+
+	/**
+	 * This is the default constructor.
+	 */
+	public TypeReferenceParserRule() {
+		super(false);
+	}
+	
+	/**
+	 * This method returns the class associated with the
+	 * concrete model reference.
+	 * 
+	 * @return The model reference class
+	 */
+	protected Class<?> getReferenceClass() {
+		return(TypeReference.class);
+	}
+
+	/**
+	 * This method instantiates an instance of the model
+	 * reference.
+	 * 
+	 * @param context The parser context
+	 * @param l The model listener
+	 * @return The instantiated model reference
+	 */
+	protected ModelReference createReference(ParserContext context, ModelListener l) {
+		return(new TypeReference());
+	}
+
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/AbstractBlockProjectorRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/AbstractBlockProjectorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/AbstractBlockProjectorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 19 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.projector;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class provides the Block implementation of the
+ * projector rule.
+ */
+public abstract class AbstractBlockProjectorRule implements ProjectorRule {
+
+	/**
+	 * This method creates a new block of the appropriate
+	 * type.
+	 * 
+	 * @return The block
+	 */
+	protected abstract Block createBlock();
+	
+	/**
+	 * This method projects the supplied model object based on the
+	 * specified role.
+	 * 
+	 * @param model The model object
+	 * @param role The role
+	 * @param l The model listener
+	 * @return The projected model object
+	 */
+	public ModelObject project(ProjectorContext context, ModelObject model,
+					Role role, ModelListener l) {
+		Block ret=createBlock();
+		Block source=(Block)model;
+		
+		ret.derivedFrom(source);
+		
+		context.pushState();
+		
+		for (int i=0; i < source.getContents().size(); i++) {
+			Activity act=(Activity)
+					context.project(source.getContents().get(i), role,
+							l);
+			
+			if (act != null) {
+				
+				if (act instanceof Block) {
+					// Copy contents
+					ret.getContents().addAll(((Block)act).getContents());
+				} else {
+					ret.getContents().add(act);
+				}
+			}
+		}
+
+		context.popState();
+		
+		// Only return block if it contains atleast one activity
+		if (ret.getContents().size() == 0) {
+			ret = null;
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/BlockProjectorRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/BlockProjectorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/BlockProjectorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 19 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.projector;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+
+/**
+ * This class provides the Block implementation of the
+ * projector rule.
+ */
+ at RegistryInfo(extension=ProjectorRule.class)
+public class BlockProjectorRule extends AbstractBlockProjectorRule {
+
+	/**
+	 * This method determines whether the projection rule is
+	 * appropriate for the supplied model object.
+	 * 
+	 * @param obj The model object to be projected
+	 * @return Whether the rule is relevant for the
+	 * 				model object
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj.getClass() == Block.class);
+	}
+	
+	/**
+	 * This method creates a new block of the appropriate
+	 * type.
+	 * 
+	 * @return The block
+	 */
+	protected Block createBlock() {
+		return(new Block());
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/ChannelListProjectorRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/ChannelListProjectorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/ChannelListProjectorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 19 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.projector;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class provides the ChannelList implementation of the
+ * projector rule.
+ */
+ at RegistryInfo(extension=ProjectorRule.class)
+public class ChannelListProjectorRule implements ProjectorRule {
+
+	/**
+	 * This method determines whether the projection rule is
+	 * appropriate for the supplied model object.
+	 * 
+	 * @param obj The model object to be projected
+	 * @return Whether the rule is relevant for the
+	 * 				model object
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj.getClass() == ChannelList.class);
+	}
+	
+	/**
+	 * This method projects the supplied model object based on the
+	 * specified role.
+	 * 
+	 * @param model The model object
+	 * @param role The role
+	 * @param l The model listener
+	 * @return The projected model object
+	 */
+	public ModelObject project(ProjectorContext context, ModelObject model,
+					Role role, ModelListener l) {
+		ChannelList ret=new ChannelList();
+		ChannelList source=(ChannelList)model;
+		
+		for (int i=0; i < source.getChannels().size(); i++) {
+			if (source.getChannels().get(i).equals(role) == false) {
+				Channel ch=new Channel();
+				
+				ch.setName(source.getChannels().get(i).getName());
+				
+				// Add to state
+				context.setState(ch.getName(), ch);
+
+				ret.getChannels().add(ch);
+			}
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/ConformanceReferenceProjectorRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/ConformanceReferenceProjectorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/ConformanceReferenceProjectorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 18 Jun 2008 : Initial version created by gary
+ */
+package org.scribble.projector;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class provides the ConformanceReference implementation of the
+ * projector rule.
+ */
+ at RegistryInfo(extension=ProjectorRule.class)
+public class ConformanceReferenceProjectorRule extends ModelReferenceProjectorRule {
+
+	/**
+	 * This is the default constructor.
+	 */
+	public ConformanceReferenceProjectorRule() {
+		super(true);
+	}
+	
+	/**
+	 * This method determines whether the projection rule is
+	 * appropriate for the supplied model object.
+	 * 
+	 * @param obj The model object to be projected
+	 * @return Whether the rule is relevant for the
+	 * 				model object
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj.getClass() == ConformanceReference.class);
+	}
+	
+	/**
+	 * This method returns the new reference instance.
+	 * 
+	 * @param source The source reference
+	 * @return The model reference
+	 */
+	protected ModelReference createReference(ModelReference source) {
+		return(new ConformanceReference(source.getNotation()));
+	}
+	
+	/**
+	 * This method projects the supplied model object based on the
+	 * specified role.
+	 * 
+	 * @param model The model object
+	 * @param role The role
+	 * @param l The model listener
+	 * @return The projected model object
+	 */
+	public ModelObject project(ProjectorContext context, ModelObject model,
+					Role role, ModelListener l) {
+		ConformanceReference source=(ConformanceReference)model;
+
+		ConformanceReference ret=null;
+		
+		// Check if conformance reference relates to the projected role
+		// TODO: Need to be able to project if projected role is in the
+		// name mapping list?? Also possibly if source is not located
+		if (source.getLocatedRole() != null &&
+				source.getLocatedRole().equals(role.getName())) {
+			ret = (ConformanceReference)super.project(context,
+					model, role, l);
+			
+			// Project name mapping
+			java.util.Map<String,String> mapping=source.getNameMapping();
+			String mappedName=null;
+			
+			java.util.Iterator<String> iter=mapping.keySet().iterator();
+			while (iter.hasNext()) {
+				String key=iter.next();
+				String value=mapping.get(key);
+				
+				ret.getNameMapping().put(key, value);
+				
+				if (role.getName().equals(value)) {
+					mappedName = key;
+				}
+			}
+			
+			if (mappedName != null) {
+				ret.setLocatedRole(mappedName);
+			}
+		}
+
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/DefaultProjector.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/DefaultProjector.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/DefaultProjector.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 18 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.projector;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class provides the default implementation
+ * of the Projector interface.
+ */
+ at RegistryInfo(extension=Projector.class)
+public class DefaultProjector implements Projector {
+
+	/**
+	 * This is the default constructor for the projector.
+	 */
+	public DefaultProjector() {
+	}
+	
+	/**
+	 * This method projects the supplied model based on the
+	 * specified role.
+	 * 
+	 * @param ref The model reference
+	 * @param model The model
+	 * @param role The role
+	 * @param l The model listener
+	 * @return The projected model
+	 */
+	public Model project(ModelReference ref, Model model, Role role,
+						ModelListener l) {
+		return(project(ref, model, null, role, l));
+	}
+
+	/**
+	 * This method projects the supplied model based on the
+	 * specified role. This version takes the additional
+	 * 'subDefinitionPath' to locate the specific definition
+	 * that should be projected to the specified role.
+	 * 
+	 * @param ref The model reference
+	 * @param model The model
+	 * @param subDefinitionPath The optional sub-definition path
+	 * @param role The role
+	 * @param l The model listener
+	 * @return The projected model
+	 */
+	public Model project(ModelReference ref, Model model,
+			SubDefinitionPath subDefinitionPath, Role role,
+						ModelListener l) {
+		Model ret=null;
+		
+		DefaultProjectorContext context=new DefaultProjectorContext(ref,
+								subDefinitionPath);
+		ModelObject obj=context.project(model, role, l);
+		
+		if (obj != null) {
+			if (obj instanceof Model) {
+				ret = (Model)obj;
+			} else {
+				String modelName=model.getNamespace().getName();
+				
+				java.util.List<Definition> defns=model.getDefinitions();
+				for (int i=0; i < defns.size(); i++) {
+					modelName += "("+defns.get(i).getLocatedName().getName();
+					
+					if (defns.get(i).getLocatedName().getRole() != null) {
+						modelName += ","+defns.get(i).getLocatedName().getRole();
+					}
+					
+					modelName += ")";
+				}
+				
+				l.error(new ModelIssue(model, org.scribble.util.MessageUtil.format(
+						java.util.PropertyResourceBundle.getBundle("org.scribble.validation.Messages"),
+						"_NOT_PROJECTED_MODEL",
+						new String[]{modelName})));
+			}
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/DefaultProjectorContext.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/DefaultProjectorContext.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/DefaultProjectorContext.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,208 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 18 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.projector;
+
+import java.util.logging.Logger;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.util.Scope;
+
+/**
+ * This class represents the default projection context.
+ */
+public class DefaultProjectorContext implements ProjectorContext {
+
+	/**
+	 * This is the default constructor for the projection context.
+	 * 
+	 * @param ref The model reference being projected
+	 * @param subDefinitionPath The sub definition path
+	 */
+	public DefaultProjectorContext(ModelReference ref,
+			SubDefinitionPath subDefinitionPath) {
+		
+		java.util.List<Object> rules=
+			org.scribble.extensions.RegistryFactory.getRegistry().
+						getExtensions(ProjectorRule.class, ref.getNotation());
+		
+		// Transfer to typed list
+		for (int i=0; i < rules.size(); i++) {
+			if (rules.get(i) instanceof ProjectorRule) {
+				m_rules.add((ProjectorRule)rules.get(i));
+			}
+		}
+		
+		m_subDefinitionPath = subDefinitionPath;
+		
+		if (m_subDefinitionPath == null) {
+			m_subDefinitionPath = new SubDefinitionPath();
+		}
+	}
+	
+	/**
+	 * This method projects the supplied model object based on the
+	 * specified role.
+	 * 
+	 * @param model The model object
+	 * @param role The role
+	 * @param l The model listener
+	 * @return The projected model object
+	 */
+	public ModelObject project(ModelObject model, Role role,
+						ModelListener l) {
+		ModelObject ret=null;
+		
+		for (int i=0; model != null && ret == null && i < getRules().size(); i++) {
+			if (getRules().get(i).isSupported(model)) {
+				ret = getRules().get(i).project(this, model, role,
+								l);
+			}
+		}
+				
+		return(ret);
+	}
+		
+	/**
+	 * This method returns a list of projection rules.
+	 * 
+	 * @return The list of projection rules
+	 */
+	public java.util.List<ProjectorRule> getRules() {
+		return(m_rules);
+	}
+	
+	/**
+	 * This method returns the named state from the current
+	 * scope.
+	 * 
+	 * @param name The state name
+	 * @return The state value, or null if not found
+	 */
+	public Object getState(String name) {
+		return(m_scope.getState(name));
+	}
+	
+	/**
+	 * This method sets the value associated with the supplied
+	 * name in the current state scope.
+	 * 
+	 * @param name The state name
+	 * @param value The state value
+	 */
+	public void setState(String name, Object value) {
+		m_scope.setState(name, value);
+	}
+
+	/**
+	 * This method pushes the current state onto a stack.
+	 */
+	public void pushState() {
+		m_scope.pushState();
+	}
+	
+	/**
+	 * This method pops the current state from the stack.
+	 */
+	public void popState() {
+		m_scope.popState();
+	}
+		
+	/**
+	 * This method pushes the current scope onto a stack.
+	 */
+	public void pushScope() {
+		m_scopeStack.add(0, m_scope);
+		m_scope = new Scope();
+	}
+	
+	/**
+	 * This method pops the current scope from the stack.
+	 */
+	public void popScope() {
+		if (m_scopeStack.size() > 0) {
+			m_scope = m_scopeStack.remove(0);
+		} else {
+			logger.severe("No state entry to pop from stack");
+		}
+	}
+	
+	/**
+	 * This method determines whether the context is associated
+	 * with the outer scope.
+	 * 
+	 * @return Whether the context is for the outer scope
+	 */
+	public boolean isOuterScope() {
+		return(m_scopeStack.size() < 1);
+	}
+
+	/**
+	 * This method registers an interest in the projected role
+	 * associated with the supplied definition.
+	 * 
+	 * @param defn The definition
+	 * @param role The projected role of interest
+	 */
+	public void registerInterest(Definition defn, Role role) {
+		java.util.List<Role> roles=m_definitionRoleMap.get(defn);
+		
+		if (roles == null) {
+			roles = new java.util.Vector<Role>();
+			m_definitionRoleMap.put(defn, roles);
+		}
+		
+		if (roles.contains(role) == false) {
+			roles.add(role);
+		}
+	}
+	
+	/**
+	 * This method returns the list of roles of interest
+	 * for the supplied definition.
+	 * 
+	 * @param defn The definition
+	 * @return The list of roles, or null if no roles have
+	 * 				registered interest in the definition
+	 */
+	public java.util.List<Role> getRolesOfInterestForDefinition(Definition defn) {
+		return(m_definitionRoleMap.get(defn));
+	}
+	
+	/**
+	 * This method returns the sub definition path being
+	 * projected. If the list is empty, then the top level
+	 * definition will be used.
+	 * 
+	 * @return The sub definition path
+	 */
+	public SubDefinitionPath getSubDefinitionPath() {
+		return(m_subDefinitionPath);
+	}
+	
+	private static Logger logger = Logger.getLogger("org.scribble.projector");
+
+	private java.util.List<ProjectorRule> m_rules=new java.util.Vector<ProjectorRule>();
+	private Scope m_scope=new Scope();
+	private java.util.List<Scope> m_scopeStack=new java.util.Vector<Scope>();
+	private java.util.Map<Definition,java.util.List<Role>> m_definitionRoleMap=
+					new java.util.HashMap<Definition,java.util.List<Role>>();
+	private SubDefinitionPath m_subDefinitionPath=null;
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/ImplementsReferenceProjectorRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/ImplementsReferenceProjectorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/ImplementsReferenceProjectorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 20 Mar 2008 : Initial version created by gary
+ */
+package org.scribble.projector;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class provides the ImplementsReference implementation of the
+ * projector rule.
+ */
+ at RegistryInfo(extension=ProjectorRule.class)
+public class ImplementsReferenceProjectorRule extends ModelReferenceProjectorRule {
+
+	/**
+	 * This is the default constructor.
+	 */
+	public ImplementsReferenceProjectorRule() {
+		super(true);
+	}
+	
+	/**
+	 * This method determines whether the projection rule is
+	 * appropriate for the supplied model object.
+	 * 
+	 * @param obj The model object to be projected
+	 * @return Whether the rule is relevant for the
+	 * 				model object
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj.getClass() == ImplementsReference.class);
+	}
+	
+	/**
+	 * This method returns the new reference instance.
+	 * 
+	 * @param source The source reference
+	 * @return The model reference
+	 */
+	protected ModelReference createReference(ModelReference source) {
+		return(new ImplementsReference(source.getNotation()));
+	}
+	
+	/**
+	 * This method projects the supplied model object based on the
+	 * specified role.
+	 * 
+	 * @param model The model object
+	 * @param role The role
+	 * @param l The model listener
+	 * @return The projected model object
+	 */
+	public ModelObject project(ProjectorContext context, ModelObject model,
+					Role role, ModelListener l) {
+		ImplementsReference source=(ImplementsReference)model;
+
+		ImplementsReference ret=(ImplementsReference)super.project(context,
+				model, role, l);
+		
+		// Project name mapping
+		java.util.Map<String,String> mapping=source.getNameMapping();
+		String mappedName=null;
+		
+		java.util.Iterator<String> iter=mapping.keySet().iterator();
+		while (iter.hasNext()) {
+			String key=iter.next();
+			String value=mapping.get(key);
+			
+			ret.getNameMapping().put(key, value);
+			
+			if (role.getName().equals(value)) {
+				mappedName = key;
+			}
+		}
+		
+		if (mappedName != null) {
+			ret.setLocatedRole(mappedName);
+		}
+
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/ImportProjectorRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/ImportProjectorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/ImportProjectorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 19 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.projector;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class provides the Import implementation of the
+ * projector rule.
+ */
+ at RegistryInfo(extension=ProjectorRule.class)
+public class ImportProjectorRule implements ProjectorRule {
+
+	/**
+	 * This method determines whether the projection rule is
+	 * appropriate for the supplied model object.
+	 * 
+	 * @param obj The model object to be projected
+	 * @return Whether the rule is relevant for the
+	 * 				model object
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj.getClass() == Import.class);
+	}
+	
+	/**
+	 * This method projects the supplied model object based on the
+	 * specified role.
+	 * 
+	 * @param model The model object
+	 * @param role The role
+	 * @param l The model listener
+	 * @return The projected model object
+	 */
+	public ModelObject project(ProjectorContext context, ModelObject model,
+					Role role, ModelListener l) {
+		Import ret=new Import();
+		Import source=(Import)model;
+		
+		ret.setName(source.getName());
+		
+		if (source.getAlias() != null) {
+			ret.setAlias(source.getAlias());
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/InteractionProjectorRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/InteractionProjectorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/InteractionProjectorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,155 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 19 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.projector;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class provides the Interaction implementation of the
+ * projector rule.
+ */
+ at RegistryInfo(extension=ProjectorRule.class)
+public class InteractionProjectorRule implements ProjectorRule {
+
+	/**
+	 * This method determines whether the projection rule is
+	 * appropriate for the supplied model object.
+	 * 
+	 * @param obj The model object to be projected
+	 * @return Whether the rule is relevant for the
+	 * 				model object
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj.getClass() == Interaction.class);
+	}
+	
+	/**
+	 * This method returns a new instance of the interaction model
+	 * object.
+	 * 
+	 * @return The new interaction
+	 */
+	protected Interaction createInteraction() {
+		return(new Interaction());
+	}
+	
+	/**
+	 * This method projects the supplied model object based on the
+	 * specified role.<p>
+	 * 
+	 * @param model The model object
+	 * @param role The role
+	 * @param l The model listener
+	 * @return The projected model object
+	 */
+	public ModelObject project(ProjectorContext context, ModelObject model,
+					Role role, ModelListener l) {
+		Interaction ret=createInteraction();
+		Interaction source=(Interaction)model;
+		boolean f_roleFound=false;
+		
+		ret.derivedFrom(source);
+
+		if (source.getRequestLabel() != null) {
+			ret.setRequestLabel(source.getRequestLabel());
+		}
+		
+		if (source.getReplyToLabel() != null) {
+			ret.setReplyToLabel(source.getReplyToLabel());
+		}
+		
+		if (source.getFromRole() != null) {
+			
+			if (source.getFromRole().equals(role)) {				
+				f_roleFound = true;
+			} else {
+				// Only set role if not projected role
+				// Find role in state
+				Object state=context.getState(source.getFromRole().getName());
+				
+				if (state instanceof Role) {
+					Role r=new Role();
+					r.setName(source.getFromRole().getName());
+					
+					r.derivedFrom(source.getFromRole());
+					
+					ret.setFromRole(r);
+				}
+			}
+		}
+		
+		if (source.getToRole() != null) {
+			
+			if (source.getToRole().equals(role)) {
+				f_roleFound = true;
+			} else {
+				// Only set role if not projected role
+				// Find role in state
+				Object state=context.getState(source.getToRole().getName());
+				
+				if (state instanceof Role) {
+					Role r=new Role();
+					r.setName(source.getToRole().getName());
+					
+					r.derivedFrom(source.getToRole());
+					
+					ret.setToRole(r);
+				}
+			}
+		}
+		
+		if (source.getChannel() != null) {
+			
+			// Find channel in state
+			Object state=context.getState(source.getChannel().getName());
+			
+			if (state instanceof Channel) {
+				Channel c=new Channel();
+				c.setName(source.getChannel().getName());
+				
+				c.derivedFrom(source.getChannel());
+				
+				ret.setChannel(c);
+			}
+			
+			if (source.getChannel().getFromRole() != null &&
+					source.getChannel().getFromRole().equals(role)) {
+				f_roleFound = true;
+			} else if (source.getChannel().getToRole() != null &&
+					source.getChannel().getToRole().equals(role)) {
+				f_roleFound = true;
+			}
+		}
+		
+		// Check if role found
+		if (f_roleFound) {
+			ret.setMessageSignature((MessageSignature)
+					context.project(source.getMessageSignature(),
+							role, l));
+		} else {
+			// Role not associated with the interaction
+			ret = null;
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/LocatedNameProjectorRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/LocatedNameProjectorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/LocatedNameProjectorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 19 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.projector;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class provides the LocatedName implementation of the
+ * projector rule.
+ */
+ at RegistryInfo(extension=ProjectorRule.class)
+public class LocatedNameProjectorRule implements ProjectorRule {
+
+	/**
+	 * This method determines whether the projection rule is
+	 * appropriate for the supplied model object.
+	 * 
+	 * @param obj The model object to be projected
+	 * @return Whether the rule is relevant for the
+	 * 				model object
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj.getClass() == LocatedName.class);
+	}
+	
+	/**
+	 * This method projects the supplied model object based on the
+	 * specified role.
+	 * 
+	 * @param model The model object
+	 * @param role The role
+	 * @param l The model listener
+	 * @return The projected model object
+	 */
+	public ModelObject project(ProjectorContext context, ModelObject model,
+					Role role, ModelListener l) {
+		LocatedName ret=new LocatedName();
+		LocatedName source=(LocatedName)model;
+		
+		ret.setName(source.getName());
+		
+		Role located=(Role)context.project(role, role, l);
+
+		ret.setRole(located);
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/MessageSignatureProjectorRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/MessageSignatureProjectorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/MessageSignatureProjectorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 19 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.projector;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class provides the MessageSignature implementation of the
+ * projector rule.
+ */
+ at RegistryInfo(extension=ProjectorRule.class)
+public class MessageSignatureProjectorRule implements ProjectorRule {
+
+	/**
+	 * This method determines whether the projection rule is
+	 * appropriate for the supplied model object.
+	 * 
+	 * @param obj The model object to be projected
+	 * @return Whether the rule is relevant for the
+	 * 				model object
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj.getClass() == MessageSignature.class);
+	}
+	
+	/**
+	 * This method projects the supplied model object based on the
+	 * specified role.
+	 * 
+	 * @param model The model object
+	 * @param role The role
+	 * @param l The model listener
+	 * @return The projected model object
+	 */
+	public ModelObject project(ProjectorContext context, ModelObject model,
+					Role role, ModelListener l) {
+		MessageSignature ret=new MessageSignature();
+		MessageSignature source=(MessageSignature)model;
+		
+		ret.derivedFrom(source);
+		
+		ret.setOperation(source.getOperation());
+		
+		for (int i=0; i < source.getTypes().size(); i++) {
+			TypeReference ref=(TypeReference)
+					context.project(source.getTypes().get(i),
+							role, l);
+			
+			if (ref != null) {
+				ret.getTypes().add(ref);
+			}
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/Messages.properties
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/Messages.properties	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/Messages.properties	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,21 @@
+# /*
+# * Copyright 2007 Pi4 Technologies Ltd
+# *
+# * 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.
+# *
+# *
+# * Change History:
+# * 18 Nov 2007 : Initial version created by gary
+# */
+
+_NOT_PROJECTED_MODEL=Model '{0}' was not projected to another model
\ No newline at end of file

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/ModelIncludeProjectorRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/ModelIncludeProjectorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/ModelIncludeProjectorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 7 Dec 2007 : Initial version created by gary
+ */
+package org.scribble.projector;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This abstract class provides the ModelInclude implementation of the
+ * projector rule.
+ */
+public abstract class ModelIncludeProjectorRule implements ProjectorRule {
+
+	/**
+	 * This method creates the model include object being projected.
+	 * 
+	 * @return The model include
+	 */
+	protected abstract ModelInclude createModelInclude();
+	
+	/**
+	 * This method projects the supplied model object based on the
+	 * specified role.
+	 * 
+	 * @param model The model object
+	 * @param role The role
+	 * @param l The model listener
+	 * @return The projected model object
+	 */
+	public ModelObject project(ProjectorContext context, ModelObject model,
+					Role role, ModelListener l) {
+		ModelInclude ret=createModelInclude();
+		ModelInclude source=(ModelInclude)model;
+		
+		ret.derivedFrom(source);
+		
+		java.util.Iterator<DeclarationBinding> iter=
+					source.getBindings().iterator();
+		while (iter.hasNext()) {
+			DeclarationBinding db=iter.next();
+			
+			// Don't project declaration if same as role - this
+			// will be done in the model include statement,
+			// not the bindings
+			if (db.getDeclaration() != role) {
+				
+				// Find declaration in local projected context
+				Object localDecl=context.getState(db.getDeclaration().getName());
+				
+				if (localDecl instanceof Declaration) {
+					DeclarationBinding dbcopy=
+						new DeclarationBinding((Declaration)localDecl,
+									db.getBoundName());
+					
+					dbcopy.derivedFrom(db);
+					
+					ret.getBindings().add(dbcopy);
+				} else {
+					
+					// TODO: What should happen if not declaration,
+					// or not found?
+				}
+			}
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/ModelProjectorRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/ModelProjectorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/ModelProjectorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 19 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.projector;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class provides the abstract Model implementation of the
+ * projector rule.
+ */
+public abstract class ModelProjectorRule implements ProjectorRule {
+
+	/**
+	 * This method creates the model instance being projected.
+	 * 
+	 * @return The new model
+	 */
+	protected abstract Model createModel();
+		
+	/**
+	 * This method projects the supplied model object based on the
+	 * specified role.
+	 * 
+	 * @param model The model object
+	 * @param role The role
+	 * @param l The model listener
+	 * @return The projected model object
+	 */
+	public ModelObject project(ProjectorContext context, ModelObject model,
+					Role role, ModelListener l) {
+		Model ret=createModel();
+		Model source=(Model)model;
+		
+		Namespace ns=null;
+		
+		if (source.getNamespace() != null) {
+			ns = (Namespace)context.project(source.getNamespace(),
+					role, l);
+		}
+		
+		ret.setNamespace(ns);
+		
+		// Project import statements
+		for (int i=0; i < source.getImports().size(); i++) {
+			
+			Import newImport=(Import)
+					context.project(source.getImports().get(i),
+								role, l);
+			
+			if (newImport != null) {
+				ret.getImports().add(newImport);
+			}
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/ModelReferenceProjectorRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/ModelReferenceProjectorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/ModelReferenceProjectorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 19 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.projector;
+
+import org.scribble.extensions.RegistryFactory;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.model.admin.ModelRepository;
+
+/**
+ * This class provides the abstract ModelReference implementation of the
+ * projector rule.
+ */
+public abstract class ModelReferenceProjectorRule implements ProjectorRule {
+
+	public ModelReferenceProjectorRule(boolean locatedRoleProjected) {
+		m_locatedRoleProjected = locatedRoleProjected;
+	}
+	
+	/**
+	 * This method returns the new reference instance.
+	 * 
+	 * @param source The source reference
+	 * @return The model reference
+	 */
+	protected abstract ModelReference createReference(ModelReference source);
+		
+	/**
+	 * This method projects the supplied model object based on the
+	 * specified role.
+	 * 
+	 * @param model The model object
+	 * @param role The role
+	 * @param l The model listener
+	 * @return The projected model object
+	 */
+	public ModelObject project(ProjectorContext context, ModelObject model,
+					Role role, ModelListener l) {
+		ModelReference source=(ModelReference)model;
+		ModelReference ret=(ModelReference)createReference(source);
+		
+		ret.derivedFrom(source);
+
+		// Make full copy of model reference - if projection
+		// needs to change located role, then this should be
+		// done in the context of where the reference is used
+		ret.setAlias(source.getAlias());
+		ret.setLocalpart(source.getLocalpart());
+		ret.setNamespace(source.getNamespace());
+		
+		ret.setFullyQualified(source.isFullyQualified());
+		ret.setInner(source.isInner());
+		ret.setNotation(source.getNotation());
+		
+		if (isLocatedRoleProjected()) {
+			ret.setLocatedRole(role.getName());
+		} else {
+			ret.setLocatedRole(source.getLocatedRole());
+		}
+		
+		// Located the reference based on the source
+		/* GPB: TO REMOVE
+		ModelRepository mrep=(ModelRepository)
+				RegistryFactory.getRegistry().getExtension(
+						ModelRepository.class, null);
+
+		if (mrep != null) {
+			mrep.locate(ret, source);
+		}
+		*/
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method determines whether the located role
+	 * should be projected.
+	 * 
+	 * @return Whether the located role should be projected
+	 */
+	protected boolean isLocatedRoleProjected() {
+		return(m_locatedRoleProjected);
+	}
+	
+	private boolean m_locatedRoleProjected=false;
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/NamespaceProjectorRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/NamespaceProjectorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/NamespaceProjectorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 18 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.projector;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class provides the Namespace implementation of the
+ * projector rule.
+ */
+ at RegistryInfo(extension=ProjectorRule.class)
+public class NamespaceProjectorRule implements ProjectorRule {
+
+	/**
+	 * This method determines whether the projection rule is
+	 * appropriate for the supplied model object.
+	 * 
+	 * @param obj The model object to be projected
+	 * @return Whether the rule is relevant for the
+	 * 				model object
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj.getClass() == Namespace.class);
+	}
+	
+	/**
+	 * This method projects the supplied model object based on the
+	 * specified role.
+	 * 
+	 * @param model The model object
+	 * @param role The role
+	 * @param l The model listener
+	 * @return The projected model object
+	 */
+	public ModelObject project(ProjectorContext context, ModelObject model,
+					Role role, ModelListener l) {
+		Namespace ret=new Namespace();
+		Namespace source=(Namespace)model;
+		
+		ret.setName(source.getName());
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/Projector.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/Projector.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/Projector.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 18 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.projector;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This interface represents the component for projecting
+ * a global model to a local model associated with a
+ * role.
+ */
+public interface Projector {
+
+	/**
+	 * This method projects the supplied model based on the
+	 * specified role.
+	 * 
+	 * @param ref The model reference
+	 * @param model The model
+	 * @param role The role
+	 * @param l The model listener
+	 * @return The projected model
+	 */
+	public Model project(ModelReference ref, Model model, Role role,
+						ModelListener l);
+	
+	/**
+	 * This method projects the supplied model based on the
+	 * specified role. This version takes the additional
+	 * 'subDefinitionPath' to locate the specific definition
+	 * that should be projected to the specified role.
+	 * 
+	 * @param ref The model reference
+	 * @param model The model
+	 * @param subDefinitionPath The optional sub-definition path
+	 * @param role The role
+	 * @param l The model listener
+	 * @return The projected model
+	 */
+	public Model project(ModelReference ref, Model model,
+			SubDefinitionPath subDefinitionPath, Role role,
+						ModelListener l);
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/ProjectorContext.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/ProjectorContext.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/ProjectorContext.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 18 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.projector;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This interface represents the comparator context.
+ */
+public interface ProjectorContext {
+	
+	/**
+	 * This method projects the supplied model object based on the
+	 * specified role.
+	 * 
+	 * @param model The model object
+	 * @param role The role
+	 * @param l The model listener
+	 * @return The projected model object
+	 */
+	public ModelObject project(ModelObject model, Role role,
+						ModelListener l);
+	
+	/**
+	 * This method returns the named state from the current
+	 * scope.
+	 * 
+	 * @param name The state name
+	 * @return The state value, or null if not found
+	 */
+	public Object getState(String name);
+	
+	/**
+	 * This method sets the value associated with the supplied
+	 * name in the current state.
+	 * 
+	 * @param name The state name
+	 * @param value The state value
+	 */
+	public void setState(String name, Object value);
+	
+	/**
+	 * This method pushes the current state onto a stack.
+	 */
+	public void pushState();
+	
+	/**
+	 * This method pops the current state from the stack.
+	 */
+	public void popState();
+	
+	/**
+	 * This method pushes the current scope onto a stack.
+	 */
+	public void pushScope();
+	
+	/**
+	 * This method pops the current scope from the stack.
+	 */
+	public void popScope();
+	
+	/**
+	 * This method determines whether the context is associated
+	 * with the outer scope.
+	 * 
+	 * @return Whether the context is for the outer scope
+	 */
+	public boolean isOuterScope();
+	
+	/**
+	 * This method registers an interest in the projected role
+	 * associated with the supplied definition.
+	 * 
+	 * @param defn The definition
+	 * @param role The projected role of interest
+	 */
+	public void registerInterest(Definition defn, Role role);
+	
+	/**
+	 * This method returns the list of roles of interest
+	 * for the supplied definition.
+	 * 
+	 * @param defn The definition
+	 * @return The list of roles, or null if no roles have
+	 * 				registered interest in the definition
+	 */
+	public java.util.List<Role> getRolesOfInterestForDefinition(Definition defn);
+	
+	/**
+	 * This method returns the sub definition path being
+	 * projected. If the list is empty, then the top level
+	 * definition will be used.
+	 * 
+	 * @return The sub definition path
+	 */
+	public SubDefinitionPath getSubDefinitionPath();
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/ProjectorRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/ProjectorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/ProjectorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 18 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.projector;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This interface represents the projection rule used to
+ * derive another model object associated with a role.
+ */
+public interface ProjectorRule {
+
+	/**
+	 * This method determines whether the projection rule is
+	 * appropriate for the supplied model object.
+	 * 
+	 * @param obj The model object to be projected
+	 * @return Whether the rule is relevant for the
+	 * 				model object
+	 */
+	public boolean isSupported(ModelObject obj);
+	
+	/**
+	 * This method projects the supplied model object based on the
+	 * specified role.
+	 * 
+	 * @param model The model object
+	 * @param role The role
+	 * @param l The model listener
+	 * @return The projected model object
+	 */
+	public ModelObject project(ProjectorContext context, ModelObject model,
+					Role role, ModelListener l);
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/RoleListProjectorRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/RoleListProjectorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/RoleListProjectorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 19 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.projector;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class provides the RoleList implementation of the
+ * projector rule.
+ */
+ at RegistryInfo(extension=ProjectorRule.class)
+public class RoleListProjectorRule implements ProjectorRule {
+
+	/**
+	 * This method determines whether the projection rule is
+	 * appropriate for the supplied model object.
+	 * 
+	 * @param obj The model object to be projected
+	 * @return Whether the rule is relevant for the
+	 * 				model object
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj.getClass() == RoleList.class);
+	}
+	
+	/**
+	 * This method projects the supplied model object based on the
+	 * specified role.
+	 * 
+	 * @param model The model object
+	 * @param role The role
+	 * @param l The model listener
+	 * @return The projected model object
+	 */
+	public ModelObject project(ProjectorContext context, ModelObject model,
+					Role role, ModelListener l) {
+		RoleList ret=new RoleList();
+		RoleList source=(RoleList)model;
+		
+		for (int i=0; i < source.getRoles().size(); i++) {
+			if (source.getRoles().get(i).equals(role) == false) {
+				Role p=(Role)context.project(source.getRoles().get(i), role, l);
+
+				if (p != null) {
+					ret.getRoles().add(p);
+				}
+			}
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/RoleProjectorRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/RoleProjectorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/RoleProjectorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2007-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 2 Oct 2009 : Initial version created by gary
+ */
+package org.scribble.projector;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class provides the Role implementation of the
+ * projector rule.
+ */
+ at RegistryInfo(extension=ProjectorRule.class)
+public class RoleProjectorRule implements ProjectorRule {
+
+	/**
+	 * This method determines whether the projection rule is
+	 * appropriate for the supplied model object.
+	 * 
+	 * @param obj The model object to be projected
+	 * @return Whether the rule is relevant for the
+	 * 				model object
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj.getClass() == Role.class);
+	}
+	
+	/**
+	 * This method projects the supplied model object based on the
+	 * specified role.
+	 * 
+	 * @param model The model object
+	 * @param role The role
+	 * @param l The model listener
+	 * @return The projected model object
+	 */
+	public ModelObject project(ProjectorContext context, ModelObject model,
+					Role role, ModelListener l) {
+		Role ret=new Role();
+		Role source=(Role)model;
+		
+		ret.derivedFrom(source);
+				
+		ret.setName(source.getName());
+				
+		// Add to state
+		context.setState(ret.getName(), ret);
+		
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/TypeReferenceProjectorRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/TypeReferenceProjectorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/projector/TypeReferenceProjectorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 19 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.projector;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class provides the TypeReference implementation of the
+ * projector rule.
+ */
+ at RegistryInfo(extension=ProjectorRule.class)
+public class TypeReferenceProjectorRule extends ModelReferenceProjectorRule {
+
+	/**
+	 * This is the default constructor.
+	 */
+	public TypeReferenceProjectorRule() {
+		super(false);
+	}
+	
+	/**
+	 * This method determines whether the projection rule is
+	 * appropriate for the supplied model object.
+	 * 
+	 * @param obj The model object to be projected
+	 * @return Whether the rule is relevant for the
+	 * 				model object
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj.getClass() == TypeReference.class);
+	}
+	
+	/**
+	 * This method returns the new reference instance.
+	 * 
+	 * @param source The source reference
+	 * @return The model reference
+	 */
+	protected ModelReference createReference(ModelReference source) {
+		return(new TypeReference());
+	}
+	
+	/**
+	 * This method projects the supplied model object based on the
+	 * specified role.
+	 * 
+	 * @param model The model object
+	 * @param role The role
+	 * @param l The model listener
+	 * @return The projected model object
+	 */
+	public ModelObject project(ProjectorContext context, ModelObject model,
+					Role role, ModelListener l) {
+		TypeReference ret=(TypeReference)super.project(context,
+									model, role, l);
+		//TypeReference source=(TypeReference)model;
+				
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/util/MessageUtil.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/util/MessageUtil.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/util/MessageUtil.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 28 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.util;
+
+/**
+ * This class provides utility functions related to
+ * messages.
+ * 
+ */
+public class MessageUtil {
+
+	/**
+	 * This method formats the message associated with the supplied
+	 * bundle and key using the supplied parameters.
+	 * 
+	 * @param bundle The bundle of message resources
+	 * @param key The message key
+	 * @param params The list of parameters
+	 * @return The formatted text
+	 */
+	public static String format(java.util.ResourceBundle bundle, String key,
+						String[] params) {
+		String ret=null;
+		
+		String mesg=bundle.getString(key);
+	
+		ret = format(mesg, params);
+					
+		return(ret);
+	}
+	
+	/**
+	 * This method formats the supplied text using the supplied
+	 * parameters.
+	 * 
+	 * @param mesg The message text
+	 * @param params The list of parameters
+	 * @return The formatted text
+	 */
+	public static String format(String mesg, String[] params) {
+		
+		String ret="";
+		int pos=0;
+		int prev=0;
+		String nextToken=INDEX_START;
+		
+		while ((pos=mesg.indexOf(nextToken, pos)) != -1) {
+			String token=mesg.substring(prev, pos);
+			
+			if (nextToken == INDEX_START) {
+				ret += token;
+				nextToken = INDEX_END;
+			} else if (nextToken == INDEX_END){
+				int index=-1;
+				
+				try {
+					index = Integer.valueOf(token).intValue();
+				} catch(Exception e) {
+					// Ignore
+				}
+				
+				if (params != null && index >= 0 &&
+						index < params.length) {
+					ret += params[index];
+				} else {
+					ret += INDEX_START+index+INDEX_END;
+				}
+				
+				nextToken = INDEX_START;
+			}
+			
+			prev = pos+1;
+		}
+		
+		if (prev != -1) {
+			ret += mesg.substring(prev);
+		}
+		
+		return(ret);
+	}
+
+	public static final String INDEX_START="{";
+	public static final String INDEX_END="}";
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/util/ModelIssueUtil.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/util/ModelIssueUtil.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/util/ModelIssueUtil.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,151 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 7 Sep 2008 : Initial version created by gary
+ */
+package org.scribble.util;
+
+import org.scribble.model.admin.DefaultResolution;
+import org.scribble.model.resolutions.Resolution;
+
+/**
+ * This class provides utility functions for dealing with
+ * model issues.
+ */
+public class ModelIssueUtil {
+
+	private static final String RESOLUTION_PROPERTY_VALUE = "ResolutionPropertyValue";
+	private static final String RESOLUTION_PROPERTY_NAME = "ResolutionPropertyName";
+	private static final String RESOLUTION_NUMBER_OF_PROPERTIES = "ResolutionNumberOfProperties";
+	private static final String RESOLUTION_CLASS = "ResolutionClass";
+	private static final String NUMBER_OF_RESOLUTIONS = "NumberOfResolutions";
+
+	/**
+	 * This method serializes the resolutions associated with a
+	 * model issue.
+	 *  
+	 * @param resolutions The resolutions
+	 * @return The serialized properties
+	 */
+	public static java.util.Map<String,Object> serializeResolutions(java.util.List<Resolution> resolutions) {
+		java.util.Map<String,Object> ret=new java.util.HashMap<String, Object>();
+		
+		ret.put(NUMBER_OF_RESOLUTIONS, resolutions.size());
+			
+		for (int i=0; i < resolutions.size(); i++) {
+			Resolution res=resolutions.get(i);
+			
+			ret.put(RESOLUTION_CLASS+"-"+i, res.getResolutionClass());
+			
+			java.util.Map<String,Object> props=res.getProperties();
+			
+			ret.put(RESOLUTION_NUMBER_OF_PROPERTIES+"-"+i,
+							props.size());
+			
+			int propNo=0;
+			
+			java.util.Iterator<String> iter=props.keySet().iterator();
+			while (iter.hasNext()) {
+				String key=iter.next();
+				Object value=props.get(key);
+				
+				ret.put(RESOLUTION_PROPERTY_NAME+"-"+i+"-"+propNo, key);
+				ret.put(RESOLUTION_PROPERTY_VALUE+"-"+i+"-"+propNo, value);
+				
+				propNo++;
+			}
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method deserializes the supplied properties to create
+	 * a list of resolutions.
+	 * 
+	 * @param props The properties
+	 * @return The list of resolutions
+	 */
+	public static java.util.List<Resolution> deserializeResolutions(java.util.Map<String,Object> props) {
+		java.util.List<Resolution> ret=new java.util.Vector<Resolution>();
+		
+		Object obj=props.get(NUMBER_OF_RESOLUTIONS);
+		int num=-1;
+		if (obj instanceof Integer) {
+			num = ((Integer)obj).intValue();
+		} else if (obj instanceof String) {
+			try {
+				num = Integer.parseInt((String)obj);
+			} catch(Exception e) {
+				e.printStackTrace();
+			}
+		}
+		
+		for (int i=0; i < num; i++) {
+			String clsName=(String)props.get(RESOLUTION_CLASS+"-"+i);
+			
+			Resolution res=null;
+			
+			try {
+				Class<?> cls=Class.forName(clsName);
+				
+				res = (Resolution)cls.newInstance();
+				
+			} catch(ClassNotFoundException cfne) {
+				res = new DefaultResolution();
+			} catch(Exception e) {
+				e.printStackTrace();
+			}
+
+			int propNo=0;
+			
+			obj = props.get(RESOLUTION_NUMBER_OF_PROPERTIES+"-"+i);
+			if (obj instanceof Integer) {
+				propNo = ((Integer)obj).intValue();
+			} else if (obj instanceof String) {
+				try {
+					propNo = Integer.parseInt((String)obj);
+				} catch(Exception e) {
+					e.printStackTrace();
+				}
+			}
+
+			for (int j=0; j < propNo; j++) {				
+				String key=(String)props.get(RESOLUTION_PROPERTY_NAME+"-"+i+"-"+j);
+				Object value=props.get(RESOLUTION_PROPERTY_VALUE+"-"+i+"-"+j);
+				
+				res.getProperties().put(key, value);
+			}
+			
+			ret.add(res);
+		}
+
+		return(ret);
+	}
+	
+	/**
+	 * This method determines if the supplied properties contains
+	 * the serialized information associated with a set of
+	 * resolutions.
+	 * 
+	 * @param props The properties
+	 * @return Whether resolutions have been defined
+	 */
+	public static boolean hasResolutions(java.util.Map<String,Object> props) {
+		return(props.containsKey(NUMBER_OF_RESOLUTIONS));
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/util/ResourceUtil.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/util/ResourceUtil.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/util/ResourceUtil.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 22 Aug 2008 : Initial version created by gary
+ */
+package org.scribble.util;
+
+public class ResourceUtil {
+
+	/**
+	 * This method returns the notation associated with the
+	 * supplied URI.
+	 * 
+	 * @param uri The URI
+	 * @return The notation, or null if an appropriate notation
+	 * 			could not be found
+	 */
+	public static org.scribble.model.Notation getNotation(String uri) {
+		org.scribble.model.Notation ret=null;
+		String ext=null;
+		String filename=null;
+		
+		// Extract extension
+		int index=uri.lastIndexOf('.');
+		
+		if (index != -1) {
+			ext = uri.substring(index+1);
+		}
+		
+		// Extract full file name
+		index = uri.lastIndexOf('/');
+		
+		if (index != -1) {
+			filename = uri.substring(index+1);
+		} else {
+			filename = uri;
+		}
+		
+		// Check if notation is available
+		java.util.List<Object> notations=
+			org.scribble.extensions.RegistryFactory.getRegistry().getExtensions(
+					org.scribble.model.Notation.class, null);
+		
+		for (int i=0; ret == null && i < notations.size(); i++) {
+			if ((ext != null &&
+				((org.scribble.model.Notation)notations.get(i)).getCode().equals(ext)) ||
+					((org.scribble.model.Notation)notations.get(i)).getCode().equals(filename)) {
+				ret = (org.scribble.model.Notation)notations.get(i);
+			}
+		}
+
+		return(ret);
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/util/Scope.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/util/Scope.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/util/Scope.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,152 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 1 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.util;
+
+import java.util.logging.Logger;
+
+/**
+ * This class represents information associated with a scope.
+ */
+public class Scope {
+
+	/**
+	 * The default constructor for the scope.
+	 */
+	public Scope() {
+		// Initialize the state
+		pushState();
+	}
+	
+	/**
+	 * This is the copy constructor for the scope.
+	 * 
+	 * @param copy The copy
+	 */
+	public Scope(Scope copy) {
+		m_locatedRole = copy.m_locatedRole;
+		
+		for (int i=0; i < copy.m_stateStack.size(); i++) {
+			java.util.Map<String,Object> current=copy.m_stateStack.get(i);
+			
+			java.util.Map<String,Object> copyStackEntry=
+						new java.util.HashMap<String,Object>();
+		
+			java.util.Iterator<String> iter=current.keySet().iterator();
+			
+			while (iter.hasNext()) {
+				String key=iter.next();
+				Object value=current.get(key);
+				
+				copyStackEntry.put(key, value);
+			}
+			
+			m_stateStack.add(copyStackEntry);
+		}
+	}
+	
+	/**
+	 * This method returns the named state from the current
+	 * scope.
+	 * 
+	 * @param name The state name
+	 * @return The state value, or null if not found
+	 */
+	public Object getState(String name) {
+		Object ret=null;
+		
+		if (m_stateStack.size() > 0) {
+			for (int i=0; ret == null && i < m_stateStack.size(); i++) {
+				java.util.Map<String,Object> current=m_stateStack.get(i);
+				ret = current.get(name);
+			}
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method sets the value associated with the supplied
+	 * name in the current state scope.
+	 * 
+	 * @param name The state name
+	 * @param value The state value
+	 */
+	public void setState(String name, Object value) {
+		if (m_stateStack.size() > 0) {
+			java.util.Map<String,Object> current=m_stateStack.get(0);
+			current.put(name, value);
+		}
+	}
+
+	/**
+	 * This method returns the located role associated with the
+	 * current scope.
+	 * 
+	 * @return The located role
+	 */
+	public String getLocatedRole() {
+		return(m_locatedRole);
+	}
+	
+	/**
+	 * This method sets the located role associated with the
+	 * current scope.
+	 * 
+	 * @param located The located role
+	 */
+	public void setLocatedRole(String located) {
+		m_locatedRole = located;
+	}
+
+	/**
+	 * This method pushes the current state onto a stack.
+	 */
+	public void pushState() {
+		m_stateStack.add(0, new java.util.Hashtable<String,Object>());
+	}
+	
+	/**
+	 * This method pops the current state from the stack.
+	 */
+	public void popState() {
+		if (m_stateStack.size() > 0) {
+			m_stateStack.remove(0);
+		} else {
+			logger.severe("No state entry to pop from stack");
+		}
+	}
+	
+	/**
+	 * This method returns the properties associated with
+	 * the scope.
+	 * 
+	 * @return The properties
+	 */
+	public java.util.Map<String,Object> getProperties() {
+		return(m_properties);
+	}
+		
+	private static Logger logger = Logger.getLogger("org.scribble.parser");
+
+	private String m_locatedRole=null;
+	private java.util.List<java.util.Map<String,Object>> m_stateStack=
+		new java.util.Vector<java.util.Map<String,Object>>();
+	private java.util.Map<String,Object> m_properties=new java.util.HashMap<String, Object>();
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/AbstractValidationRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/AbstractValidationRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/AbstractValidationRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 7 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.validation;
+
+public abstract class AbstractValidationRule implements ValidationRule {
+
+	/**
+	 * This is the default validation rule constructor.
+	 */
+	public AbstractValidationRule() {
+	}
+	
+	/**
+	 * This abstract validation rule constructor initializes
+	 * whether the validation rule should be a background
+	 * task.
+	 * 
+	 * @param backgroundTask Whether a background task
+	 */
+	public AbstractValidationRule(boolean backgroundTask) {
+		m_backgroundTask = backgroundTask;	
+	}
+	
+	/**
+	 * This method determines whether this validation task
+	 * should be performed in the background.
+	 * 
+	 * @return Whether the validation should be performed
+	 * 			as a background task
+	 */
+	public boolean isBackgroundTask() {
+		return(m_backgroundTask);
+	}
+	
+	private boolean m_backgroundTask=false;
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/BlockValidationRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/BlockValidationRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/BlockValidationRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 13 Mar 2008 : Initial version created by gary
+ */
+package org.scribble.validation;
+
+import org.scribble.extensions.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class implements the validation rule for the
+ * Block component.
+ */
+ at RegistryInfo(extension=ValidationRule.class)
+public class BlockValidationRule extends AbstractValidationRule {
+
+	/**
+	 * This is the default constructor.
+	 */
+	public BlockValidationRule() {
+		super();
+	}
+
+	/**
+	 * This method determines whether the rule is appropriate for
+	 * the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @return Whether the rule is appropriate
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj instanceof Block);
+	}
+
+	/**
+	 * This method validates the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @param context The context
+	 * @param l The listener
+	 */
+	public void validate(ModelObject obj, ValidationContext context,
+							ModelListener l) {
+		Block block=(Block)obj;
+
+		for (int i=0; i < block.getContents().size(); i++) {
+			context.validate(block.getContents().get(i), l);
+		}
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/ChannelListValidationRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/ChannelListValidationRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/ChannelListValidationRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 13 Mar 2008 : Initial version created by gary
+ */
+package org.scribble.validation;
+
+import org.scribble.extensions.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class implements the validation rule for the
+ * ChannelList construct.
+ */
+ at RegistryInfo(extension=ValidationRule.class)
+public class ChannelListValidationRule extends AbstractValidationRule {
+
+	/**
+	 * This is the default constructor.
+	 */
+	public ChannelListValidationRule() {
+	}
+
+	/**
+	 * This method determines whether the rule is appropriate for
+	 * the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @return Whether the rule is appropriate
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj instanceof ChannelList);
+	}
+
+	/**
+	 * This method validates the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @param context The context
+	 * @param l The listener
+	 */
+	public void validate(ModelObject obj, ValidationContext context,
+			ModelListener l) {
+		ChannelList elem=(ChannelList)obj;
+
+		for (int i=0; i < elem.getChannels().size(); i++) {
+			context.validate(elem.getChannels().get(i), l);
+		}
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/ChannelValidationRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/ChannelValidationRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/ChannelValidationRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 13 Mar 2008 : Initial version created by gary
+ */
+package org.scribble.validation;
+
+import org.scribble.extensions.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class implements the validation rule for the
+ * Channel construct.
+ */
+ at RegistryInfo(extension=ValidationRule.class)
+public class ChannelValidationRule extends AbstractValidationRule {
+
+	/**
+	 * This is the default constructor.
+	 */
+	public ChannelValidationRule() {
+	}
+
+	/**
+	 * This method determines whether the rule is appropriate for
+	 * the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @return Whether the rule is appropriate
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj instanceof Channel);
+	}
+
+	/**
+	 * This method validates the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @param context The context
+	 * @param l The listener
+	 */
+	public void validate(ModelObject obj, ValidationContext context,
+			ModelListener l) {
+		//Channel elem=(Channel)obj;
+
+		// TODO: Validate roles in the context of the channel
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/DefaultValidationContext.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/DefaultValidationContext.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/DefaultValidationContext.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,296 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 28 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.validation;
+
+import org.scribble.comparator.Comparator;
+import org.scribble.extensions.RegistryFactory;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.model.admin.ModelRepository;
+import org.scribble.util.Scope;
+
+import java.util.logging.Logger;
+
+/**
+ * This class provides the default implementation of the
+ * validation context supplied to each validation rule.
+ * 
+ */
+public class DefaultValidationContext implements ValidationContext {
+
+	/**
+	 * The constructor for the default validation context.
+	 * 
+	 * @param ref The model reference
+	 * @param rules The list of rules
+	 */
+	public DefaultValidationContext(org.scribble.model.ModelReference ref,
+							java.util.List<ValidationRule> rules) {
+		m_modelReference = ref;
+		m_rules = rules;
+		
+	}
+		
+	/**
+	 * This is the copy constructor for the default validation context.
+	 * 
+	 * @param copy The copy
+	 */
+	protected DefaultValidationContext(DefaultValidationContext copy) {
+		
+		m_modelRepository = copy.getModelRepository();
+		m_comparator = copy.getComparator();
+		
+		m_modelReference = copy.m_modelReference;
+		
+		m_rules = copy.m_rules;
+		
+		m_scope = new Scope(copy.m_scope);
+	}
+	
+	/**
+	 * This method gets the model repository.
+	 * 
+	 * @return The model repository
+	 */
+	public ModelRepository getModelRepository() {
+		if (m_modelRepository == null) {
+			m_modelRepository = (org.scribble.model.admin.ModelRepository)
+					RegistryFactory.getRegistry().getExtension(
+							org.scribble.model.admin.ModelRepository.class, null);
+		}
+		
+		return(m_modelRepository);
+	}
+	
+	/**
+	 * This method sets the model repository.
+	 * 
+	 * @param mrep The model repository
+	 */
+	public void setModelRepository(ModelRepository mrep) {
+		m_modelRepository = mrep;
+	}
+
+	/**
+	 * This method gets the comparator.
+	 * 
+	 * @return The comparator
+	 */
+	public Comparator getComparator() {
+		if (m_comparator == null) {
+			m_comparator = (org.scribble.comparator.Comparator)
+				org.scribble.extensions.RegistryFactory.getRegistry().getExtension(
+						org.scribble.comparator.Comparator.class, null);
+		}
+		
+		return(m_comparator);
+	}
+	
+	/**
+	 * This method sets the comparator.
+	 * 
+	 * @param comparator The comparator
+	 */
+	public void setComparator(Comparator comparator) {
+		m_comparator = comparator;
+	}
+
+	/**
+	 * This method returns the source model reference associated
+	 * with the definition being validated.
+	 * 
+	 * @return The model reference
+	 */
+	public ModelReference getSource() {
+		return(m_modelReference);
+	}
+
+	/**
+	 * This method returns a list of validation rules appropriate
+	 * for the notation being validated.
+	 * 
+	 * @return The list of validation rules
+	 */
+	public java.util.List<ValidationRule> getRules() {
+		return(m_rules);
+	}
+	
+	/**
+	 * This method validates a supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @param l The model listener
+	 */
+	public void validate(ModelObject obj, ModelListener l) {
+
+		logger.fine("Validate "+obj);
+		
+		if (obj instanceof Activity &&
+					((Activity)obj).isScope()) {
+			pushScope();
+		}
+		
+		if (obj instanceof Behaviour &&
+				((Behaviour)obj).isGroupingConstruct()) {
+			pushState();
+		}
+		
+		if (obj instanceof Declaration) {
+			// Check if state already exists for this name
+			if (getState(((Declaration)obj).getName()) != null) {
+				
+				l.error(new ModelIssue(obj, org.scribble.util.MessageUtil.format(
+						java.util.PropertyResourceBundle.getBundle("org.scribble.validation.Messages"),
+						"_EXISTING_DECLARATION",
+						new String[]{((Declaration)obj).getName()})));
+			} else {
+				setState(((Declaration)obj).getName(), obj);
+			}
+		}
+		
+		for (int i=0; i < getRules().size(); i++) {
+			ValidationRule rule=getRules().get(i);
+			
+			if (rule.isSupported(obj)) {
+				
+				if (rule.isBackgroundTask()) {
+					final ModelObject bobj=obj;
+					final ModelListener bl=l;
+					final ValidationRule brule=rule;
+					
+					new Thread(new Runnable() {
+						public void run() {
+							// Need to take copy of the context so
+							// that the background task is not affected
+							// by changes in the context as a result
+							// of other concurrently running validation
+							// rules
+							DefaultValidationContext newcontext=
+								new DefaultValidationContext(DefaultValidationContext.this);
+							
+							brule.validate(bobj,
+									newcontext, bl);
+						}
+					}).start();
+					
+				} else {
+					rule.validate(obj, this, l);
+				}
+			}
+		}
+		
+		if (obj instanceof Behaviour &&
+				((Behaviour)obj).isGroupingConstruct()) {
+			popState();
+		}
+
+		if (obj instanceof Activity &&
+					((Activity)obj).isScope()) {
+			popScope();
+		}
+	}
+
+	/**
+	 * This method returns the located role associated with the
+	 * current scope.
+	 * 
+	 * @return The located role
+	 */
+	public String getLocatedRole() {
+		return(m_scope.getLocatedRole());
+	}
+	
+	/**
+	 * This method sets the located role associated with the
+	 * current scope.
+	 * 
+	 * @param located The located role
+	 */
+	public void setLocatedRole(String located) {
+		m_scope.setLocatedRole(located);
+	}
+	
+	/**
+	 * This method returns the named state from the current
+	 * scope.
+	 * 
+	 * @param name The state name
+	 * @return The state value, or null if not found
+	 */
+	public Object getState(String name) {
+		return(m_scope.getState(name));
+	}
+	
+	/**
+	 * This method sets the value associated with the supplied
+	 * name in the current state scope.
+	 * 
+	 * @param name The state name
+	 * @param value The state value
+	 */
+	public void setState(String name, Object value) {
+		m_scope.setState(name, value);
+	}
+
+	/**
+	 * This method pushes the current set of declarations onto the
+	 * stack.
+	 */
+	public void pushState() {
+		m_scope.pushState();
+	}
+	
+	/**
+	 * This method pops the current set of declarations off the stack.
+	 */
+	public void popState() {
+		m_scope.popState();
+	}
+	
+	/**
+	 * This method pushes the current scope onto a stack.
+	 */
+	public void pushScope() {
+		m_scopeStack.add(0, m_scope);
+		m_scope = new Scope();
+	}
+	
+	/**
+	 * This method pops the current scope from the stack.
+	 */
+	public void popScope() {
+		if (m_scopeStack.size() > 0) {
+			m_scope = m_scopeStack.remove(0);
+		} else {
+			logger.severe("No state entry to pop from stack");
+		}
+	}
+		
+	private static Logger logger = Logger.getLogger("org.scribble.validation");
+
+	private ModelRepository m_modelRepository=null;
+	private Comparator m_comparator=null;
+	private ModelReference m_modelReference=null;
+	private java.util.List<ValidationRule> m_rules=new java.util.Vector<ValidationRule>();
+	private Scope m_scope=new Scope();
+	private java.util.List<Scope> m_scopeStack=new java.util.Vector<Scope>();
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/DefaultValidator.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/DefaultValidator.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/DefaultValidator.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,153 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 21 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.validation;
+
+import java.util.logging.Logger;
+
+import org.scribble.comparator.Comparator;
+import org.scribble.extensions.RegistryFactory;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.model.admin.ModelRepository;
+
+/**
+ * This class provides the default implementation of the validator
+ * interface.
+ */
+ at RegistryInfo(extension=Validator.class)
+public class DefaultValidator implements Validator {
+
+	/**
+	 * This method gets the model repository.
+	 * 
+	 * @return The model repository
+	 */
+	public ModelRepository getModelRepository() {
+		if (m_modelRepository == null) {
+			m_modelRepository = (org.scribble.model.admin.ModelRepository)
+					RegistryFactory.getRegistry().getExtension(
+							org.scribble.model.admin.ModelRepository.class, null);
+		}
+		
+		return(m_modelRepository);
+	}
+	
+	/**
+	 * This method sets the model repository.
+	 * 
+	 * @param mrep The model repository
+	 */
+	public void setModelRepository(ModelRepository mrep) {
+		m_modelRepository = mrep;
+	}
+
+	/**
+	 * This method gets the comparator.
+	 * 
+	 * @return The comparator
+	 */
+	public Comparator getComparator() {
+		return(m_comparator);
+	}
+	
+	/**
+	 * This method sets the comparator.
+	 * 
+	 * @param comparator The comparator
+	 */
+	public void setComparator(Comparator comparator) {
+		m_comparator = comparator;
+	}
+
+	/**
+	 * This method validates the supplied model, based on the supplied
+	 * notation code, and reports any relevant details to the
+	 * validation listener.
+	 * 
+	 * @param model The model
+	 * @param ref The model reference
+	 * @param l The listener
+	 * @return Whether model was validated
+	 */
+	public boolean validate(Model model, ModelReference ref, ModelListener l) {
+		boolean f_validate=false;
+		
+		// Prevent the same model reference being validated
+		// multiple times concurrently
+		synchronized(m_inValidation) {
+			if (m_inValidation.contains(ref) == false) {
+				if (logger.isLoggable(java.util.logging.Level.FINEST)) {
+					logger.finest("Set 'in validation' status of '"+ref+"'");
+				}
+				
+				f_validate = true;
+
+				m_inValidation.add(ref);
+			} else {
+				if (logger.isLoggable(java.util.logging.Level.FINEST)) {
+					logger.finest("Skip validation of '"+ref+"'");
+				}
+			}
+		}
+		
+		if (f_validate) {
+			try {
+				if (logger.isLoggable(java.util.logging.Level.FINEST)) {
+					logger.finest("Validate '"+ref+"'");
+				}
+				
+				java.util.List<Object> ruleObjects=
+					org.scribble.extensions.RegistryFactory.getRegistry().
+								getExtensions(ValidationRule.class, ref.getNotation());
+				java.util.List<ValidationRule> rules=
+					new java.util.Vector<ValidationRule>();
+				
+				// Transfer to typed list
+				for (int i=0; i < ruleObjects.size(); i++) {
+					if (ruleObjects.get(i) instanceof ValidationRule) {
+						rules.add((ValidationRule)ruleObjects.get(i));
+					}
+				}
+
+				DefaultValidationContext context=new DefaultValidationContext(ref, rules);
+				context.setModelRepository(getModelRepository());
+				context.setComparator(getComparator());
+			
+				context.validate(model, l);
+			} finally {
+				synchronized(m_inValidation) {
+					if (logger.isLoggable(java.util.logging.Level.FINEST)) {
+						logger.finest("Clear 'in validation' status of '"+ref+"'");
+					}
+					m_inValidation.remove(ref);
+				}
+			}
+		}
+		
+		return(f_validate);
+	}
+	
+	private static Logger logger = Logger.getLogger("org.scribble.validation");
+
+	private ModelRepository m_modelRepository=null;
+	private Comparator m_comparator=null;
+	private static java.util.List<ModelReference> m_inValidation=new java.util.Vector<ModelReference>();
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/InteractionValidationRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/InteractionValidationRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/InteractionValidationRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 28 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.validation;
+
+import org.scribble.extensions.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class implements the validation rule for the
+ * interaction.
+ */
+ at RegistryInfo(extension=ValidationRule.class)
+public class InteractionValidationRule extends AbstractValidationRule {
+
+	/**
+	 * This is the default constructor.
+	 */
+	public InteractionValidationRule() {
+	}
+
+	/**
+	 * This method determines whether the rule is appropriate for
+	 * the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @return Whether the rule is appropriate
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj instanceof Interaction);
+	}
+
+	/**
+	 * This method validates the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @param context The context
+	 * @param l The listener
+	 */
+	public void validate(ModelObject obj, ValidationContext context,
+			ModelListener l) {
+		Interaction interaction=(Interaction)obj;
+		
+		if (interaction.getMessageSignature() != null) {
+			context.validate(interaction.getMessageSignature(), l);			
+		}
+		
+		// Check that between the channel and the interaction, there
+		// are 'to' and 'from' roles defined
+		if (interaction.getFromRole() == null &&
+				(interaction.getChannel() == null ||
+				interaction.getChannel().getFromRole() == null)) {
+			
+			// Check if local model and 'to' is not the same as the
+			// located role
+			if (context.getLocatedRole() == null ||
+					interaction.getToRole() == null ||
+					context.getLocatedRole().equals(
+							interaction.getToRole().getName())) {
+			
+				l.error(new ModelIssue(obj, org.scribble.util.MessageUtil.format(
+						java.util.PropertyResourceBundle.getBundle("org.scribble.validation.Messages"),
+						"_INTERACTION_ROLE",
+						new String[]{"from"})));
+			}
+		}
+
+		if (interaction.getToRole() == null &&
+				(interaction.getChannel() == null ||
+				interaction.getChannel().getToRole() == null)) {
+			
+			// Check if local model and 'from' is not the same as the
+			// located role
+			if (context.getLocatedRole() == null ||
+					interaction.getFromRole() == null ||
+					context.getLocatedRole().equals(
+							interaction.getFromRole().getName())) {
+			
+				l.error(new ModelIssue(obj, org.scribble.util.MessageUtil.format(
+						java.util.PropertyResourceBundle.getBundle("org.scribble.validation.Messages"),
+						"_INTERACTION_ROLE",
+						new String[]{"to"})));
+			}
+		}
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/MessageSignatureValidationRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/MessageSignatureValidationRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/MessageSignatureValidationRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 13 Mar 2008 : Initial version created by gary
+ */
+package org.scribble.validation;
+
+import org.scribble.extensions.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class implements the validation rule for the
+ * MessageSignature construct.
+ */
+ at RegistryInfo(extension=ValidationRule.class)
+public class MessageSignatureValidationRule extends AbstractValidationRule {
+
+	/**
+	 * This is the default constructor.
+	 */
+	public MessageSignatureValidationRule() {
+	}
+
+	/**
+	 * This method determines whether the rule is appropriate for
+	 * the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @return Whether the rule is appropriate
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj instanceof MessageSignature);
+	}
+
+	/**
+	 * This method validates the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @param context The context
+	 * @param l The listener
+	 */
+	public void validate(ModelObject obj, ValidationContext context,
+			ModelListener l) {
+		MessageSignature ms=(MessageSignature)obj;
+
+		for (int i=0; i < ms.getTypes().size(); i++) {
+			context.validate(ms.getTypes().get(i), l);
+		}
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/Messages.properties
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/Messages.properties	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/Messages.properties	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,24 @@
+# /*
+# * Copyright 2007 Pi4 Technologies Ltd
+# *
+# * 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.
+# *
+# *
+# * Change History:
+# * 2 Nov 2007 : Initial version created by gary
+# */
+
+_EXISTING_DECLARATION=Declaration already exists for name '{0}'
+_NOT_FOUND_BOUND_DECLARATION=Bound declaration '{0}' not found in definition '{1}' 
+_NOT_FOUND_REFERENCE=Definition '{0}' of type '{1}' could not be found
+_INTERACTION_ROLE=Interaction needs to define a '{0}' role

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/ModelReferenceValidationRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/ModelReferenceValidationRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/ModelReferenceValidationRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,118 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 2 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.validation;
+
+import org.scribble.extensions.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class implements the validation rule for the
+ * model reference.
+ */
+ at RegistryInfo(extension=ValidationRule.class)
+public class ModelReferenceValidationRule extends AbstractValidationRule {
+
+	/**
+	 * This is the default constructor.
+	 */
+	public ModelReferenceValidationRule() {
+	}
+
+	/**
+	 * This method determines whether the rule is appropriate for
+	 * the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @return Whether the rule is appropriate
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj.getClass() == ModelReference.class);
+	}
+
+	/**
+	 * This method validates the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @param context The context
+	 * @param l The listener
+	 */
+	public void validate(ModelObject obj, ValidationContext context,
+			ModelListener l) {
+		ModelReference ref=(ModelReference)obj;
+		
+/* GPB: TO REMOVE			
+		if (ref.isInner() == false) {
+			org.scribble.model.admin.ModelRepository mrep=
+				(org.scribble.model.admin.ModelRepository)
+				org.scribble.extensions.RegistryFactory.getRegistry().getExtension(
+						org.scribble.model.admin.ModelRepository.class,
+									null);
+			
+			boolean f_exists=mrep.exists(ref, context.getSource());
+			
+			// Check if local reference, but has a global model
+			if (f_exists == false && ref.getLocatedRole() != null) {
+				
+				ModelReference tmpref=new ModelReference(ref.getNamespace(),
+						ref.getLocalpart(), null, ref.getNotation());
+				
+				mrep.locate(tmpref, ref);
+				
+				f_exists = mrep.exists(tmpref, context.getSource());
+			}
+			
+			if (f_exists == false && ref.useImplementations()) {
+				
+				org.scribble.model.admin.DependencyManager dm=
+					(org.scribble.model.admin.DependencyManager)
+					org.scribble.extensions.RegistryFactory.getRegistry().getExtension(
+							org.scribble.model.admin.DependencyManager.class, null);
+				
+				if (dm != null) {
+					java.util.List<ModelReference> impls=
+							dm.getDependents(ref, DependencyType.Implements);
+					
+					for (int i=0; f_exists == false &&
+								i < impls.size(); i++) {
+						f_exists = mrep.exists(impls.get(i),
+								context.getSource());
+					}
+				}				
+			}
+			
+			if (f_exists == false) {
+				String name=ref.getAlias();
+				
+				if (ref.getLocatedRole() != null) {
+					name += ModelReference.LOCATED_REFERENCE_SEPARATOR+
+									ref.getLocatedRole();
+				}
+				
+				l.error(new ModelIssue(obj, org.scribble.util.MessageUtil.format(
+						java.util.PropertyResourceBundle.getBundle("org.scribble.validation.Messages"),
+						"_NOT_FOUND_REFERENCE",
+						new String[]{name,ref.getNotation()})));
+			}
+		}
+*/
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/ModelValidationRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/ModelValidationRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/ModelValidationRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,133 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 2 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.validation;
+
+import java.util.logging.Logger;
+
+import org.scribble.extensions.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.DefaultModelListener;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class implements the validation rule for the
+ * model.
+ */
+ at RegistryInfo(extension=ValidationRule.class)
+public class ModelValidationRule extends AbstractValidationRule {
+
+	/**
+	 * This is the default constructor.
+	 */
+	public ModelValidationRule() {
+		super(true);	// Background task
+	}
+
+	/**
+	 * This method determines whether the rule is appropriate for
+	 * the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @return Whether the rule is appropriate
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj instanceof Model);
+	}
+
+	/**
+	 * This method validates the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @param context The context
+	 * @param l The listener
+	 */
+	public void validate(ModelObject obj, ValidationContext context,
+							ModelListener l) {
+		Model model=(Model)obj;
+		ModelReference ref=context.getSource();
+		
+/* GPB: TO REMOVE		
+		java.util.List<ModelReference> refs=context.getDependencyManager().getDependencies(ref,
+						DependencyType.ConformsTo);
+		
+		java.util.List<ModelReference> implsRefs=context.getDependencyManager().getDependencies(ref,
+						DependencyType.Implements);
+		
+		if (refs == null && implsRefs != null) {
+			refs = implsRefs;
+		} else if (refs != null && implsRefs != null) {
+			for (int i=0; i < implsRefs.size(); i++) {
+				if (refs.contains(implsRefs.get(i)) == false) {
+					refs.add(implsRefs.get(i));
+				}
+			}
+		}
+	
+		if (logger.isLoggable(java.util.logging.Level.FINEST)) {
+			logger.finest(Thread.currentThread()+" Validate dependencies: "+ref+
+						", No. of dependent models="+refs.size());
+		}
+		
+		for (int i=0; refs != null && i < refs.size(); i++) {
+				
+			DefaultModelListener tmpml=new DefaultModelListener();
+			
+			java.util.List<ModelInfo> refModels=
+					context.getModelRepository().getModels(refs.get(i), tmpml);
+
+			if (logger.isLoggable(java.util.logging.Level.FINEST)) {
+				logger.finest(Thread.currentThread()+" Checking ref: "+refs.get(i)+
+							" No. of models="+refModels.size());
+			}	
+			
+			for (int j=0; j < refModels.size(); j++) {
+				
+				if (logger.isLoggable(java.util.logging.Level.FINEST)) {
+					logger.finest(Thread.currentThread()+" Checking model info: "+refModels.get(j));
+				}	
+				
+				// Check that reference resource can be accessed
+				// from the resource being validated.
+				// Check that the reference resource exists - and
+				// if does not exist, then check that the source
+				// associated with the reference is different from
+				// the resource being validated - i.e. that it
+				// is not derived from the source being validated,
+				// otherwise comparison would be pointless.
+				if (context.getModelRepository().canAccess(context.getSource(),
+							refModels.get(j).getSource(), false) &&
+						(context.getModelRepository().exists(refs.get(i), null) ||
+						context.getSource().equals(refModels.get(j).getSource()) == false)) {
+
+					if (logger.isLoggable(java.util.logging.Level.FINEST)) {
+						logger.finest(Thread.currentThread()+" Compare: "+context.getSource());
+					}
+					
+					context.getComparator().compare(model, context.getSource(),
+							refModels.get(j).getModel(),
+								refModels.get(j).getSource(), l);
+				}
+			}
+		}
+		*/
+	}
+	
+	private static Logger logger = Logger.getLogger("org.scribble.validation");
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/RoleListValidationRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/RoleListValidationRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/RoleListValidationRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 13 Mar 2008 : Initial version created by gary
+ */
+package org.scribble.validation;
+
+import org.scribble.extensions.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class implements the validation rule for the
+ * RoleList construct.
+ */
+ at RegistryInfo(extension=ValidationRule.class)
+public class RoleListValidationRule extends AbstractValidationRule {
+
+	/**
+	 * This is the default constructor.
+	 */
+	public RoleListValidationRule() {
+	}
+
+	/**
+	 * This method determines whether the rule is appropriate for
+	 * the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @return Whether the rule is appropriate
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj instanceof RoleList);
+	}
+
+	/**
+	 * This method validates the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @param context The context
+	 * @param l The listener
+	 */
+	public void validate(ModelObject obj, ValidationContext context,
+			ModelListener l) {
+		RoleList elem=(RoleList)obj;
+
+		for (int i=0; i < elem.getRoles().size(); i++) {
+			context.validate(elem.getRoles().get(i), l);
+		}
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/RoleValidationRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/RoleValidationRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/RoleValidationRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 13 Mar 2008 : Initial version created by gary
+ */
+package org.scribble.validation;
+
+import org.scribble.extensions.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class implements the validation rule for the
+ * Role construct.
+ */
+ at RegistryInfo(extension=ValidationRule.class)
+public class RoleValidationRule extends AbstractValidationRule {
+
+	/**
+	 * This is the default constructor.
+	 */
+	public RoleValidationRule() {
+	}
+
+	/**
+	 * This method determines whether the rule is appropriate for
+	 * the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @return Whether the rule is appropriate
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj instanceof Role);
+	}
+
+	/**
+	 * This method validates the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @param context The context
+	 * @param l The listener
+	 */
+	public void validate(ModelObject obj, ValidationContext context,
+			ModelListener l) {
+		//Role elem=(Role)obj;
+
+		// TODO: Validate role
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/TypeReferenceValidationRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/TypeReferenceValidationRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/TypeReferenceValidationRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,118 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 2 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.validation;
+
+import org.scribble.extensions.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class implements the validation rule for the
+ * model reference.
+ */
+ at RegistryInfo(extension=ValidationRule.class)
+public class TypeReferenceValidationRule extends AbstractValidationRule {
+
+	/**
+	 * This is the default constructor.
+	 */
+	public TypeReferenceValidationRule() {
+	}
+
+	/**
+	 * This method determines whether the rule is appropriate for
+	 * the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @return Whether the rule is appropriate
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj.getClass() == TypeReference.class);
+	}
+
+	/**
+	 * This method validates the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @param context The context
+	 * @param l The listener
+	 */
+	public void validate(ModelObject obj, ValidationContext context,
+			ModelListener l) {
+		ModelReference ref=(ModelReference)obj;
+		
+/* GPB: TO REMOVE		
+		if (ref.isInner() == false) {
+			org.scribble.model.admin.ModelRepository mrep=
+				(org.scribble.model.admin.ModelRepository)
+				org.scribble.extensions.RegistryFactory.getRegistry().getExtension(
+						org.scribble.model.admin.ModelRepository.class,
+									null);
+			
+			boolean f_exists=mrep.exists(ref, context.getSource());
+			
+			// Check if local reference, but has a global model
+			if (f_exists == false && ref.getLocatedRole() != null) {
+				
+				ModelReference tmpref=new ModelReference(ref.getNamespace(),
+						ref.getLocalpart(), null, ref.getNotation());
+				
+				mrep.locate(tmpref, ref);
+				
+				f_exists = mrep.exists(tmpref, context.getSource());
+			}
+			
+			if (f_exists == false && ref.useImplementations()) {
+				
+				org.scribble.model.admin.DependencyManager dm=
+					(org.scribble.model.admin.DependencyManager)
+					org.scribble.extensions.RegistryFactory.getRegistry().getExtension(
+							org.scribble.model.admin.DependencyManager.class, null);
+				
+				if (dm != null) {
+					java.util.List<ModelReference> impls=
+							dm.getDependents(ref, DependencyType.Implements);
+					
+					for (int i=0; f_exists == false &&
+								i < impls.size(); i++) {
+						f_exists = mrep.exists(impls.get(i),
+								context.getSource());
+					}
+				}				
+			}
+			
+			if (f_exists == false) {
+				String name=ref.getAlias();
+				
+				if (ref.getLocatedRole() != null) {
+					name += ModelReference.LOCATED_REFERENCE_SEPARATOR+
+									ref.getLocatedRole();
+				}
+				
+				l.error(new ModelIssue(obj, org.scribble.util.MessageUtil.format(
+						java.util.PropertyResourceBundle.getBundle("org.scribble.validation.Messages"),
+						"_NOT_FOUND_REFERENCE",
+						new String[]{name,ref.getNotation()})));
+			}
+		}
+		*/
+	}
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/ValidationContext.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/ValidationContext.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/ValidationContext.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 28 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.validation;
+
+import org.scribble.comparator.Comparator;
+import org.scribble.model.ModelObject;
+import org.scribble.model.ModelReference;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.model.admin.ModelRepository;
+
+/**
+ * This interface represents the context provided to all
+ * validation rules.
+ * 
+ */
+public interface ValidationContext {
+	
+	/**
+	 * This method gets the model repository.
+	 * 
+	 * @return The model repository
+	 */
+	public ModelRepository getModelRepository();
+	
+	/**
+	 * This method gets the comparator.
+	 * 
+	 * @return The comparator
+	 */
+	public Comparator getComparator();
+	
+	/**
+	 * This method validates a supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @param l The model listener
+	 */
+	public void validate(ModelObject obj, ModelListener l);
+	
+	/**
+	 * This method returns the source model reference associated
+	 * with the definition being validated.
+	 * 
+	 * @return The model reference
+	 */
+	public ModelReference getSource();
+	
+	/**
+	 * This method returns the located role associated with the
+	 * current scope.
+	 * 
+	 * @return The located role
+	 */
+	public String getLocatedRole();
+	
+	/**
+	 * This method sets the located role associated with the
+	 * current scope.
+	 * 
+	 * @param located The located role
+	 */
+	public void setLocatedRole(String located);
+	
+	/**
+	 * This method returns the named state from the current
+	 * scope.
+	 * 
+	 * @param name The state name
+	 * @return The state value, or null if not found
+	 */
+	public Object getState(String name);
+	
+	/**
+	 * This method sets the value associated with the supplied
+	 * name in the current state.
+	 * 
+	 * @param name The state name
+	 * @param value The state value
+	 */
+	public void setState(String name, Object value);
+
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/ValidationRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/ValidationRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/ValidationRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 28 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.validation;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This interface represents a validation rule associated with
+ * a Scribble language construct.
+ */
+public interface ValidationRule {
+
+	/**
+	 * This method determines whether the validation rule is
+	 * appropriate for the supplied model object.
+	 * 
+	 * @param obj The model object to be validated
+	 * @return Whether the valid rule is relevant for the
+	 * 				model object
+	 */
+	public boolean isSupported(ModelObject obj);
+	
+	/**
+	 * This method determines whether this validation task
+	 * should be performed in the background.
+	 * 
+	 * @return Whether the validation should be performed
+	 * 			as a background task
+	 */
+	public boolean isBackgroundTask();
+	
+	/**
+	 * This method validates the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @param context The context
+	 * @param l The listener
+	 */
+	public void validate(ModelObject obj, ValidationContext context,
+								ModelListener l);
+	
+}

Added: trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/Validator.java
===================================================================
--- trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/Validator.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/main/java/org/scribble/validation/Validator.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 20 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.validation;
+
+import org.scribble.comparator.Comparator;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.model.admin.ModelRepository;
+
+/**
+ * This interface represents the validator for Scribble models.
+ */
+public interface Validator {
+
+	/**
+	 * This method gets the model repository.
+	 * 
+	 * @return The model repository
+	 */
+	public ModelRepository getModelRepository();
+	
+	/**
+	 * This method sets the model repository.
+	 * 
+	 * @param mrep The model repository
+	 */
+	public void setModelRepository(ModelRepository mrep);
+	
+	/**
+	 * This method gets the comparator.
+	 * 
+	 * @return The comparator
+	 */
+	public Comparator getComparator();
+	
+	/**
+	 * This method sets the comparator.
+	 * 
+	 * @param comparator The comparator
+	 */
+	public void setComparator(Comparator comparator);
+	
+	/**
+	 * This method validates the supplied model, based on the supplied
+	 * notation code associated with the model reference, and reports
+	 * any relevant details to the validation listener.
+	 * 
+	 * @param model The model
+	 * @param ref The model reference
+	 * @param l The listener
+	 * @return Whether the model was validated
+	 */
+	public boolean validate(Model model, ModelReference ref,
+							ModelListener l);
+
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/ScribbleCoreAllTests.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/ScribbleCoreAllTests.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/ScribbleCoreAllTests.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 23 Feb 2009 : Initial version created by gary
+ */
+package org.scribble;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class ScribbleCoreAllTests {
+
+	public static Test suite() {
+		TestSuite suite = new TestSuite();
+
+		suite.addTestSuite(org.scribble.comparator.BlockComparatorRuleTest.class);
+		suite.addTestSuite(org.scribble.comparator.ChannelComparatorRuleTest.class);
+		suite.addTestSuite(org.scribble.comparator.DefaultNameMapTest.class);
+		suite.addTestSuite(org.scribble.comparator.GlobalToLocalModelComparatorRuleTest.class);
+
+		return suite;
+	}
+}
\ No newline at end of file

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/comparator/BlockComparatorRuleTest.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/comparator/BlockComparatorRuleTest.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/comparator/BlockComparatorRuleTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 23 Feb 2009 : Initial version created by gary
+ */
+package org.scribble.comparator;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.*;
+
+import junit.framework.TestCase;
+
+public class BlockComparatorRuleTest extends TestCase {
+
+	public void testCompareShallow() {
+		BlockComparatorRule rule=new BlockComparatorRule();
+		
+		DefaultComparatorContext context=
+				new DefaultComparatorContext(new ModelReference("test"),
+							new ModelReference("test"), null);
+		
+		Block main=new Block();
+		Block reference=new Block();
+		
+		DefaultModelListener l=new DefaultModelListener();
+		
+		boolean result=rule.compare(context, main, reference, l, false);
+		
+		if (result == false) {
+			fail("Shallow comparator failed");
+		}
+	}
+
+	public void testCompareDeep() {
+		BlockComparatorRule rule=new BlockComparatorRule();
+		
+		DefaultComparatorContext context=
+				new DefaultComparatorContext(new ModelReference("test"),
+							new ModelReference("test"), null);
+		
+		Block main=new Block();
+		Block reference=new Block();
+		
+		DefaultModelListener l=new DefaultModelListener();
+		
+		boolean result=rule.compare(context, main, reference, l, true);
+		
+		if (result == true) {
+			fail("Deep comparator should fail - currently not supported");
+		}
+	}
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/comparator/ChannelComparatorRuleTest.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/comparator/ChannelComparatorRuleTest.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/comparator/ChannelComparatorRuleTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,133 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 23 Feb 2009 : Initial version created by gary
+ */
+package org.scribble.comparator;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.*;
+
+import junit.framework.TestCase;
+
+public class ChannelComparatorRuleTest extends TestCase {
+
+	private static final String NAME2 = "name2";
+	private static final String NAME1 = "name1";
+
+	public void testCompareSameNamesNoNameMapping() {
+		ChannelComparatorRule rule=new ChannelComparatorRule();
+		
+		DefaultComparatorContext context=
+				new DefaultComparatorContext(new ModelReference("test"),
+							new ModelReference("test"), null);
+		
+		Channel main=new Channel();
+		main.setName(NAME1);
+		
+		Channel reference=new Channel();
+		reference.setName(NAME1);
+		
+		DefaultModelListener l=new DefaultModelListener();
+		
+		boolean result=rule.compare(context, main, reference, l, false);
+		
+		if (result == false) {
+			fail("Compare of same names, with no mapping, failed");
+		}
+	}
+
+	public void testCompareDiffNamesWithNoNameMapping() {
+		ChannelComparatorRule rule=new ChannelComparatorRule();
+		
+		DefaultComparatorContext context=
+				new DefaultComparatorContext(new ModelReference("test"),
+							new ModelReference("test"), null);
+		
+		Channel main=new Channel();
+		main.setName(NAME1);
+		
+		Channel reference=new Channel();
+		reference.setName(NAME2);
+		
+		DefaultModelListener l=new DefaultModelListener();
+		
+		boolean result=rule.compare(context, main, reference, l, false);
+		
+		if (result == true) {
+			fail("Compare of diff names, with no mapping, should have failed");
+		}
+	}
+
+	public void testCompareWithMainNameMapping() {
+		ChannelComparatorRule rule=new ChannelComparatorRule();
+		
+		DefaultComparatorContext context=
+				new DefaultComparatorContext(new ModelReference("test"),
+							new ModelReference("test"), null);
+		
+		java.util.Map<String,String> nameMap=new java.util.HashMap<String, String>();
+		NameMap map=new DefaultNameMap(nameMap);
+		
+		nameMap.put(NAME1, NAME2);
+		
+		context.pushMainNameMap(map);
+		
+		Channel main=new Channel();
+		main.setName(NAME1);
+		
+		Channel reference=new Channel();
+		reference.setName(NAME2);
+		
+		DefaultModelListener l=new DefaultModelListener();
+		
+		boolean result=rule.compare(context, main, reference, l, false);
+		
+		if (result == false) {
+			fail("Compare of diff names, with main name mapping, failed");
+		}
+	}
+
+	public void testCompareWithRefNameMapping() {
+		ChannelComparatorRule rule=new ChannelComparatorRule();
+		
+		DefaultComparatorContext context=
+				new DefaultComparatorContext(new ModelReference("test"),
+							new ModelReference("test"), null);
+		
+		java.util.Map<String,String> nameMap=new java.util.HashMap<String, String>();
+		NameMap map=new DefaultNameMap(nameMap);
+		
+		nameMap.put(NAME2, NAME1);
+		
+		context.pushReferenceNameMap(map);
+		
+		Channel main=new Channel();
+		main.setName(NAME1);
+		
+		Channel reference=new Channel();
+		reference.setName(NAME2);
+		
+		DefaultModelListener l=new DefaultModelListener();
+		
+		boolean result=rule.compare(context, main, reference, l, false);
+		
+		if (result == false) {
+			fail("Compare of diff names, with reference name mapping, failed");
+		}
+	}
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/comparator/DefaultNameMapTest.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/comparator/DefaultNameMapTest.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/comparator/DefaultNameMapTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 23 Feb 2009 : Initial version created by gary
+ */
+package org.scribble.comparator;
+
+import junit.framework.TestCase;
+
+public class DefaultNameMapTest extends TestCase {
+
+	public void testGetSameName() {
+		java.util.Map<String, String> nameMap=
+				new java.util.HashMap<String, String>();
+		
+		DefaultNameMap map=new DefaultNameMap(nameMap);
+		
+		String testName="fred";
+		
+		String name=map.getName(testName);
+		
+		if (name == null) {
+			fail("Name should not be null");
+		}
+		
+		if (name.equals(testName) == false) {
+			fail("Returned name should be same as requested name");
+		}
+	}
+
+	public void testGetMappedName() {
+		java.util.Map<String, String> nameMap=
+				new java.util.HashMap<String, String>();
+		
+		DefaultNameMap map=new DefaultNameMap(nameMap);
+		
+		String testName="fred";
+		String toName="joe";
+		
+		nameMap.put(testName, toName);
+		
+		String name=map.getName(testName);
+		
+		if (name == null) {
+			fail("Name should not be null");
+		}
+		
+		if (name.equals(toName) == false) {
+			fail("Returned name should be '"+
+					toName+"', but was: "+name);
+		}
+	}
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/comparator/GlobalToLocalModelComparatorRuleTest.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/comparator/GlobalToLocalModelComparatorRuleTest.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/comparator/GlobalToLocalModelComparatorRuleTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,245 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 28 Feb 2009 : Initial version created by gary
+ */
+package org.scribble.comparator;
+
+import org.scribble.extensions.RegistryFactory;
+import org.scribble.model.*;
+import org.scribble.model.admin.*;
+
+import junit.framework.TestCase;
+
+public class GlobalToLocalModelComparatorRuleTest extends TestCase {
+
+	private static final String TEST_NOTATION = "test";
+	private static final String TEST_ROLE = "testRole";
+	private static final String TEST_MODEL = "testModel";
+
+	public void testIsSupported1() {
+		GlobalToLocalModelComparatorRule rule=
+				new GlobalToLocalModelComparatorRule();
+		
+		TestModel mainModel=new TestModel();	
+		Definition defn=new Definition(){
+			private static final long serialVersionUID = 1L;
+		};
+		
+		LocatedName mainMName=new LocatedName();
+		defn.setLocatedName(mainMName);
+		
+		mainModel.getDefinitions().add(defn);
+		
+		TestModel refModel=new TestModel();
+		defn = new Definition(){
+			private static final long serialVersionUID = 1L;
+		};
+		
+		LocatedName refMName=new LocatedName();
+		defn.setLocatedName(refMName);
+		
+		refModel.getDefinitions().add(defn);
+				
+		boolean result=rule.isComparisonSupported(mainModel, refModel);
+		
+		if (result == true) {
+			fail("Two global models should not be supported");
+		}
+		
+	}
+
+	public void testIsSupported2() {
+		GlobalToLocalModelComparatorRule rule=
+				new GlobalToLocalModelComparatorRule();
+		
+		TestModel mainModel=new TestModel();		
+		Definition defn=new Definition(){
+			private static final long serialVersionUID = 1L;
+		};
+
+		LocatedName mainMName=new LocatedName();
+		mainMName.setRole(new Role());
+		defn.setLocatedName(mainMName);
+
+		mainModel.getDefinitions().add(defn);
+
+		TestModel refModel=new TestModel();
+		defn=new Definition(){
+			private static final long serialVersionUID = 1L;
+		};
+
+		LocatedName refMName=new LocatedName();
+		defn.setLocatedName(refMName);
+		
+		refModel.getDefinitions().add(defn);
+				
+		boolean result=rule.isComparisonSupported(mainModel, refModel);
+		
+		if (result == true) {
+			fail("Local main model should not be supported");
+		}
+		
+	}
+
+	public void testIsSupported3() {
+		GlobalToLocalModelComparatorRule rule=
+				new GlobalToLocalModelComparatorRule();
+		
+		TestModel mainModel=new TestModel();		
+		Definition defn=new Definition(){
+			private static final long serialVersionUID = 1L;
+		};
+
+		LocatedName mainMName=new LocatedName();
+		mainMName.setRole(new Role());
+		defn.setLocatedName(mainMName);
+		mainModel.getDefinitions().add(defn);
+		
+		TestModel refModel=new TestModel();
+		defn=new Definition(){
+			private static final long serialVersionUID = 1L;
+		};
+
+		LocatedName refMName=new LocatedName();
+		refMName.setRole(new Role());
+		defn.setLocatedName(refMName);
+		refModel.getDefinitions().add(defn);
+				
+		boolean result=rule.isComparisonSupported(mainModel, refModel);
+		
+		if (result == true) {
+			fail("Two local models should not be supported");
+		}
+		
+	}
+
+	public void testIsSupported4() {
+		GlobalToLocalModelComparatorRule rule=
+				new GlobalToLocalModelComparatorRule();
+		
+		TestModel mainModel=new TestModel();		
+		Definition defn=new Definition(){
+			private static final long serialVersionUID = 1L;
+		};
+
+		LocatedName mainMName=new LocatedName();
+		defn.setLocatedName(mainMName);
+		mainModel.getDefinitions().add(defn);
+		
+		TestModel refModel=new TestModel();
+		defn=new Definition(){
+			private static final long serialVersionUID = 1L;
+		};
+
+		LocatedName refMName=new LocatedName();
+		refMName.setRole(new Role());
+		defn.setLocatedName(refMName);
+		refModel.getDefinitions().add(defn);
+				
+		boolean result=rule.isComparisonSupported(mainModel, refModel);
+		
+		if (result == false) {
+			fail("Local ref model should be supported");
+		}
+		
+	}
+
+	public void testCompare() {
+		GlobalToLocalModelComparatorRule rule=
+				new GlobalToLocalModelComparatorRule();
+		
+		TestModel main=new TestModel();		
+		Definition defn=new Definition(){
+			private static final long serialVersionUID = 1L;
+		};
+
+		LocatedName mainMName=new LocatedName();
+		mainMName.setName(TEST_MODEL);
+		defn.setLocatedName(mainMName);
+		main.getDefinitions().add(defn);
+		
+		final TestModel mainProjected=new TestModel();		
+		defn=new Definition(){
+			private static final long serialVersionUID = 1L;
+		};
+
+		LocatedName mainMNameP=new LocatedName();
+		mainMNameP.setName(TEST_MODEL);
+		Role mainRoleP=new Role();
+		mainRoleP.setName(TEST_ROLE);
+		mainMNameP.setRole(mainRoleP);
+		defn.setLocatedName(mainMNameP);
+		mainProjected.getDefinitions().add(defn);
+		
+		TestModel reference=new TestModel();
+		defn=new Definition(){
+			private static final long serialVersionUID = 1L;
+		};
+		
+		LocatedName refMName=new LocatedName();
+		refMName.setName(TEST_MODEL);
+		Role refRole=new Role();
+		refRole.setName(TEST_ROLE);
+		refMName.setRole(refRole);
+		defn.setLocatedName(refMName);
+		reference.getDefinitions().add(defn);
+		
+		java.util.Map<Class<?>,Object> map=
+			new java.util.HashMap<Class<?>,Object>();
+		
+		org.scribble.projector.TestProjector projector=
+			new org.scribble.projector.TestProjector();
+		
+		map.put(org.scribble.projector.Projector.class,
+							projector);
+		
+		projector.setProjectedMode(main, mainProjected);
+		
+		org.scribble.extensions.TestTypeMapRegistry reg=
+			new org.scribble.extensions.TestTypeMapRegistry(map);
+		
+		RegistryFactory.setRegistry(reg);
+		
+		DefaultModelListener l=new DefaultModelListener();
+		
+		java.util.List<ComparatorRule> rules=
+					new java.util.Vector<ComparatorRule>();
+		
+		org.scribble.comparator.TestComparatorRule comparatorRule=
+			new org.scribble.comparator.TestComparatorRule(TestModel.class,
+					TestModel.class, true) {
+			
+			public boolean compare(ComparatorContext context, ModelObject main,
+					ModelObject reference, ModelListener l, boolean deep) {
+				return(mainProjected == main);
+			}
+		};
+		
+		rules.add(comparatorRule);
+		
+		DefaultComparatorContext context=
+			new DefaultComparatorContext(new ModelReference(TEST_NOTATION),
+						new ModelReference(TEST_NOTATION), rules);
+	
+		boolean result=rule.compare(context, main, reference, l, false);
+		
+		if (result == false) {
+			fail("Comparator failed");
+		}
+	}
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/comparator/InteractionComparatorRuleTest.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/comparator/InteractionComparatorRuleTest.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/comparator/InteractionComparatorRuleTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,642 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 28 Feb 2009 : Initial version created by gary
+ */
+package org.scribble.comparator;
+
+import org.scribble.extensions.RegistryFactory;
+import org.scribble.model.*;
+import org.scribble.model.admin.*;
+
+import junit.framework.TestCase;
+
+public class InteractionComparatorRuleTest extends TestCase {
+
+	private static final String TEST_NOTATION = "test";
+
+	public void testCompareSameExplicitRolesDiffSig() {
+		InteractionComparatorRule rule=
+				new InteractionComparatorRule();
+		
+		RegistryFactory.setRegistry(null);
+		
+		DefaultModelListener l=new DefaultModelListener();
+		
+		java.util.List<ComparatorRule> rules=
+					new java.util.Vector<ComparatorRule>();
+		
+		rules.add(new RoleComparatorRule());
+		rules.add(new ChannelComparatorRule());
+		rules.add(new MessageSignatureComparatorRule());
+		rules.add(new TypeReferenceComparatorRule());
+		
+		DefaultComparatorContext context=
+			new DefaultComparatorContext(new ModelReference(TEST_NOTATION),
+						new ModelReference(TEST_NOTATION), rules);
+		
+		Role fromRole=new Role();
+		fromRole.setName("fromRole");
+		
+		Role toRole=new Role();
+		toRole.setName("toRole");
+		
+		MessageSignature msig1=new MessageSignature();
+		TypeReference typeRef1=new TypeReference();
+		typeRef1.setLocalpart("testType1");
+		msig1.getTypes().add(typeRef1);
+		
+		MessageSignature msig2=new MessageSignature();
+		TypeReference typeRef2=new TypeReference();
+		typeRef2.setLocalpart("testType2");
+		msig2.getTypes().add(typeRef2);
+		
+		Interaction main=new Interaction();
+		main.setMessageSignature(msig1);
+		main.setFromRole(fromRole);
+		main.setToRole(toRole);
+		
+		Interaction reference=new Interaction();
+		reference.setMessageSignature(msig2);
+		reference.setFromRole(fromRole);
+		reference.setToRole(toRole);
+	
+		boolean result=rule.compare(context, main, reference, l, false);
+		
+		if (l.getErrors().size() != 1) {
+			fail("One error expected");
+		}
+		
+		if (result == true) {
+			fail("Comparator should have failed");
+		}
+	}
+
+	public void testCompareGlobalSameExplicitRoles() {
+		InteractionComparatorRule rule=
+				new InteractionComparatorRule();
+		
+		RegistryFactory.setRegistry(null);
+		
+		DefaultModelListener l=new DefaultModelListener();
+		
+		java.util.List<ComparatorRule> rules=
+					new java.util.Vector<ComparatorRule>();
+		
+		rules.add(new RoleComparatorRule());
+		rules.add(new ChannelComparatorRule());
+		rules.add(new MessageSignatureComparatorRule());
+		rules.add(new TypeReferenceComparatorRule());
+		
+		DefaultComparatorContext context=
+			new DefaultComparatorContext(new ModelReference(TEST_NOTATION),
+						new ModelReference(TEST_NOTATION), rules);
+		
+		Role fromRole=new Role();
+		fromRole.setName("fromRole");
+		
+		Role toRole=new Role();
+		toRole.setName("toRole");
+		
+		MessageSignature msig=new MessageSignature();
+		TypeReference typeRef=new TypeReference();
+		typeRef.setLocalpart("testType");
+		msig.getTypes().add(typeRef);
+		
+		Interaction main=new Interaction();
+		main.setMessageSignature(msig);
+		main.setFromRole(fromRole);
+		main.setToRole(toRole);
+		
+		Interaction reference=new Interaction();
+		reference.setMessageSignature(msig);
+		reference.setFromRole(fromRole);
+		reference.setToRole(toRole);
+	
+		boolean result=rule.compare(context, main, reference, l, false);
+		
+		if (l.getErrors().size() > 0) {
+			fail("No errors expected");
+		}
+		
+		if (result == false) {
+			fail("Comparator failed");
+		}
+	}
+
+	public void testCompareGlobalDiffExplicitFromRoles() {
+		InteractionComparatorRule rule=
+				new InteractionComparatorRule();
+		
+		RegistryFactory.setRegistry(null);
+		
+		DefaultModelListener l=new DefaultModelListener();
+		
+		java.util.List<ComparatorRule> rules=
+					new java.util.Vector<ComparatorRule>();
+		
+		rules.add(new RoleComparatorRule());
+		rules.add(new ChannelComparatorRule());
+		rules.add(new MessageSignatureComparatorRule());
+		rules.add(new TypeReferenceComparatorRule());
+		
+		DefaultComparatorContext context=
+			new DefaultComparatorContext(new ModelReference(TEST_NOTATION),
+						new ModelReference(TEST_NOTATION), rules);
+		
+		Role fromRole1=new Role();
+		fromRole1.setName("fromRole1");
+		
+		Role fromRole2=new Role();
+		fromRole2.setName("fromRole2");
+		
+		Role toRole=new Role();
+		toRole.setName("toRole");
+		
+		MessageSignature msig=new MessageSignature();
+		TypeReference typeRef=new TypeReference();
+		typeRef.setLocalpart("testType");
+		msig.getTypes().add(typeRef);
+		
+		Interaction main=new Interaction();
+		main.setMessageSignature(msig);
+		main.setFromRole(fromRole1);
+		main.setToRole(toRole);
+		
+		Interaction reference=new Interaction();
+		reference.setMessageSignature(msig);
+		reference.setFromRole(fromRole2);
+		reference.setToRole(toRole);
+	
+		boolean result=rule.compare(context, main, reference, l, false);
+		
+		// Should report role comparison error - actual error
+		// is determine by RoleComparatorRule, just passed
+		// through by this rule
+		if (l.getErrors().size() != 1) {
+			fail("One error expected");
+		}
+		
+		if (result == true) {
+			fail("Comparator should have failed");
+		}
+	}
+
+	public void testCompareGlobalDiffExplicitToRoles() {
+		InteractionComparatorRule rule=
+				new InteractionComparatorRule();
+		
+		RegistryFactory.setRegistry(null);
+		
+		DefaultModelListener l=new DefaultModelListener();
+		
+		java.util.List<ComparatorRule> rules=
+					new java.util.Vector<ComparatorRule>();
+		
+		rules.add(new RoleComparatorRule());
+		rules.add(new ChannelComparatorRule());
+		rules.add(new MessageSignatureComparatorRule());
+		rules.add(new TypeReferenceComparatorRule());
+		
+		DefaultComparatorContext context=
+			new DefaultComparatorContext(new ModelReference(TEST_NOTATION),
+						new ModelReference(TEST_NOTATION), rules);
+		
+		Role fromRole=new Role();
+		fromRole.setName("fromRole");
+		
+		Role toRole1=new Role();
+		toRole1.setName("toRole1");
+		
+		Role toRole2=new Role();
+		toRole2.setName("toRole2");
+		
+		MessageSignature msig=new MessageSignature();
+		TypeReference typeRef=new TypeReference();
+		typeRef.setLocalpart("testType");
+		msig.getTypes().add(typeRef);
+		
+		Interaction main=new Interaction();
+		main.setMessageSignature(msig);
+		main.setFromRole(fromRole);
+		main.setToRole(toRole1);
+		
+		Interaction reference=new Interaction();
+		reference.setMessageSignature(msig);
+		reference.setFromRole(fromRole);
+		reference.setToRole(toRole2);
+	
+		boolean result=rule.compare(context, main, reference, l, false);
+		
+		// Should report role comparison error - actual error
+		// is determine by RoleComparatorRule, just passed
+		// through by this rule
+		if (l.getErrors().size() != 1) {
+			fail("One error expected");
+		}
+		
+		if (result == true) {
+			fail("Comparator should have failed");
+		}
+	}
+	
+	public void testCompareGlobalSameImplicitRoles() {
+		InteractionComparatorRule rule=
+				new InteractionComparatorRule();
+		
+		RegistryFactory.setRegistry(null);
+		
+		DefaultModelListener l=new DefaultModelListener();
+		
+		java.util.List<ComparatorRule> rules=
+					new java.util.Vector<ComparatorRule>();
+		
+		rules.add(new RoleComparatorRule());
+		rules.add(new ChannelComparatorRule());
+		rules.add(new MessageSignatureComparatorRule());
+		rules.add(new TypeReferenceComparatorRule());
+		
+		DefaultComparatorContext context=
+			new DefaultComparatorContext(new ModelReference(TEST_NOTATION),
+						new ModelReference(TEST_NOTATION), rules);
+		
+		Role fromRole=new Role();
+		fromRole.setName("fromRole");
+		
+		Role toRole=new Role();
+		toRole.setName("toRole");
+		
+		Channel mainCh=new Channel();
+		mainCh.setName("testch");
+		mainCh.setFromRole(fromRole);
+		mainCh.setToRole(toRole);
+		
+		Channel refCh=new Channel();
+		refCh.setName("testch");
+		refCh.setFromRole(fromRole);
+		refCh.setToRole(toRole);
+		
+		MessageSignature msig=new MessageSignature();
+		TypeReference typeRef=new TypeReference();
+		typeRef.setLocalpart("testType");
+		msig.getTypes().add(typeRef);
+		
+		Interaction main=new Interaction();
+		main.setMessageSignature(msig);
+		main.setChannel(mainCh);
+		
+		Interaction reference=new Interaction();
+		reference.setMessageSignature(msig);
+		reference.setChannel(refCh);
+
+		boolean result=rule.compare(context, main, reference, l, false);
+		
+		if (l.getErrors().size() > 0) {
+			fail("No errors expected");
+		}
+		
+		if (result == false) {
+			fail("Comparator failed");
+		}
+	}
+
+	public void testCompareGlobalDiffImplicitFromRoles() {
+		InteractionComparatorRule rule=
+				new InteractionComparatorRule();
+		
+		RegistryFactory.setRegistry(null);
+		
+		DefaultModelListener l=new DefaultModelListener();
+		
+		java.util.List<ComparatorRule> rules=
+					new java.util.Vector<ComparatorRule>();
+		
+		rules.add(new RoleComparatorRule());
+		rules.add(new ChannelComparatorRule());
+		rules.add(new MessageSignatureComparatorRule());
+		rules.add(new TypeReferenceComparatorRule());
+		
+		DefaultComparatorContext context=
+			new DefaultComparatorContext(new ModelReference(TEST_NOTATION),
+						new ModelReference(TEST_NOTATION), rules);
+		
+		Role fromRole1=new Role();
+		fromRole1.setName("fromRole1");
+		
+		Role fromRole2=new Role();
+		fromRole2.setName("fromRole2");
+		
+		Role toRole=new Role();
+		toRole.setName("toRole");
+		
+		Channel mainCh=new Channel();
+		mainCh.setName("testch");
+		mainCh.setFromRole(fromRole1);
+		mainCh.setToRole(toRole);
+		
+		Channel refCh=new Channel();
+		refCh.setName("testch");
+		refCh.setFromRole(fromRole2);
+		refCh.setToRole(toRole);
+		
+		MessageSignature msig=new MessageSignature();
+		TypeReference typeRef=new TypeReference();
+		typeRef.setLocalpart("testType");
+		msig.getTypes().add(typeRef);
+		
+		Interaction main=new Interaction();
+		main.setMessageSignature(msig);
+		main.setChannel(mainCh);
+		
+		Interaction reference=new Interaction();
+		reference.setMessageSignature(msig);
+		reference.setChannel(refCh);
+	
+		boolean result=rule.compare(context, main, reference, l, false);
+		
+		if (l.getErrors().size() != 1) {
+			fail("One error expected");
+		}
+		
+		if (result == true) {
+			fail("Comparator should have failed");
+		}
+	}
+
+	public void testCompareGlobalDiffImplicitToRoles() {
+		InteractionComparatorRule rule=
+				new InteractionComparatorRule();
+		
+		RegistryFactory.setRegistry(null);
+		
+		DefaultModelListener l=new DefaultModelListener();
+		
+		java.util.List<ComparatorRule> rules=
+					new java.util.Vector<ComparatorRule>();
+		
+		rules.add(new RoleComparatorRule());
+		rules.add(new ChannelComparatorRule());
+		rules.add(new MessageSignatureComparatorRule());
+		rules.add(new TypeReferenceComparatorRule());
+		
+		DefaultComparatorContext context=
+			new DefaultComparatorContext(new ModelReference(TEST_NOTATION),
+						new ModelReference(TEST_NOTATION), rules);
+		
+		Role fromRole=new Role();
+		fromRole.setName("fromRole");
+		
+		Role toRole1=new Role();
+		toRole1.setName("toRole1");
+		
+		Role toRole2=new Role();
+		toRole2.setName("toRole2");
+		
+		Channel mainCh=new Channel();
+		mainCh.setName("testch");
+		mainCh.setFromRole(fromRole);
+		mainCh.setToRole(toRole1);
+		
+		Channel refCh=new Channel();
+		refCh.setName("testch");
+		refCh.setFromRole(fromRole);
+		refCh.setToRole(toRole2);
+		
+		MessageSignature msig=new MessageSignature();
+		TypeReference typeRef=new TypeReference();
+		typeRef.setLocalpart("testType");
+		msig.getTypes().add(typeRef);
+		
+		Interaction main=new Interaction();
+		main.setMessageSignature(msig);
+		main.setChannel(mainCh);
+		
+		Interaction reference=new Interaction();
+		reference.setMessageSignature(msig);
+		reference.setChannel(refCh);
+	
+		boolean result=rule.compare(context, main, reference, l, false);
+		
+		if (l.getErrors().size() != 1) {
+			fail("One error expected");
+		}
+		
+		if (result == true) {
+			fail("Comparator should have failed");
+		}
+	}
+
+	public void testCompareLocalSameExplicitFromRoles() {
+		InteractionComparatorRule rule=
+				new InteractionComparatorRule();
+		
+		RegistryFactory.setRegistry(null);
+		
+		DefaultModelListener l=new DefaultModelListener();
+		
+		java.util.List<ComparatorRule> rules=
+					new java.util.Vector<ComparatorRule>();
+		
+		rules.add(new RoleComparatorRule());
+		rules.add(new ChannelComparatorRule());
+		rules.add(new MessageSignatureComparatorRule());
+		rules.add(new TypeReferenceComparatorRule());
+		
+		DefaultComparatorContext context=
+			new DefaultComparatorContext(new ModelReference(TEST_NOTATION),
+						new ModelReference(TEST_NOTATION), rules);
+		
+		Role fromRole=new Role();
+		fromRole.setName("fromRole");
+		
+		MessageSignature msig=new MessageSignature();
+		TypeReference typeRef=new TypeReference();
+		typeRef.setLocalpart("testType");
+		msig.getTypes().add(typeRef);
+		
+		Interaction main=new Interaction();
+		main.setMessageSignature(msig);
+		main.setFromRole(fromRole);
+		
+		Interaction reference=new Interaction();
+		reference.setMessageSignature(msig);
+		reference.setFromRole(fromRole);
+	
+		boolean result=rule.compare(context, main, reference, l, false);
+		
+		if (l.getErrors().size() > 0) {
+			fail("No errors expected");
+		}
+		
+		if (result == false) {
+			fail("Comparator failed");
+		}
+	}
+
+	public void testCompareLocalSameExplicitToRoles() {
+		InteractionComparatorRule rule=
+				new InteractionComparatorRule();
+		
+		RegistryFactory.setRegistry(null);
+		
+		DefaultModelListener l=new DefaultModelListener();
+		
+		java.util.List<ComparatorRule> rules=
+					new java.util.Vector<ComparatorRule>();
+		
+		rules.add(new RoleComparatorRule());
+		rules.add(new ChannelComparatorRule());
+		rules.add(new MessageSignatureComparatorRule());
+		rules.add(new TypeReferenceComparatorRule());
+		
+		DefaultComparatorContext context=
+			new DefaultComparatorContext(new ModelReference(TEST_NOTATION),
+						new ModelReference(TEST_NOTATION), rules);
+		
+		Role toRole=new Role();
+		toRole.setName("toRole");
+		
+		MessageSignature msig=new MessageSignature();
+		TypeReference typeRef=new TypeReference();
+		typeRef.setLocalpart("testType");
+		msig.getTypes().add(typeRef);
+		
+		Interaction main=new Interaction();
+		main.setMessageSignature(msig);
+		main.setToRole(toRole);
+		
+		Interaction reference=new Interaction();
+		reference.setMessageSignature(msig);
+		reference.setToRole(toRole);
+	
+		boolean result=rule.compare(context, main, reference, l, false);
+		
+		if (l.getErrors().size() > 0) {
+			fail("No errors expected");
+		}
+		
+		if (result == false) {
+			fail("Comparator failed");
+		}
+	}
+
+	public void testCompareLocalDiffExplicitFromRoles() {
+		InteractionComparatorRule rule=
+				new InteractionComparatorRule();
+		
+		RegistryFactory.setRegistry(null);
+		
+		DefaultModelListener l=new DefaultModelListener();
+		
+		java.util.List<ComparatorRule> rules=
+					new java.util.Vector<ComparatorRule>();
+		
+		rules.add(new RoleComparatorRule());
+		rules.add(new ChannelComparatorRule());
+		rules.add(new MessageSignatureComparatorRule());
+		rules.add(new TypeReferenceComparatorRule());
+		
+		DefaultComparatorContext context=
+			new DefaultComparatorContext(new ModelReference(TEST_NOTATION),
+						new ModelReference(TEST_NOTATION), rules);
+		
+		Role fromRole1=new Role();
+		fromRole1.setName("fromRole1");
+		
+		Role fromRole2=new Role();
+		fromRole2.setName("fromRole2");
+				
+		MessageSignature msig=new MessageSignature();
+		TypeReference typeRef=new TypeReference();
+		typeRef.setLocalpart("testType");
+		msig.getTypes().add(typeRef);
+		
+		Interaction main=new Interaction();
+		main.setMessageSignature(msig);
+		main.setFromRole(fromRole1);
+		
+		Interaction reference=new Interaction();
+		reference.setMessageSignature(msig);
+		reference.setFromRole(fromRole2);
+	
+		boolean result=rule.compare(context, main, reference, l, false);
+		
+		// Should report role comparison error - actual error
+		// is determine by RoleComparatorRule, just passed
+		// through by this rule
+		if (l.getErrors().size() != 1) {
+			fail("One error expected");
+		}
+		
+		if (result == true) {
+			fail("Comparator should have failed");
+		}
+	}
+
+	public void testCompareLocalDiffExplicitToRoles() {
+		InteractionComparatorRule rule=
+				new InteractionComparatorRule();
+		
+		RegistryFactory.setRegistry(null);
+		
+		DefaultModelListener l=new DefaultModelListener();
+		
+		java.util.List<ComparatorRule> rules=
+					new java.util.Vector<ComparatorRule>();
+		
+		rules.add(new RoleComparatorRule());
+		rules.add(new ChannelComparatorRule());
+		rules.add(new MessageSignatureComparatorRule());
+		rules.add(new TypeReferenceComparatorRule());
+		
+		DefaultComparatorContext context=
+			new DefaultComparatorContext(new ModelReference(TEST_NOTATION),
+						new ModelReference(TEST_NOTATION), rules);
+		
+		Role toRole1=new Role();
+		toRole1.setName("toRole1");
+		
+		Role toRole2=new Role();
+		toRole2.setName("toRole2");
+		
+		MessageSignature msig=new MessageSignature();
+		TypeReference typeRef=new TypeReference();
+		typeRef.setLocalpart("testType");
+		msig.getTypes().add(typeRef);
+		
+		Interaction main=new Interaction();
+		main.setMessageSignature(msig);
+		main.setToRole(toRole1);
+		
+		Interaction reference=new Interaction();
+		reference.setMessageSignature(msig);
+		reference.setToRole(toRole2);
+	
+		boolean result=rule.compare(context, main, reference, l, false);
+		
+		// Should report role comparison error - actual error
+		// is determine by RoleComparatorRule, just passed
+		// through by this rule
+		if (l.getErrors().size() != 1) {
+			fail("One error expected");
+		}
+		
+		if (result == true) {
+			fail("Comparator should have failed");
+		}
+	}	
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/comparator/MessageSignatureComparatorRuleTest.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/comparator/MessageSignatureComparatorRuleTest.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/comparator/MessageSignatureComparatorRuleTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,257 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 28 Feb 2009 : Initial version created by gary
+ */
+package org.scribble.comparator;
+
+import org.scribble.extensions.RegistryFactory;
+import org.scribble.model.*;
+import org.scribble.model.admin.*;
+
+import junit.framework.TestCase;
+
+public class MessageSignatureComparatorRuleTest extends TestCase {
+
+	private static final String TEST_NOTATION = "test";
+
+	public void testCompareSameOpNoTypes() {
+		MessageSignatureComparatorRule rule=
+				new MessageSignatureComparatorRule();
+		
+		RegistryFactory.setRegistry(null);
+		
+		DefaultModelListener l=new DefaultModelListener();
+		
+		java.util.List<ComparatorRule> rules=
+					new java.util.Vector<ComparatorRule>();
+		
+		rules.add(new TypeReferenceComparatorRule());
+		
+		DefaultComparatorContext context=
+			new DefaultComparatorContext(new ModelReference(TEST_NOTATION),
+						new ModelReference(TEST_NOTATION), rules);
+		
+		MessageSignature main=new MessageSignature();
+		main.setOperation("opName");
+		
+		MessageSignature reference=new MessageSignature();
+		reference.setOperation("opName");
+	
+		boolean result=rule.compare(context, main, reference, l, false);
+		
+		if (l.getErrors().size() > 0) {
+			fail("No errors expected");
+		}
+		
+		if (result == false) {
+			fail("Comparator failed");
+		}
+	}
+
+	public void testCompareDiffOpNoTypes() {
+		MessageSignatureComparatorRule rule=
+				new MessageSignatureComparatorRule();
+		
+		RegistryFactory.setRegistry(null);
+		
+		DefaultModelListener l=new DefaultModelListener();
+		
+		java.util.List<ComparatorRule> rules=
+					new java.util.Vector<ComparatorRule>();
+		
+		rules.add(new TypeReferenceComparatorRule());
+		
+		DefaultComparatorContext context=
+			new DefaultComparatorContext(new ModelReference(TEST_NOTATION),
+						new ModelReference(TEST_NOTATION), rules);
+		
+		MessageSignature main=new MessageSignature();
+		main.setOperation("opName1");
+		
+		MessageSignature reference=new MessageSignature();
+		reference.setOperation("opName2");
+	
+		boolean result=rule.compare(context, main, reference, l, false);
+		
+		if (l.getErrors().size() != 1) {
+			fail("One error expected");
+		}
+		
+		if (result == true) {
+			fail("Comparator should have failed");
+		}
+	}
+	
+	public void testCompareNoOpSameTypes() {
+		MessageSignatureComparatorRule rule=
+				new MessageSignatureComparatorRule();
+		
+		RegistryFactory.setRegistry(null);
+		
+		DefaultModelListener l=new DefaultModelListener();
+		
+		java.util.List<ComparatorRule> rules=
+					new java.util.Vector<ComparatorRule>();
+		
+		rules.add(new TypeReferenceComparatorRule());
+		
+		DefaultComparatorContext context=
+			new DefaultComparatorContext(new ModelReference(TEST_NOTATION),
+						new ModelReference(TEST_NOTATION), rules);
+
+		TypeReference typeRef=new TypeReference();
+		typeRef.setLocalpart("typeRef");
+		
+		MessageSignature main=new MessageSignature();
+		main.getTypes().add(typeRef);
+		
+		MessageSignature reference=new MessageSignature();
+		reference.getTypes().add(typeRef);
+	
+		boolean result=rule.compare(context, main, reference, l, false);
+		
+		if (l.getErrors().size() > 0) {
+			fail("No errors expected");
+		}
+		
+		if (result == false) {
+			fail("Comparator failed");
+		}
+	}
+	
+	public void testCompareNoOpDiffTypes() {
+		MessageSignatureComparatorRule rule=
+				new MessageSignatureComparatorRule();
+		
+		RegistryFactory.setRegistry(null);
+		
+		DefaultModelListener l=new DefaultModelListener();
+		
+		java.util.List<ComparatorRule> rules=
+					new java.util.Vector<ComparatorRule>();
+		
+		rules.add(new TypeReferenceComparatorRule());
+		
+		DefaultComparatorContext context=
+			new DefaultComparatorContext(new ModelReference(TEST_NOTATION),
+						new ModelReference(TEST_NOTATION), rules);
+
+		TypeReference typeRef1=new TypeReference();
+		typeRef1.setLocalpart("typeRef1");
+		
+		TypeReference typeRef2=new TypeReference();
+		typeRef2.setLocalpart("typeRef2");
+		
+		MessageSignature main=new MessageSignature();
+		main.getTypes().add(typeRef1);
+		
+		MessageSignature reference=new MessageSignature();
+		reference.getTypes().add(typeRef2);
+	
+		boolean result=rule.compare(context, main, reference, l, false);
+		
+		if (l.getErrors().size() != 1) {
+			fail("One error expected");
+		}
+		
+		if (result == true) {
+			fail("Comparator should have failed");
+		}
+	}
+	
+	public void testCompareOpSameTypes() {
+		MessageSignatureComparatorRule rule=
+				new MessageSignatureComparatorRule();
+		
+		RegistryFactory.setRegistry(null);
+		
+		DefaultModelListener l=new DefaultModelListener();
+		
+		java.util.List<ComparatorRule> rules=
+					new java.util.Vector<ComparatorRule>();
+		
+		rules.add(new TypeReferenceComparatorRule());
+		
+		DefaultComparatorContext context=
+			new DefaultComparatorContext(new ModelReference(TEST_NOTATION),
+						new ModelReference(TEST_NOTATION), rules);
+
+		TypeReference typeRef=new TypeReference();
+		typeRef.setLocalpart("typeRef");
+		
+		MessageSignature main=new MessageSignature();
+		main.setOperation("opName");
+		main.getTypes().add(typeRef);
+		
+		MessageSignature reference=new MessageSignature();
+		reference.setOperation("opName");
+		reference.getTypes().add(typeRef);
+	
+		boolean result=rule.compare(context, main, reference, l, false);
+		
+		if (l.getErrors().size() > 0) {
+			fail("No errors expected");
+		}
+		
+		if (result == false) {
+			fail("Comparator failed");
+		}
+	}
+	
+	public void testCompareOpDiffTypes() {
+		MessageSignatureComparatorRule rule=
+				new MessageSignatureComparatorRule();
+		
+		RegistryFactory.setRegistry(null);
+		
+		DefaultModelListener l=new DefaultModelListener();
+		
+		java.util.List<ComparatorRule> rules=
+					new java.util.Vector<ComparatorRule>();
+		
+		rules.add(new TypeReferenceComparatorRule());
+		
+		DefaultComparatorContext context=
+			new DefaultComparatorContext(new ModelReference(TEST_NOTATION),
+						new ModelReference(TEST_NOTATION), rules);
+
+		TypeReference typeRef1=new TypeReference();
+		typeRef1.setLocalpart("typeRef1");
+		
+		TypeReference typeRef2=new TypeReference();
+		typeRef2.setLocalpart("typeRef2");
+		
+		MessageSignature main=new MessageSignature();
+		main.setOperation("opName");
+		main.getTypes().add(typeRef1);
+		
+		MessageSignature reference=new MessageSignature();
+		reference.setOperation("opName");
+		reference.getTypes().add(typeRef2);
+	
+		boolean result=rule.compare(context, main, reference, l, false);
+		
+		if (l.getErrors().size() != 1) {
+			fail("One error expected");
+		}
+		
+		if (result == true) {
+			fail("Comparator should have failed");
+		}
+	}
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/comparator/NamespaceComparatorRuleTest.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/comparator/NamespaceComparatorRuleTest.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/comparator/NamespaceComparatorRuleTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 28 Feb 2009 : Initial version created by gary
+ */
+package org.scribble.comparator;
+
+import org.scribble.extensions.RegistryFactory;
+import org.scribble.model.*;
+import org.scribble.model.admin.*;
+
+import junit.framework.TestCase;
+
+public class NamespaceComparatorRuleTest extends TestCase {
+
+	private static final String TEST_NOTATION = "test";
+
+	public void testCompareSameNamespace() {
+		NamespaceComparatorRule rule=
+				new NamespaceComparatorRule();
+		
+		RegistryFactory.setRegistry(null);
+		
+		DefaultModelListener l=new DefaultModelListener();
+		
+		java.util.List<ComparatorRule> rules=
+					new java.util.Vector<ComparatorRule>();
+		
+		DefaultComparatorContext context=
+			new DefaultComparatorContext(new ModelReference(TEST_NOTATION),
+						new ModelReference(TEST_NOTATION), rules);
+		
+		Namespace main=new Namespace();
+		main.setName("test.namespace");
+		
+		Namespace reference=new Namespace();
+		reference.setName("test.namespace");
+	
+		boolean result=rule.compare(context, main, reference, l, false);
+		
+		if (l.getErrors().size() > 0) {
+			fail("No errors expected");
+		}
+		
+		if (result == false) {
+			fail("Comparator failed");
+		}
+	}
+	
+	public void testCompareDiffNamespace() {
+		NamespaceComparatorRule rule=
+				new NamespaceComparatorRule();
+		
+		RegistryFactory.setRegistry(null);
+		
+		DefaultModelListener l=new DefaultModelListener();
+		
+		java.util.List<ComparatorRule> rules=
+					new java.util.Vector<ComparatorRule>();
+		
+		DefaultComparatorContext context=
+			new DefaultComparatorContext(new ModelReference(TEST_NOTATION),
+						new ModelReference(TEST_NOTATION), rules);
+		
+		Namespace main=new Namespace();
+		main.setName("test.namespace1");
+		
+		Namespace reference=new Namespace();
+		reference.setName("test.namespace2");
+	
+		boolean result=rule.compare(context, main, reference, l, false);
+		
+		/*
+		 * Currently does not report message - may need to
+		 * change, including doing name mapping of the
+		 * namespace?
+		 * 
+		if (l.getErrors().size() != 1) {
+			fail("One error expected");
+		}
+		*/
+		
+		if (result == true) {
+			fail("Comparator should have failed");
+		}
+	}
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/comparator/RoleComparatorRuleTest.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/comparator/RoleComparatorRuleTest.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/comparator/RoleComparatorRuleTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 28 Feb 2009 : Initial version created by gary
+ */
+package org.scribble.comparator;
+
+import org.scribble.extensions.RegistryFactory;
+import org.scribble.model.*;
+import org.scribble.model.admin.*;
+
+import junit.framework.TestCase;
+
+public class RoleComparatorRuleTest extends TestCase {
+
+	private static final String TEST_NOTATION = "test";
+
+	public void testCompareSameName() {
+		RoleComparatorRule rule=
+				new RoleComparatorRule();
+		
+		RegistryFactory.setRegistry(null);
+		
+		DefaultModelListener l=new DefaultModelListener();
+		
+		java.util.List<ComparatorRule> rules=
+					new java.util.Vector<ComparatorRule>();
+		
+		DefaultComparatorContext context=
+			new DefaultComparatorContext(new ModelReference(TEST_NOTATION),
+						new ModelReference(TEST_NOTATION), rules);
+		
+		Role main=new Role();
+		main.setName("roleName");
+		
+		Role reference=new Role();
+		reference.setName("roleName");
+	
+		boolean result=rule.compare(context, main, reference, l, false);
+		
+		if (l.getErrors().size() > 0) {
+			fail("No errors expected");
+		}
+		
+		if (result == false) {
+			fail("Comparator failed");
+		}
+	}
+	
+	public void testCompareDiffNames() {
+		RoleComparatorRule rule=
+				new RoleComparatorRule();
+		
+		RegistryFactory.setRegistry(null);
+		
+		DefaultModelListener l=new DefaultModelListener();
+		
+		java.util.List<ComparatorRule> rules=
+					new java.util.Vector<ComparatorRule>();
+		
+		DefaultComparatorContext context=
+			new DefaultComparatorContext(new ModelReference(TEST_NOTATION),
+						new ModelReference(TEST_NOTATION), rules);
+		
+		Role main=new Role();
+		main.setName("roleName1");
+		
+		Role reference=new Role();
+		reference.setName("roleName2");
+	
+		boolean result=rule.compare(context, main, reference, l, false);
+		
+		if (l.getErrors().size() != 1) {
+			fail("One error expected");
+		}
+		
+		if (result == true) {
+			fail("Comparator should have failed");
+		}
+	}
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/comparator/TestComparatorRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/comparator/TestComparatorRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/comparator/TestComparatorRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 28 Feb 2009 : Initial version created by gary
+ */
+package org.scribble.comparator;
+
+import org.scribble.model.ModelObject;
+import org.scribble.model.admin.ModelListener;
+
+public class TestComparatorRule implements ComparatorRule {
+
+	public TestComparatorRule(Class<?> modelType, Class<?> refType,
+					boolean result) {
+		m_modelType = modelType;
+		m_refType = refType;
+		m_compareResult = result;
+	}
+	
+	public boolean compare(ComparatorContext context, ModelObject main,
+			ModelObject reference, ModelListener l, boolean deep) {
+		return(m_compareResult);
+	}
+
+	public boolean isComparisonSupported(ModelObject main, ModelObject ref) {
+		return(m_modelType.isAssignableFrom(main.getClass()) &&
+				m_refType.isAssignableFrom(ref.getClass()));
+	}
+
+	public boolean isTypeSupported(ModelObject obj) {
+		return(m_modelType.isAssignableFrom(obj.getClass()) &&
+				m_refType.isAssignableFrom(obj.getClass()));
+	}
+
+	private boolean m_compareResult=true;
+	private Class<?> m_modelType=null;
+	private Class<?> m_refType=null;
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/comparator/TypeReferenceComparatorRuleTest.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/comparator/TypeReferenceComparatorRuleTest.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/comparator/TypeReferenceComparatorRuleTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 28 Feb 2009 : Initial version created by gary
+ */
+package org.scribble.comparator;
+
+import org.scribble.extensions.RegistryFactory;
+import org.scribble.model.*;
+import org.scribble.model.admin.*;
+
+import junit.framework.TestCase;
+
+public class TypeReferenceComparatorRuleTest extends TestCase {
+
+	private static final String TEST_NOTATION = "test";
+
+	public void testCompareSameType() {
+		TypeReferenceComparatorRule rule=
+				new TypeReferenceComparatorRule();
+		
+		RegistryFactory.setRegistry(null);
+		
+		DefaultModelListener l=new DefaultModelListener();
+		
+		java.util.List<ComparatorRule> rules=
+					new java.util.Vector<ComparatorRule>();
+		
+		DefaultComparatorContext context=
+			new DefaultComparatorContext(new ModelReference(TEST_NOTATION),
+						new ModelReference(TEST_NOTATION), rules);
+		
+		TypeReference main=new TypeReference();
+		main.setLocalpart("type");
+		
+		TypeReference reference=new TypeReference();
+		reference.setLocalpart("type");
+	
+		boolean result=rule.compare(context, main, reference, l, false);
+		
+		if (l.getErrors().size() > 0) {
+			fail("No errors expected");
+		}
+		
+		if (result == false) {
+			fail("Comparator failed");
+		}
+	}
+	
+	public void testCompareDiffTypes() {
+		TypeReferenceComparatorRule rule=
+			new TypeReferenceComparatorRule();
+	
+		RegistryFactory.setRegistry(null);
+		
+		DefaultModelListener l=new DefaultModelListener();
+		
+		java.util.List<ComparatorRule> rules=
+					new java.util.Vector<ComparatorRule>();
+		
+		DefaultComparatorContext context=
+			new DefaultComparatorContext(new ModelReference(TEST_NOTATION),
+						new ModelReference(TEST_NOTATION), rules);
+		
+		TypeReference main=new TypeReference();
+		main.setLocalpart("type1");
+		
+		TypeReference reference=new TypeReference();
+		reference.setLocalpart("type2");
+	
+		boolean result=rule.compare(context, main, reference, l, false);
+		
+		if (l.getErrors().size() != 1) {
+			fail("One error expected");
+		}
+		
+		if (result == true) {
+			fail("Comparator should have failed");
+		}
+	}
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/AbstractRegistryTest.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/AbstractRegistryTest.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/AbstractRegistryTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,562 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 15 Feb 2009 : Initial version created by gary
+ */
+package org.scribble.extensions;
+
+import junit.framework.TestCase;
+
+import org.scribble.extensions.test.*;
+import org.scribble.model.AbstractNotation;
+import org.scribble.model.Notation;
+
+public class AbstractRegistryTest extends TestCase {
+
+	// Need to test that rules returned for notation hierarchy
+	// including the notation=null
+	
+	public void testExtensionNoNotation() {
+		TestRegistry reg=new TestRegistry();
+		
+		try {
+			reg.addExtension(MainNotation1.class);
+			reg.addExtension(MainNotation2.class);
+			reg.addExtension(SubNotation1A.class);
+			reg.addExtension(Extension1Rule.class);
+		} catch(Exception e) {
+			fail("Failed to register extensions");
+		}
+		
+		Object ext=reg.getExtension(Extension1.class, null);
+		
+		if (ext == null) {
+			fail("Failed to retrieve extension");
+		}
+		
+		if (ext.getClass() != Extension1Rule.class) {
+			fail("Unexpected extension returns '"+ext.getClass()+
+					"', was expecting: "+Extension1Rule.class);
+		}
+	}
+
+	public void testExtensionMain1() {
+		TestRegistry reg=new TestRegistry();
+		
+		try {
+			reg.addExtension(MainNotation1.class);
+			reg.addExtension(MainNotation2.class);
+			reg.addExtension(SubNotation1A.class);
+			reg.addExtension(Extension1Rule_MN1.class);
+			reg.addExtension(Extension1Rule_MN2.class);
+		} catch(Exception e) {
+			fail("Failed to register extensions");
+		}
+		
+		Object ext=reg.getExtension(Extension1.class,
+						MainNotation1.NOTATION);
+		
+		if (ext == null) {
+			fail("Failed to retrieve extension");
+		}
+		
+		if (ext.getClass() != Extension1Rule_MN1.class) {
+			fail("Unexpected extension returns '"+ext.getClass()+
+					"', was expecting: "+Extension1Rule_MN1.class);
+		}
+	}
+
+
+	public void testExtensionMain2() {
+		TestRegistry reg=new TestRegistry();
+		
+		try {
+			reg.addExtension(MainNotation1.class);
+			reg.addExtension(MainNotation2.class);
+			reg.addExtension(SubNotation1A.class);
+			reg.addExtension(Extension1Rule_MN1.class);
+			reg.addExtension(Extension1Rule_MN2.class);
+		} catch(Exception e) {
+			fail("Failed to register extensions");
+		}
+		
+		Object ext=reg.getExtension(Extension1.class,
+						MainNotation2.NOTATION);
+		
+		if (ext == null) {
+			fail("Failed to retrieve extension");
+		}
+		
+		if (ext.getClass() != Extension1Rule_MN2.class) {
+			fail("Unexpected extension returns '"+ext.getClass()+
+					"', was expecting: "+Extension1Rule_MN2.class);
+		}
+	}
+
+	public void testExtensionsNoNotation() {
+		TestRegistry reg=new TestRegistry();
+		
+		try {
+			reg.addExtension(MainNotation1.class);
+			reg.addExtension(MainNotation2.class);
+			reg.addExtension(SubNotation1A.class);
+			reg.addExtension(Extension1Rule.class);
+			reg.addExtension(Extension1Rule_MN1.class);
+			reg.addExtension(Extension1Rule_SN1A.class);
+		} catch(Exception e) {
+			fail("Failed to register extensions");
+		}
+		
+		java.util.List<Object> exts=reg.getExtensions(Extension1.class, null);
+		
+		if (exts == null) {
+			fail("Failed to retrieve extensions");
+		}
+		
+		// All registered extensions, with the exception of
+		// extensions that have been overridden by another
+		// extension - in this case, the Extension1Rule_MN1
+		// overrides Extension1Rule
+		if (exts.size() != 2) {
+			fail("Should be 2 extensions returned");
+		}
+		
+		for (int i=0; i < exts.size(); i++) {
+			if (exts.get(i).getClass() == Extension1Rule.class) {
+				fail("Extension 'Extension1Rule' should not be in the list");
+			}
+		}
+	}
+
+	public void testExtensionsNoNotation_Derived() {
+		TestRegistry reg=new TestRegistry();
+		
+		try {
+			reg.addExtension(MainNotation1.class);
+			reg.addExtension(MainNotation2.class);
+			reg.addExtension(SubNotation1A.class);
+			reg.addExtension(Extension1Rule.class);
+			reg.addExtension(Extension1Rule_MN1.class);
+			reg.addExtension(Extension1Rule_Derived_SN1A.class);
+		} catch(Exception e) {
+			fail("Failed to register extensions");
+		}
+		
+		java.util.List<Object> exts=reg.getExtensions(Extension1.class, null);
+		
+		if (exts == null) {
+			fail("Failed to retrieve extensions");
+		}
+		
+		// All registered extensions, with the exception of
+		// extensions that have been overridden by another
+		// extension - in this case, the Extension1Rule_Derived_SN1A
+		// overrides Extension1Rule_MN1, and Extension1Rule_MN1
+		// overrides Extension1Rule
+		if (exts.size() != 1) {
+			fail("Should be 1 extensions returned");
+		}
+		
+		for (int i=0; i < exts.size(); i++) {
+			if (exts.get(i).getClass() == Extension1Rule_MN1.class) {
+				fail("Extension 'Extension1Rule_MN1' should not be in the list");
+			}
+			if (exts.get(i).getClass() == Extension1Rule.class) {
+				fail("Extension 'Extension1Rule' should not be in the list");
+			}
+		}
+	}
+
+	/**
+	 * This test ensures that if an extension is overridden
+	 * by a specific notation (MN1), then a request by
+	 * that notation (MN1) returns the derived extension.
+	 */
+	public void testExtensionMN1() {
+		TestRegistry reg=new TestRegistry();
+		
+		try {
+			reg.addExtension(MainNotation1.class);
+			reg.addExtension(MainNotation2.class);
+			reg.addExtension(SubNotation1A.class);
+			reg.addExtension(Extension1Rule.class);
+			reg.addExtension(Extension1Rule_MN1.class);
+		} catch(Exception e) {
+			fail("Failed to register extensions");
+		}
+		
+		Object ext=reg.getExtension(Extension1.class,
+							MainNotation1.NOTATION);
+		
+		if (ext == null) {
+			fail("Failed to retrieve extension");
+		}
+		
+		if (ext.getClass() != Extension1Rule_MN1.class) {
+			fail("Unexpected extension returns '"+ext.getClass()+
+					"', was expecting: "+Extension1Rule_MN1.class);
+		}
+	}
+
+	/**
+	 * This test ensures that if an extension is overridden
+	 * by another specific notation (MN1), then a request by
+	 * another notation (MN2) makes a request, which should
+	 * still return the generic extension.
+	 */
+	public void testExtensionMN2() {
+		TestRegistry reg=new TestRegistry();
+		
+		try {
+			reg.addExtension(MainNotation1.class);
+			reg.addExtension(MainNotation2.class);
+			reg.addExtension(SubNotation1A.class);
+			reg.addExtension(Extension1Rule.class);
+			reg.addExtension(Extension1Rule_MN1.class);
+		} catch(Exception e) {
+			fail("Failed to register extensions");
+		}
+		
+		Object ext=reg.getExtension(Extension1.class,
+							MainNotation2.NOTATION);
+		
+		if (ext == null) {
+			fail("Failed to retrieve extension");
+		}
+		
+		if (ext.getClass() != Extension1Rule.class) {
+			fail("Unexpected extension returns '"+ext.getClass()+
+					"', was expecting: "+Extension1Rule.class);
+		}
+	}
+
+	/**
+	 * This test makes a request for a derived notation,
+	 * but should return the extension for a generic
+	 * notation as a specific extension has not been
+	 * defined for the derived notation.
+	 */
+	public void testExtensionForDerivedNotation1() {
+		TestRegistry reg=new TestRegistry();
+		
+		try {
+			reg.addExtension(MainNotation1.class);
+			reg.addExtension(MainNotation2.class);
+			reg.addExtension(SubNotation1A.class);
+			reg.addExtension(Extension1Rule.class);
+			reg.addExtension(Extension1Rule_MN1.class);
+		} catch(Exception e) {
+			fail("Failed to register extensions");
+		}
+		
+		Object ext=reg.getExtension(Extension1.class,
+							SubNotation1A.NOTATION);
+		
+		if (ext == null) {
+			fail("Failed to retrieve extension");
+		}
+		
+		if (ext.getClass() != Extension1Rule_MN1.class) {
+			fail("Unexpected extension returns '"+ext.getClass()+
+					"', was expecting: "+Extension1Rule_MN1.class);
+		}
+	}
+
+	/**
+	 * This test returns a list of extensions that are appropriate
+	 * for the supplied 'sub' notation. This will include one
+	 * extension associated with the supplied notation, and
+	 * another associated with a generic (super) notation.
+	 */
+	public void testExtensionsForDerivedNotation1() {
+		TestRegistry reg=new TestRegistry();
+		
+		try {
+			reg.addExtension(MainNotation1.class);
+			reg.addExtension(MainNotation2.class);
+			reg.addExtension(SubNotation1A.class);
+			reg.addExtension(Extension1Rule.class);
+			reg.addExtension(Extension1Rule_MN1.class);
+			reg.addExtension(Extension1Rule_SN1A.class);
+		} catch(Exception e) {
+			fail("Failed to register extensions");
+		}
+		
+		java.util.List<Object> exts=reg.getExtensions(Extension1.class,
+							SubNotation1A.NOTATION);
+		
+		if (exts.size() != 2) {
+			fail("Was expecting 2 extensions");
+		}
+		
+		for (int i=0; i < exts.size(); i++) {
+			if (exts.get(i).getClass() == Extension1Rule.class) {
+				fail("Extension 'Extension1Rule' should not be in the list");
+			}
+		}	
+	}
+
+	/**
+	 * This test returns a list of extensions that are appropriate
+	 * for the supplied 'sub' notation. This will include one
+	 * extension associated with the supplied notation. The
+	 * other potential extension (Extension1Rule_MN1) would have
+	 * been overridden.
+	 */
+	public void testExtensionsForDerivedNotation2() {
+		TestRegistry reg=new TestRegistry();
+		
+		try {
+			reg.addExtension(MainNotation1.class);
+			reg.addExtension(MainNotation2.class);
+			reg.addExtension(SubNotation1A.class);
+			reg.addExtension(Extension1Rule.class);
+			reg.addExtension(Extension1Rule_MN1.class);
+			reg.addExtension(Extension1Rule_Derived_SN1A.class);
+		} catch(Exception e) {
+			fail("Failed to register extensions");
+		}
+		
+		java.util.List<Object> exts=reg.getExtensions(Extension1.class,
+							SubNotation1A.NOTATION);
+		
+		if (exts.size() != 1) {
+			fail("Was expecting 1 extensions");
+		}
+		
+		for (int i=0; i < exts.size(); i++) {
+			if (exts.get(i).getClass() == Extension1Rule.class) {
+				fail("Extension 'Extension1Rule' should not be in the list");
+			}
+			if (exts.get(i).getClass() == Extension1Rule_MN1.class) {
+				fail("Extension 'Extension1Rule_MN1' should not be in the list");
+			}
+		}	
+	}
+
+	public void testGetNotationSuitabilitySameNotations1() {
+		TestRegistry reg=new TestRegistry();
+		
+		try {
+			reg.addExtension(NotationA.class);
+			reg.addExtension(NotationB.class);
+			reg.addExtension(NotationC.class);
+		} catch (RegistryException e) {
+			fail("Failed to register extensions: "+e);
+		}
+		
+		int suitability=reg.getNotationSuitability("A", "A");
+		
+		if (suitability != 0) {
+			fail("Suitability should be 0: "+suitability);
+		}
+	}
+
+	public void testGetNotationSuitabilitySameNotations2() {
+		TestRegistry reg=new TestRegistry();
+		
+		try {
+			reg.addExtension(NotationA.class);
+			reg.addExtension(NotationB.class);
+			reg.addExtension(NotationC.class);
+		} catch (RegistryException e) {
+			fail("Failed to register extensions: "+e);
+		}
+		
+		int suitability=reg.getNotationSuitability("A", "C,A");
+		
+		if (suitability != 0) {
+			fail("Suitability should be 0: "+suitability);
+		}
+	}
+	
+	// Should return -1 as no relationship between the requested
+	// notation and the one that would be associated with the
+	// extension.
+	public void testGetNotationSuitabilityDiffNotations() {
+		TestRegistry reg=new TestRegistry();
+		
+		try {
+			reg.addExtension(NotationA.class);
+			reg.addExtension(NotationB.class);
+			reg.addExtension(NotationC.class);
+		} catch (RegistryException e) {
+			fail("Failed to register extensions: "+e);
+		}
+		
+		int suitability=reg.getNotationSuitability("A", "C");
+		
+		if (suitability != -1) {
+			fail("Suitability should be -1: "+suitability);
+		}
+	}
+	
+	// Should return success, but indicate there is a single level
+	// of indirection between the requested type (B) and the one
+	// is available (A).
+	public void testGetNotationSuitabilityDerivedNotations() {
+		TestRegistry reg=new TestRegistry();
+		
+		try {
+			reg.addExtension(NotationA.class);
+			reg.addExtension(NotationB.class);
+			reg.addExtension(NotationC.class);
+		} catch (RegistryException e) {
+			fail("Failed to register extensions: "+e);
+		}
+		
+		int suitability=reg.getNotationSuitability("B", "A");
+		
+		if (suitability != 1) {
+			fail("Suitability should be 1: "+suitability);
+		}
+	}
+	
+	// Check that if asking for generic notation, should not
+	// consider derived notation suitable. Derived (or rather
+	// a more specific) notation should only be returned if
+	// either requested, or a more specific notation is
+	// requested.
+	public void testGetNotationSuitabilitySuperNotations() {
+		TestRegistry reg=new TestRegistry();
+		
+		try {
+			reg.addExtension(NotationA.class);
+			reg.addExtension(NotationB.class);
+			reg.addExtension(NotationC.class);
+		} catch (RegistryException e) {
+			fail("Failed to register extensions: "+e);
+		}
+		
+		int suitability=reg.getNotationSuitability("A", "B");
+		
+		if (suitability != -1) {
+			fail("Suitability should be -1: "+suitability);
+		}
+	}
+	
+	// Check that extension for requested notation is
+	// returned.
+	public void testGetInstanceListRequestedNotation() {
+		TestRegistry reg=new TestRegistry();
+		
+		try {
+			reg.addExtension(NotationA.class);
+			reg.addExtension(NotationB.class);
+			reg.addExtension(TestExtensionAImpl.class);
+			reg.addExtension(TestExtensionBImpl.class);
+		} catch (RegistryException e) {
+			fail("Failed to register extensions: "+e);
+		}
+		
+		java.util.List<Object> list=reg.getInstanceList(TestExtension.class, "A");
+		
+		if (list == null) {
+			fail("List is null");
+		}
+		
+		if (list.size() != 1) {
+			fail("List should have 1 element: "+list.size());
+		}
+		
+		if (list.get(0).getClass() != TestExtensionAImpl.class) {
+			fail("Expecting class 'TestExtensionAImpl', but got: "+
+					list.get(0).getClass());
+		}
+	}
+	
+	// Check that extension for requested notation is
+	// returned ahead of extension for super-notation.
+	public void testGetInstanceList() {
+		TestRegistry reg=new TestRegistry();
+		
+		try {
+			reg.addExtension(NotationA.class);
+			reg.addExtension(NotationB.class);
+			reg.addExtension(TestExtensionAImpl.class);
+			reg.addExtension(TestExtensionBImpl.class);
+		} catch (RegistryException e) {
+			fail("Failed to register extensions: "+e);
+		}
+		
+		java.util.List<Object> list=reg.getInstanceList(TestExtension.class, "B");
+		
+		if (list == null) {
+			fail("List is null");
+		}
+		
+		if (list.size() != 2) {
+			fail("List should have 2 elements: "+list.size());
+		}
+		
+		if (list.get(0).getClass() != TestExtensionBImpl.class) {
+			fail("First element expecting class 'TestExtensionBImpl', but got: "+
+					list.get(0).getClass());
+		}		
+		
+		if (list.get(1).getClass() != TestExtensionAImpl.class) {
+			fail("Second element expecting class 'TestExtensionAImpl', but got: "+
+					list.get(1).getClass());
+		}		
+	}
+	
+	@RegistryInfo(extension=Notation.class)
+	public static class NotationA extends AbstractNotation {
+		public NotationA() {
+			super("A","NotationA",false);
+		}
+	}
+	
+	@RegistryInfo(extension=Notation.class)
+	public static class NotationB extends AbstractNotation {
+		public NotationB() {
+			super("B","NotationB",false);
+		}
+		public Notation getSuperNotation() {
+			return(new NotationA());
+		}
+	}
+	
+	@RegistryInfo(extension=Notation.class)
+	public static class NotationC extends AbstractNotation {
+		public NotationC() {
+			super("C","NotationC",false);
+		}
+	}
+	
+	public interface TestExtension {
+		public void testMethod();
+	}
+	
+	@RegistryInfo(extension=TestExtension.class,notation="A")
+	public static class TestExtensionAImpl implements TestExtension {
+		public TestExtensionAImpl() {	
+		}
+		
+		public void testMethod() {
+		}
+	}
+	
+	@RegistryInfo(extension=TestExtension.class,notation="B")
+	public static class TestExtensionBImpl implements TestExtension {
+		public TestExtensionBImpl() {	
+		}
+		
+		public void testMethod() {
+		}
+	}
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/TestRegistry.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/TestRegistry.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/TestRegistry.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 1 May 2008 : Initial version created by gary
+ */
+package org.scribble.extensions;
+
+public class TestRegistry extends AbstractRegistry {
+
+	@Override
+	public void initialize() throws RegistryException {
+	}
+
+	public boolean isActive() {
+		return true;
+	}
+
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/TestSingleExtensionRegistry.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/TestSingleExtensionRegistry.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/TestSingleExtensionRegistry.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 9 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.extensions;
+
+import java.util.List;
+
+public class TestSingleExtensionRegistry implements Registry {
+
+	public TestSingleExtensionRegistry(Object extension) {
+		m_extension = extension;
+	}
+
+	public boolean isActive() {
+		return true;
+	}
+
+	public Object getExtension(Class<?> intf, String notation) {
+		return(m_extension);
+	}
+
+	public List<Object> getExtensions(Class<?> intf, String notation) {
+		return null;
+	}
+	
+	private Object m_extension=null;
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/TestTypeMapRegistry.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/TestTypeMapRegistry.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/TestTypeMapRegistry.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2007-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 28 Feb 2009 : Initial version created by gary
+ */
+package org.scribble.extensions;
+
+import java.util.List;
+
+public class TestTypeMapRegistry implements Registry {
+
+	public TestTypeMapRegistry(java.util.Map<Class<?>,Object> map) {
+		m_extensions = map;
+	}
+
+	public boolean isActive() {
+		return true;
+	}
+
+	public Object getExtension(Class<?> intf, String notation) {
+		return(m_extensions.get(intf));
+	}
+
+	public List<Object> getExtensions(Class<?> intf, String notation) {
+		return null;
+	}
+	
+	private java.util.Map<Class<?>,Object> m_extensions=null;
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/test/Extension1.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/test/Extension1.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/test/Extension1.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 15 Feb 2009 : Initial version created by gary
+ */
+package org.scribble.extensions.test;
+
+public interface Extension1 {
+
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/test/Extension1Rule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/test/Extension1Rule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/test/Extension1Rule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 15 Feb 2009 : Initial version created by gary
+ */
+package org.scribble.extensions.test;
+
+import org.scribble.extensions.*;
+
+ at RegistryInfo(extension=Extension1.class)
+public class Extension1Rule implements Extension1 {
+
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/test/Extension1Rule_Derived_SN1A.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/test/Extension1Rule_Derived_SN1A.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/test/Extension1Rule_Derived_SN1A.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 15 Feb 2009 : Initial version created by gary
+ */
+package org.scribble.extensions.test;
+
+import org.scribble.extensions.*;
+
+ at RegistryInfo(extension=Extension1.class,notation=SubNotation1A.NOTATION)
+public class Extension1Rule_Derived_SN1A extends Extension1Rule_MN1 {
+
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/test/Extension1Rule_MN1.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/test/Extension1Rule_MN1.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/test/Extension1Rule_MN1.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 15 Feb 2009 : Initial version created by gary
+ */
+package org.scribble.extensions.test;
+
+import org.scribble.extensions.*;
+
+ at RegistryInfo(extension=Extension1.class,notation=MainNotation1.NOTATION)
+public class Extension1Rule_MN1 extends Extension1Rule {
+
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/test/Extension1Rule_MN2.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/test/Extension1Rule_MN2.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/test/Extension1Rule_MN2.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 15 Feb 2009 : Initial version created by gary
+ */
+package org.scribble.extensions.test;
+
+import org.scribble.extensions.*;
+
+ at RegistryInfo(extension=Extension1.class,notation=MainNotation2.NOTATION)
+public class Extension1Rule_MN2 extends Extension1Rule {
+
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/test/Extension1Rule_SN1A.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/test/Extension1Rule_SN1A.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/test/Extension1Rule_SN1A.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 15 Feb 2009 : Initial version created by gary
+ */
+package org.scribble.extensions.test;
+
+import org.scribble.extensions.*;
+
+ at RegistryInfo(extension=Extension1.class,notation=SubNotation1A.NOTATION)
+public class Extension1Rule_SN1A implements Extension1 {
+
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/test/MainNotation1.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/test/MainNotation1.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/test/MainNotation1.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 15 Feb 2009 : Initial version created by gary
+ */
+package org.scribble.extensions.test;
+
+import org.scribble.extensions.RegistryInfo;
+
+ at RegistryInfo(extension=org.scribble.model.Notation.class)
+public class MainNotation1 extends org.scribble.model.AbstractNotation {
+
+	public static final String NOTATION="MN1";
+	
+	public MainNotation1() {
+		super(NOTATION, "MainNotation1", false);
+	}
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/test/MainNotation2.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/test/MainNotation2.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/test/MainNotation2.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 15 Feb 2009 : Initial version created by gary
+ */
+package org.scribble.extensions.test;
+
+import org.scribble.extensions.RegistryInfo;
+
+ at RegistryInfo(extension=org.scribble.model.Notation.class)
+public class MainNotation2 extends org.scribble.model.AbstractNotation {
+
+	public static final String NOTATION="MN2";
+	
+	public MainNotation2() {
+		super(NOTATION, "MainNotation2", false);
+	}
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/test/SubNotation1A.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/test/SubNotation1A.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/extensions/test/SubNotation1A.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 15 Feb 2009 : Initial version created by gary
+ */
+package org.scribble.extensions.test;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.Notation;
+
+ at RegistryInfo(extension=org.scribble.model.Notation.class)
+public class SubNotation1A extends org.scribble.model.AbstractNotation {
+
+	public static final String NOTATION="SN1A";
+	
+	public SubNotation1A() {
+		super(NOTATION, "SubNotation1A", false);
+	}
+	
+	public Notation getSuperNotation() {
+		return(new MainNotation1());
+	}
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/model/InteractionTest.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/model/InteractionTest.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/model/InteractionTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,117 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 11 Nov 2008 : Initial version created by gary
+ */
+package org.scribble.model;
+
+import junit.framework.TestCase;
+
+public class InteractionTest extends TestCase {
+
+	public void testIsWaitStateFalse1() {
+		
+		Definition d=new Definition() {
+		};
+		
+		LocatedName mn=new LocatedName();
+		d.setLocatedName(mn);
+		
+		Role r=new Role();
+		r.setName("r1");
+		
+		mn.setRole(r);
+		
+		Interaction interaction=new Interaction();
+		
+		d.getBlock().getContents().add(interaction);
+		
+		if (interaction.isWaitState()) {
+			fail("Not a wait state");
+		}
+	}
+
+	public void testIsWaitStateFalse2() {
+		
+		Definition d=new Definition() {
+		};
+		
+		LocatedName mn=new LocatedName();
+		d.setLocatedName(mn);
+		
+		Role r=new Role();
+		r.setName("r1");
+		
+		mn.setRole(r);
+		
+		Interaction interaction=new Interaction();
+		
+		interaction.setFromRole(r);
+		
+		d.getBlock().getContents().add(interaction);
+		
+		if (interaction.isWaitState()) {
+			fail("Not a wait state");
+		}
+	}
+
+	public void testIsWaitStateFalse3() {
+		
+		Definition d=new Definition() {
+		};
+		
+		LocatedName mn=new LocatedName();
+		d.setLocatedName(mn);
+		
+		Role r=new Role();
+		r.setName("r1");
+		
+		Interaction interaction=new Interaction();
+		
+		interaction.setToRole(r);
+		
+		d.getBlock().getContents().add(interaction);
+		
+		if (interaction.isWaitState()) {
+			fail("Not a wait state");
+		}
+	}
+
+	public void testIsWaitStateTrue1() {
+		
+		Definition d=new Definition() {
+		};
+		
+		LocatedName mn=new LocatedName();
+		d.setLocatedName(mn);
+		
+		Role r=new Role();
+		r.setName("r1");
+		
+		mn.setRole(r);
+		
+		Interaction interaction=new Interaction();
+		
+		interaction.setToRole(r);
+		
+		d.getBlock().getContents().add(interaction);
+		
+		if (interaction.isWaitState() == false) {
+			fail("IS a wait state");
+		}
+	}
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/model/ModelObjectTest.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/model/ModelObjectTest.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/model/ModelObjectTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,231 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 6 Sep 2008 : Initial version created by gary
+ */
+package org.scribble.model;
+
+import junit.framework.TestCase;
+
+public class ModelObjectTest extends TestCase {
+
+	public void testGetSourceModelObjectURI() {
+		Top t=new Top();
+		
+		Middle mid=new Middle();
+		t.setMid(mid);
+		mid.setParent(t);
+		
+		Bottom b_mid_1=new Bottom();
+		mid.getBottom().add(b_mid_1);
+		
+		Bottom b_mid_2=new Bottom();
+		mid.getBottom().add(b_mid_2);
+		
+		Middle m1=new Middle();
+		t.getMiddle().add(m1);
+		
+		Bottom bot1=new Bottom();
+		m1.setOther(bot1);
+		bot1.setParent(m1);
+		
+		Bottom b1_1=new Bottom();
+		m1.getBottom().add(b1_1);
+		
+		Bottom b1_2=new Bottom();
+		m1.getBottom().add(b1_2);
+		
+		Middle m2=new Middle();
+		t.getMiddle().add(m2);
+		
+		Bottom b2_1=new Bottom();
+		m2.getBottom().add(b2_1);
+		
+		Bottom b2_2=new Bottom();
+		m2.getBottom().add(b2_2);
+		
+		t.initializeURIPart("");
+		
+		String uri=b1_1.getSource().getModelObjectURI();
+		
+		if (uri == null) {
+			fail("URI not set");
+		}
+		
+		if (uri.equals("//middle.1/bottom.1") == false) {
+			fail("URI not as expected: "+uri);
+		}
+		
+		if (b1_1.getSource().getModelObjectURI().equals(uri) == false) {
+			fail("b1_1 source ref mo URI not same as URI");
+		}
+		
+		uri = b2_2.getSource().getModelObjectURI();
+		
+		if (uri == null) {
+			fail("URI not set");
+		}
+		
+		if (uri.equals("//middle.2/bottom.2") == false) {
+			fail("URI not as expected: "+uri);
+		}
+		
+		if (b2_2.getSource().getModelObjectURI().equals(uri) == false) {
+			fail("b2_2 source ref mo URI not same as URI");
+		}
+		
+		uri = m2.getSource().getModelObjectURI();
+		
+		if (uri == null) {
+			fail("URI not set");
+		}
+		
+		if (uri.equals("//middle.2") == false) {
+			fail("URI not as expected: "+uri);
+		}
+		
+		if (m2.getSource().getModelObjectURI().equals(uri) == false) {
+			fail("m2 source ref mo URI not same as URI");
+		}
+		
+		uri = bot1.getSource().getModelObjectURI();
+		
+		if (uri == null) {
+			fail("URI not set");
+		}
+		
+		if (uri.equals("//middle.1/other") == false) {
+			fail("URI not as expected: "+uri);
+		}
+		
+		if (bot1.getSource().getModelObjectURI().equals(uri) == false) {
+			fail("bot1 source ref mo URI not same as URI");
+		}
+		
+		uri = b_mid_1.getSource().getModelObjectURI();
+		
+		if (uri == null) {
+			fail("URI not set");
+		}
+		
+		if (uri.equals("//mid/bottom.1") == false) {
+			fail("URI not as expected: "+uri);
+		}
+		
+		if (b_mid_1.getSource().getModelObjectURI().equals(uri) == false) {
+			fail("b_mid_1 source ref mo URI not same as URI");
+		}
+	}
+	
+	public void testFindChild() {
+		Top t=new Top();
+		
+		Middle mid=new Middle();
+		t.setMid(mid);
+		mid.setParent(t);
+		
+		Bottom b_mid_1=new Bottom();
+		mid.getBottom().add(b_mid_1);
+		
+		Bottom b_mid_2=new Bottom();
+		mid.getBottom().add(b_mid_2);
+		
+		Middle m1=new Middle();
+		t.getMiddle().add(m1);
+		
+		Bottom bot1=new Bottom();
+		m1.setOther(bot1);
+		bot1.setParent(m1);
+		
+		Bottom b1_1=new Bottom();
+		m1.getBottom().add(b1_1);
+		
+		Bottom b1_2=new Bottom();
+		m1.getBottom().add(b1_2);
+		
+		Middle m2=new Middle();
+		t.getMiddle().add(m2);
+		
+		Bottom b2_1=new Bottom();
+		m2.getBottom().add(b2_1);
+		
+		Bottom b2_2=new Bottom();
+		m2.getBottom().add(b2_2);
+		
+		t.initializeURIPart("");
+		
+		if (t.findChild("middle.2") != m2) {
+			fail("Failed to find middle.2 child");
+		}
+		
+		if (m1.findChild("bottom.1") != b1_1) {
+			fail("Failed to find bottom 1 child");
+		}
+		
+		if (m1.findChild("other") != bot1) {
+			fail("Failed to find other child");
+		}
+		
+		if (t.findChild("mid") != mid) {
+			fail("Failed to find mid child");
+		}
+	}
+	
+	public class Top extends ModelObject {
+		
+		@Reference(containment=true)
+		public java.util.List<Middle> getMiddle() {
+			return(m_middle);
+		}
+		
+		@Reference(containment=true)
+		public Middle getMid() {
+			return(m_mid);
+		}
+		
+		public void setMid(Middle mid) {
+			m_mid = mid;
+		}
+		
+		private java.util.List<Middle> m_middle=new ContainmentList<Middle>(Top.this, Middle.class);
+		private Middle m_mid=null;
+	}
+	
+	public class Middle extends ModelObject {
+		
+		@Reference(containment=true)
+		public java.util.List<Bottom> getBottom() {
+			return(m_bottom);
+		}
+		
+		@Reference(containment=true)
+		public Bottom getOther() {
+			return(m_other);
+		}
+		
+		public void setOther(Bottom b) {
+			m_other = b;
+		}
+		
+		private java.util.List<Bottom> m_bottom=new ContainmentList<Bottom>(Middle.this, Bottom.class);
+		private Bottom m_other=null;
+	}
+	
+	public class Bottom extends ModelObject {
+		
+	}
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/model/ModelReferenceTest.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/model/ModelReferenceTest.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/model/ModelReferenceTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,117 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 28 Feb 2009 : Initial version created by gary
+ */
+package org.scribble.model;
+
+import junit.framework.TestCase;
+
+public class ModelReferenceTest extends TestCase {
+
+	private static final String TEST_NOTATION = "test";
+
+	public void testEqualsLocalpartSame() {
+		ModelReference ref1=new ModelReference(TEST_NOTATION);
+		ModelReference ref2=new ModelReference(TEST_NOTATION);
+
+		ref1.setLocalpart("local");
+		ref2.setLocalpart("local");
+		
+		if (ref1.equals(ref2) == false) {
+			fail("Model refs should be same");
+		}
+	}
+
+	public void testEqualsLocalpartDiff() {
+		ModelReference ref1=new ModelReference(TEST_NOTATION);
+		ModelReference ref2=new ModelReference(TEST_NOTATION);
+
+		ref1.setLocalpart("local1");
+		ref2.setLocalpart("local2");
+		
+		if (ref1.equals(ref2) == true) {
+			fail("Model refs should NOT be same");
+		}
+	}
+
+	public void testEqualsFQNSame() {
+		ModelReference ref1=new ModelReference(TEST_NOTATION);
+		ModelReference ref2=new ModelReference(TEST_NOTATION);
+
+		ref1.setLocalpart("local");
+		ref1.setNamespace("ns");
+		ref2.setLocalpart("local");
+		ref2.setNamespace("ns");
+		
+		if (ref1.equals(ref2) == false) {
+			fail("Model refs should be same");
+		}
+	}
+
+	public void testEqualsFQNDiffLocalpart() {
+		ModelReference ref1=new ModelReference(TEST_NOTATION);
+		ModelReference ref2=new ModelReference(TEST_NOTATION);
+
+		ref1.setLocalpart("local1");
+		ref1.setNamespace("ns");
+		ref2.setLocalpart("local2");
+		ref2.setNamespace("ns");
+		
+		if (ref1.equals(ref2) == true) {
+			fail("Model refs should NOT be same");
+		}
+	}
+
+	public void testEqualsFQNDiffNS() {
+		ModelReference ref1=new ModelReference(TEST_NOTATION);
+		ModelReference ref2=new ModelReference(TEST_NOTATION);
+
+		ref1.setLocalpart("local");
+		ref1.setNamespace("ns1");
+		ref2.setLocalpart("local");
+		ref2.setNamespace("ns2");
+		
+		if (ref1.equals(ref2) == true) {
+			fail("Model refs should NOT be same");
+		}
+	}
+	
+	public void testHashCodeLocalpartSame() {
+		ModelReference ref1=new ModelReference(TEST_NOTATION);
+		ModelReference ref2=new ModelReference(TEST_NOTATION);
+
+		ref1.setLocalpart("local");
+		ref2.setLocalpart("local");
+		
+		if (ref1.hashCode() != ref2.hashCode()) {
+			fail("Model refs hashCode should be same");
+		}
+	}
+
+	public void testHashCodeLocalpartDiff() {
+		ModelReference ref1=new ModelReference(TEST_NOTATION);
+		ModelReference ref2=new ModelReference(TEST_NOTATION);
+
+		ref1.setLocalpart("local1");
+		ref2.setLocalpart("local2");
+		
+		if (ref1.hashCode() == ref2.hashCode()) {
+			fail("Model refs hashCode should NOT be same");
+		}
+	}
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/model/ModelTest.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/model/ModelTest.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/model/ModelTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,122 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 6 Sep 2008 : Initial version created by gary
+ */
+package org.scribble.model;
+
+import java.util.List;
+
+import junit.framework.TestCase;
+
+public class ModelTest extends TestCase {
+
+	public void testFindModelObject() {
+		
+		TopModel t=new TopModel();
+		
+		Middle mid=new Middle();
+		t.setMid(mid);
+		mid.setParent(t);
+		
+		Bottom b_mid_1=new Bottom();
+		mid.getBottom().add(b_mid_1);
+		
+		Bottom b_mid_2=new Bottom();
+		mid.getBottom().add(b_mid_2);
+		
+		Middle m1=new Middle();
+		t.getMiddle().add(m1);
+		
+		Bottom bot1=new Bottom();
+		m1.setOther(bot1);
+		bot1.setParent(m1);
+		
+		Bottom b1_1=new Bottom();
+		m1.getBottom().add(b1_1);
+		
+		Bottom b1_2=new Bottom();
+		m1.getBottom().add(b1_2);
+		
+		Middle m2=new Middle();
+		t.getMiddle().add(m2);
+		
+		Bottom b2_1=new Bottom();
+		m2.getBottom().add(b2_1);
+		
+		Bottom b2_2=new Bottom();
+		m2.getBottom().add(b2_2);
+		
+		t.initializeURIs();
+		
+		if (t.findModelObject("//middle.1/bottom.1") != b1_1) {
+			fail("Failed to find m1->b1");
+		}
+		
+		if (t.findModelObject("//mid/bottom.2") != b_mid_2) {
+			fail("Failed to find mid->b2");
+		}
+		
+		if (t.findModelObject("//middle.1/other") != bot1) {
+			fail("Failed to find m1->other");
+		}
+	}
+	
+	public class TopModel extends TestModel {
+		
+		@Reference(containment=true)
+		public java.util.List<Middle> getMiddle() {
+			return(m_middle);
+		}
+		
+		@Reference(containment=true)
+		public Middle getMid() {
+			return(m_mid);
+		}
+		
+		public void setMid(Middle mid) {
+			m_mid = mid;
+		}
+
+		private java.util.List<Middle> m_middle=new ContainmentList<Middle>(TopModel.this, Middle.class);
+		private Middle m_mid=null;
+	}
+	
+	public class Middle extends ModelObject {
+		
+		@Reference(containment=true)
+		public java.util.List<Bottom> getBottom() {
+			return(m_bottom);
+		}
+		
+		@Reference(containment=true)
+		public Bottom getOther() {
+			return(m_other);
+		}
+		
+		public void setOther(Bottom b) {
+			m_other = b;
+		}
+		
+		private java.util.List<Bottom> m_bottom=new ContainmentList<Bottom>(Middle.this, Bottom.class);
+		private Bottom m_other=null;
+	}
+	
+	public class Bottom extends ModelObject {
+		
+	}
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/model/TestDefinition.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/model/TestDefinition.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/model/TestDefinition.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 8 November 2009 : Initial version created by gary
+ */
+package org.scribble.model;
+
+public class TestDefinition extends Definition {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 6928397919692808974L;
+
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/model/TestModel.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/model/TestModel.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/model/TestModel.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 28 Feb 2009 : Initial version created by gary
+ */
+package org.scribble.model;
+
+import java.util.List;
+
+public class TestModel extends Model {
+
+	private static final long serialVersionUID = 1451347101999033427L;
+
+	public void setDefinition(Definition defn) {
+		defn.setParent(this);
+		
+		m_definitions.add(defn);
+	}
+	
+	@Override
+	public List<Definition> getDefinitions() {
+		return(m_definitions);
+	}
+
+	private List<Definition> m_definitions=new java.util.Vector<Definition>();
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/model/TestMultiPathBehaviour.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/model/TestMultiPathBehaviour.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/model/TestMultiPathBehaviour.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 8 November 2009 : Initial version created by gary
+ */
+package org.scribble.model;
+
+import java.util.List;
+
+public class TestMultiPathBehaviour extends MultiPathBehaviour {
+
+	private static final long serialVersionUID = 8235810904977687042L;
+
+	public TestMultiPathBehaviour() {
+	}
+	
+	@Override
+	public Block createNewPath() {
+		Block ret=new Block();
+		ret.setParent(this);
+		
+		m_paths.add(ret);
+		
+		return(ret);
+	}
+
+	@Override
+	public OrderingConstraint getOrdering() {
+		return(m_ordering);
+	}
+	
+	public void setOrdering(OrderingConstraint oc) {
+		m_ordering = oc;
+	}
+
+	@Override
+	public List<Block> getPaths() {
+		return(m_paths);
+	}
+
+	@Override
+	public boolean removePath(Block path) {
+		return(m_paths.remove(path));
+	}
+
+	private java.util.List<Block> m_paths=new java.util.Vector<Block>();
+	private OrderingConstraint m_ordering=OrderingConstraint.Ordered;
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/model/TestSinglePathBehaviour.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/model/TestSinglePathBehaviour.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/model/TestSinglePathBehaviour.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 8 November 2009 : Initial version created by gary
+ */
+package org.scribble.model;
+
+public class TestSinglePathBehaviour extends SinglePathBehaviour {
+
+	private static final long serialVersionUID = 7412502499877343886L;
+
+	public TestSinglePathBehaviour() {
+		m_block.setParent(this);
+	}
+	
+	@Override
+	public Block getBlock() {
+		return(m_block);
+	}
+
+	private Block m_block=new Block();
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/model/admin/DefaultModelListenerTest.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/model/admin/DefaultModelListenerTest.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/model/admin/DefaultModelListenerTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,229 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 30 Apr 2008 : Initial version created by gary
+ */
+package org.scribble.model.admin;
+
+import junit.framework.TestCase;
+
+public class DefaultModelListenerTest extends TestCase {
+
+	private static final String OTHER_RESOLUTION = "OtherResolution";
+
+	public void testPlaceholder() {
+	}
+	
+	/*
+	public void testCheckShowReferenceDescriptionProperties1() {
+		java.util.Map<String,Object> props=new java.util.HashMap<String,Object>();
+		java.util.Map<String,Object> additionalProps=new java.util.HashMap<String,Object>();
+		
+		props.put(ModelListener.RESOLUTIONS, ModelListener.SHOW_REFERENCE_DESCRIPTION_RESOLUTION);
+		props.put(ModelListener.REFERENCE_MODEL, "refmodel1");
+		props.put(ModelListener.REFERENCE_MODEL_START_POSITION, "1");
+		props.put(ModelListener.REFERENCE_MODEL_END_POSITION, "2");
+		
+		additionalProps.put(ModelListener.RESOLUTIONS, ModelListener.SHOW_REFERENCE_DESCRIPTION_RESOLUTION);
+		additionalProps.put(ModelListener.REFERENCE_MODEL, "refmodel2");
+		additionalProps.put(ModelListener.REFERENCE_MODEL_START_POSITION, "3");
+		additionalProps.put(ModelListener.REFERENCE_MODEL_END_POSITION, "4");
+		
+		DefaultModelListener l=new DefaultModelListener();
+		
+		l.checkShowReferenceDescriptionProperties(props, additionalProps);
+		
+		if (additionalProps.containsKey(ModelListener.RESOLUTIONS)) {
+			fail("Resolution should not be defined");
+		}
+		
+		if (additionalProps.containsKey(ModelListener.REFERENCE_MODEL)) {
+			fail("Reference model should not be defined");
+		}
+		
+		if (additionalProps.containsKey(ModelListener.REFERENCE_MODEL_START_POSITION)) {
+			fail("Reference model start should not be defined");
+		}
+		
+		if (additionalProps.containsKey(ModelListener.REFERENCE_MODEL_END_POSITION)) {
+			fail("Reference model end should not be defined");
+		}
+	}
+
+	public void testCheckShowReferenceDescriptionProperties2() {
+		java.util.Map<String,Object> props=new java.util.HashMap<String,Object>();
+		java.util.Map<String,Object> additionalProps=new java.util.HashMap<String,Object>();
+		
+		props.put(ModelListener.RESOLUTIONS, ModelListener.SHOW_REFERENCE_DESCRIPTION_RESOLUTION);
+		props.put(ModelListener.REFERENCE_MODEL, "refmodel1");
+		props.put(ModelListener.REFERENCE_MODEL_START_POSITION, "1");
+		props.put(ModelListener.REFERENCE_MODEL_END_POSITION, "2");
+		
+		additionalProps.put(ModelListener.RESOLUTIONS,
+				ModelListener.SHOW_REFERENCE_DESCRIPTION_RESOLUTION+","+
+				OTHER_RESOLUTION);
+		additionalProps.put(ModelListener.REFERENCE_MODEL, "refmodel2");
+		additionalProps.put(ModelListener.REFERENCE_MODEL_START_POSITION, "3");
+		additionalProps.put(ModelListener.REFERENCE_MODEL_END_POSITION, "4");
+		
+		DefaultModelListener l=new DefaultModelListener();
+		
+		l.checkShowReferenceDescriptionProperties(props, additionalProps);
+		
+		if (additionalProps.get(ModelListener.RESOLUTIONS).equals(OTHER_RESOLUTION) == false) {
+			fail("Resolution not as expected: "+additionalProps.get(ModelListener.RESOLUTIONS));
+		}
+		
+		if (additionalProps.containsKey(ModelListener.REFERENCE_MODEL)) {
+			fail("Reference model should not be defined");
+		}
+		
+		if (additionalProps.containsKey(ModelListener.REFERENCE_MODEL_START_POSITION)) {
+			fail("Reference model start should not be defined");
+		}
+		
+		if (additionalProps.containsKey(ModelListener.REFERENCE_MODEL_END_POSITION)) {
+			fail("Reference model end should not be defined");
+		}
+	}
+
+	public void testCheckShowReferenceDescriptionProperties3() {
+		java.util.Map<String,Object> props=new java.util.HashMap<String,Object>();
+		java.util.Map<String,Object> additionalProps=new java.util.HashMap<String,Object>();
+		
+		props.put(ModelListener.RESOLUTIONS, ModelListener.SHOW_REFERENCE_DESCRIPTION_RESOLUTION);
+		props.put(ModelListener.REFERENCE_MODEL, "refmodel1");
+		props.put(ModelListener.REFERENCE_MODEL_START_POSITION, "1");
+		props.put(ModelListener.REFERENCE_MODEL_END_POSITION, "2");
+		props.put(ModelListener.REFERENCE_MODEL_COMPONENT, "comp1");
+		
+		additionalProps.put(ModelListener.RESOLUTIONS, OTHER_RESOLUTION+","+
+				ModelListener.SHOW_REFERENCE_DESCRIPTION_RESOLUTION);
+		additionalProps.put(ModelListener.REFERENCE_MODEL, "refmodel2");
+		additionalProps.put(ModelListener.REFERENCE_MODEL_START_POSITION, "3");
+		additionalProps.put(ModelListener.REFERENCE_MODEL_END_POSITION, "4");
+		additionalProps.put(ModelListener.REFERENCE_MODEL_COMPONENT, "comp2");
+		
+		DefaultModelListener l=new DefaultModelListener();
+		
+		l.checkShowReferenceDescriptionProperties(props, additionalProps);
+		
+		if (additionalProps.get(ModelListener.RESOLUTIONS).equals(OTHER_RESOLUTION) == false) {
+			fail("Resolution not as expected: "+additionalProps.get(ModelListener.RESOLUTIONS));
+		}
+		
+		if (additionalProps.containsKey(ModelListener.REFERENCE_MODEL)) {
+			fail("Reference model should not be defined");
+		}
+		
+		if (additionalProps.containsKey(ModelListener.REFERENCE_MODEL_START_POSITION)) {
+			fail("Reference model start should not be defined");
+		}
+		
+		if (additionalProps.containsKey(ModelListener.REFERENCE_MODEL_END_POSITION)) {
+			fail("Reference model end should not be defined");
+		}
+		
+		if (additionalProps.containsKey(ModelListener.REFERENCE_MODEL_COMPONENT)) {
+			fail("Reference model component should not be defined");
+		}
+	}
+	*/
+
+	/*
+	public void testApplyProperties1() {
+		java.util.Map<String,Object> props=new java.util.HashMap<String,Object>();
+		java.util.Map<String,Object> additionalProps=new java.util.HashMap<String,Object>();
+		
+		props.put(ModelListener.RESOLUTIONS, ModelListener.SHOW_REFERENCE_DESCRIPTION_RESOLUTION);
+		props.put(ModelListener.REFERENCE_MODEL, "refmodel1");
+		props.put(ModelListener.REFERENCE_MODEL_START_POSITION, "1");
+		props.put(ModelListener.REFERENCE_MODEL_END_POSITION, "2");
+		props.put(ModelListener.REFERENCE_MODEL_COMPONENT, "comp1");
+		
+		additionalProps.put(ModelListener.RESOLUTIONS, ModelListener.SHOW_REFERENCE_DESCRIPTION_RESOLUTION);
+		additionalProps.put(ModelListener.REFERENCE_MODEL, "refmodel2");
+		additionalProps.put(ModelListener.REFERENCE_MODEL_START_POSITION, "3");
+		additionalProps.put(ModelListener.REFERENCE_MODEL_END_POSITION, "4");
+		additionalProps.put(ModelListener.REFERENCE_MODEL_COMPONENT, "comp2");
+		
+		DefaultModelListener l=new DefaultModelListener();
+		
+		l.applyProperties(props, null, additionalProps);
+		
+		if (props.get(ModelListener.RESOLUTIONS).equals(
+				ModelListener.SHOW_REFERENCE_DESCRIPTION_RESOLUTION) == false) {
+			fail("Resolution not as expected: "+props.get(ModelListener.RESOLUTIONS));
+		}
+		
+		if (props.get(ModelListener.REFERENCE_MODEL).equals("refmodel1") == false) {
+			fail("Reference model not as expected: "+props.get(ModelListener.REFERENCE_MODEL));
+		}
+		
+		if (props.get(ModelListener.REFERENCE_MODEL_START_POSITION).equals("1") == false) {
+			fail("Reference model start not as expected: "+props.get(ModelListener.REFERENCE_MODEL_START_POSITION));
+		}
+		
+		if (props.get(ModelListener.REFERENCE_MODEL_END_POSITION).equals("2") == false) {
+			fail("Reference model end not as expected: "+props.get(ModelListener.REFERENCE_MODEL_END_POSITION));
+		}
+		
+		if (props.get(ModelListener.REFERENCE_MODEL_COMPONENT).equals("comp1") == false) {
+			fail("Reference model component not as expected: "+props.get(ModelListener.REFERENCE_MODEL_COMPONENT));
+		}
+	}
+
+	public void testApplyProperties2() {
+		java.util.Map<String,Object> props=new java.util.HashMap<String,Object>();
+		java.util.Map<String,Object> additionalProps=new java.util.HashMap<String,Object>();
+		
+		props.put(ModelListener.RESOLUTIONS, ModelListener.SHOW_REFERENCE_DESCRIPTION_RESOLUTION);
+		props.put(ModelListener.REFERENCE_MODEL, "refmodel1");
+		props.put(ModelListener.REFERENCE_MODEL_START_POSITION, "1");
+		props.put(ModelListener.REFERENCE_MODEL_END_POSITION, "2");
+		
+		additionalProps.put(ModelListener.RESOLUTIONS,
+				ModelListener.SHOW_REFERENCE_DESCRIPTION_RESOLUTION+","+
+								OTHER_RESOLUTION);
+		additionalProps.put(ModelListener.REFERENCE_MODEL, "refmodel2");
+		additionalProps.put(ModelListener.REFERENCE_MODEL_START_POSITION, "3");
+		additionalProps.put(ModelListener.REFERENCE_MODEL_END_POSITION, "4");
+		
+		DefaultModelListener l=new DefaultModelListener();
+		
+		l.applyProperties(props, null, additionalProps);
+		
+		if (props.get(ModelListener.RESOLUTIONS).equals(
+				ModelListener.SHOW_REFERENCE_DESCRIPTION_RESOLUTION+","+
+						OTHER_RESOLUTION) == false) {
+			fail("Resolution not as expected: "+props.get(ModelListener.RESOLUTIONS));
+		}
+		
+		if (props.get(ModelListener.REFERENCE_MODEL).equals("refmodel1") == false) {
+			fail("Reference model not as expected: "+props.get(ModelListener.REFERENCE_MODEL));
+		}
+		
+		if (props.get(ModelListener.REFERENCE_MODEL_START_POSITION).equals("1") == false) {
+			fail("Reference model start not as expected: "+props.get(ModelListener.REFERENCE_MODEL_START_POSITION));
+		}
+		
+		if (props.get(ModelListener.REFERENCE_MODEL_END_POSITION).equals("2") == false) {
+			fail("Reference model end not as expected: "+props.get(ModelListener.REFERENCE_MODEL_END_POSITION));
+		}
+	}
+	*/
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/model/admin/ErrorRecorder.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/model/admin/ErrorRecorder.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/model/admin/ErrorRecorder.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,121 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 14 Jul 2008 : Initial version created by gary
+ */
+package org.scribble.model.admin;
+
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+
+public class ErrorRecorder implements ModelListener {
+
+	public ErrorRecorder() {
+	}
+	
+	public void error(ModelIssue issue) {
+		
+		if (issue.getModelObject() == null) {
+			throw new RuntimeException("Null model object");
+		}
+		
+		m_errors.add(issue);
+		reported(issue.getMessage());
+	}
+
+	public void warning(ModelIssue issue) {
+
+		if (issue.getModelObject() == null) {
+			throw new RuntimeException("Null model object");
+		}
+
+		m_warnings.add(issue);
+		reported(issue.getMessage());
+	}
+	
+	protected void reported(String mesg) {
+		if (mesg != null) {
+			
+			// Check if in the list of messages to be
+			// detected
+			if (m_errorsToDetect.contains(mesg)) {
+				m_errorsToDetect.remove(mesg);
+			} else {
+				m_unexpectedErrors.add(mesg);
+			}
+		}		
+	}
+
+	public void addExpectedError(String mesg) {
+		m_errorsToDetect.add(mesg);
+	}
+	
+	public boolean isValid() {
+		// If there are no more errors to detect, and no
+		// unexpected errors have been reported, then
+		// the expression has been validated as expected
+		return(m_errorsToDetect.size() == 0 &&
+				m_unexpectedErrors.size() == 0);
+	}
+	
+	public String invalidMessage() {
+		String ret="\r\n";
+		
+		if (m_errorsToDetect.size() > 0) {
+			ret += "Errors not detected:\r\n";
+			
+			for (int i=0; i < m_errorsToDetect.size(); i++) {
+				ret += m_errorsToDetect.get(i)+"\r\n";
+			}
+		}
+		
+		if (m_unexpectedErrors.size() > 0) {
+			ret += "Unexpected Errors:\r\n";
+			
+			for (int i=0; i < m_unexpectedErrors.size(); i++) {
+				ret += m_unexpectedErrors.get(i)+"\r\n";
+			}
+		}
+		
+		return(ret);
+	}
+
+	public java.util.List<ModelIssue> getErrors() {
+		return(m_errors);
+	}
+	
+	public java.util.List<ModelIssue> getWarnings() {
+		return(m_warnings);
+	}
+	
+	public boolean hasError(String mesg) {
+		boolean ret=false;
+		
+		for (int i=0; ret == false && i < m_errors.size(); i++) {
+			ModelIssue re=m_errors.get(i);
+			
+			ret = re.getMessage().equals(mesg);
+		}
+		
+		return(ret);
+	}
+	
+	private java.util.List<ModelIssue> m_errors=new java.util.Vector<ModelIssue>();
+	private java.util.List<ModelIssue> m_warnings=new java.util.Vector<ModelIssue>();
+	private java.util.List<String> m_errorsToDetect=new java.util.Vector<String>();
+	private java.util.List<String> m_unexpectedErrors=new java.util.Vector<String>();
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/model/admin/TestModelResource.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/model/admin/TestModelResource.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/model/admin/TestModelResource.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,51 @@
+package org.scribble.model.admin;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+
+import org.scribble.model.ModelReference;
+
+public class TestModelResource implements ModelResource {
+
+	public TestModelResource(ModelReference ref) {
+		m_reference = ref;
+	}
+
+	@Override
+	public InputStream getContents() throws IOException {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public ModelReference getReference() {
+		return(m_reference);
+	}
+
+	@Override
+	public URI getURI() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+	
+	public boolean equals(Object obj) {
+		boolean ret=false;
+		
+		if (obj instanceof TestModelResource) {
+			TestModelResource tmr=(TestModelResource)obj;
+			
+			if (m_reference.equals(tmr.getReference())) {
+				ret = true;
+			}
+		}
+		
+		return(ret);
+	}
+	
+	public int hashCode() {
+		return(m_reference.hashCode());
+	}
+	
+	private ModelReference m_reference=null;
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/model/analysis/TestLookaheadAnalyser.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/model/analysis/TestLookaheadAnalyser.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/model/analysis/TestLookaheadAnalyser.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 5 Aug 2008 : Initial version created by gary
+ */
+package org.scribble.model.analysis;
+
+import java.util.Set;
+
+import org.scribble.model.Interaction;
+import org.scribble.model.ModelObject;
+
+public class TestLookaheadAnalyser implements LookaheadAnalyser {
+
+	public Set<Interaction> getInteractions(ModelObject mobj) {
+		return(m_interactions);
+	}
+
+	public Set<Interaction> getInteractions(ModelObject mobj,
+			boolean stopAtConditionalInitiator) {
+		return(m_interactions);
+	}
+
+	public void setInteractions(Set<Interaction> interactions) {
+		m_interactions = interactions;
+	}
+	
+	private Set<Interaction> m_interactions=null;
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/model/change/TestChangeInformation.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/model/change/TestChangeInformation.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/model/change/TestChangeInformation.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 30 Jul 2008 : Initial version created by gary
+ */
+package org.scribble.model.change;
+
+import org.scribble.model.Model;
+import org.scribble.model.ModelObject;
+
+public class TestChangeInformation {
+
+	public TestChangeInformation(Model model, ModelObject mobj,
+						ModelObject other) {
+		m_model = model;
+		m_mobj = mobj;
+		m_other = other;
+	}
+	
+	public void setInsert(boolean insert) {
+		m_insert = insert;
+	}
+	
+	public boolean isInsert() {
+		return(m_insert);
+	}
+	
+	public void setUpdate(boolean update) {
+		m_update = update;
+	}
+	
+	public boolean isUpdate() {
+		return(m_update);
+	}
+	
+	public void setDelete(boolean delete) {
+		m_delete = delete;
+	}
+	
+	public boolean isDelete() {
+		return(m_delete);
+	}
+	
+	public Model getModel() {
+		return(m_model);
+	}
+	
+	public ModelObject getModelObject() {
+		return(m_mobj);
+	}
+	
+	public ModelObject getOther() {
+		return(m_other);
+	}
+	
+	private boolean m_insert=false;
+	private boolean m_update=false;
+	private boolean m_delete=false;
+	private Model m_model=null;
+	private ModelObject m_mobj=null;
+	private ModelObject m_other=null;
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/model/change/TestModelChangeContext.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/model/change/TestModelChangeContext.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/model/change/TestModelChangeContext.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 30 Jul 2008 : Initial version created by gary
+ */
+package org.scribble.model.change;
+
+import org.scribble.model.Model;
+import org.scribble.model.ModelObject;
+import org.scribble.model.Role;
+
+public class TestModelChangeContext implements ModelChangeContext {
+
+	public Object getParent() {
+		return(m_parent);
+	}
+
+	public void setParent(Object parent) {
+		m_parent = parent;
+	}
+
+	public Role getRole() {
+		return(m_role);
+	}
+	
+	public void setRole(Role role) {
+		m_role = role;
+	}
+
+	public boolean insert(Model model, ModelObject mobj, ModelObject ref) {
+		TestChangeInformation tci=new TestChangeInformation(model, mobj, ref);
+		tci.setInsert(true);
+		m_changeInfo.add(tci);
+		return(true);
+	}
+
+	public boolean update(Model model, ModelObject mobj, ModelObject toObj) {
+		TestChangeInformation tci=new TestChangeInformation(model, mobj, toObj);
+		tci.setUpdate(true);
+		m_changeInfo.add(tci);
+		return(true);
+	}
+
+	public boolean delete(Model model, ModelObject mobj) {
+		TestChangeInformation tci=new TestChangeInformation(model, mobj, null);
+		tci.setDelete(true);
+		m_changeInfo.add(tci);
+		return(true);
+	}
+
+	/**
+	 * This method returns a set of properties used during model change
+	 * processing.
+	 * 
+	 * @return The properties
+	 */
+	public java.util.Map<String,Object> getProperties() {
+		return(m_properties);
+	}
+	
+	private Role m_role=null;
+	private Object m_parent=null;
+	private java.util.List<TestChangeInformation> m_changeInfo=new java.util.Vector<TestChangeInformation>();
+	private java.util.Map<String,Object> m_properties=new java.util.HashMap<String,Object>();
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/model/filter/DefaultModelFilterTest.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/model/filter/DefaultModelFilterTest.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/model/filter/DefaultModelFilterTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,115 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 21 Jan 2009 : Initial version created by gary
+ */
+package org.scribble.model.filter;
+
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.scribble.model.*;
+
+public class DefaultModelFilterTest extends TestCase {
+
+	public void testInteractionFilter() {
+		DefaultModelFilter dmf=new DefaultModelFilter();
+		
+		TestModel model=new TestModel();
+		
+		TestDefinition defn=new TestDefinition();
+		model.getDefinitions().add(defn);
+	
+		Role r1=new Role();
+		r1.setName("r1");
+		
+		Role r2=new Role();
+		r2.setName("r2");
+		
+		Role r3=new Role();
+		r3.setName("r3");
+		
+		Interaction i1=new Interaction();
+		i1.setFromRole(r1);
+		i1.setToRole(r2);
+		
+		defn.getBlock().getContents().add(i1);
+		
+		Interaction i2=new Interaction();
+		i2.setFromRole(r2);
+		i2.setToRole(r3);
+		
+		defn.getBlock().getContents().add(i2);
+		
+		Interaction i3=new Interaction();
+		i3.setFromRole(r3);
+		i3.setToRole(r2);
+		
+		defn.getBlock().getContents().add(i3);
+		
+		Interaction i4=new Interaction();
+		i4.setFromRole(r2);
+		i4.setToRole(r1);
+		
+		defn.getBlock().getContents().add(i4);
+		
+		java.util.List<Role> roles=new java.util.Vector<Role>();
+		roles.add(r1);
+		roles.add(r2);
+		
+		dmf.filter(model, roles);
+		
+		if (defn.getBlock().getContents().size() != 2) {
+			fail("Only two interactions should be left");
+		}
+		
+		if (defn.getBlock().getContents().get(0) != i1) {
+			fail("First interaction not i1");
+		}
+		
+		if (defn.getBlock().getContents().get(1) != i4) {
+			fail("Second interaction not i2");
+		}
+	}
+	
+	public class TestDefinition extends Definition {
+		
+	}
+	
+	public class TestModel extends Model {
+		
+		public List<Definition> getDefinitions() {
+			return(m_definitions);
+		}
+
+		public LocatedName getModelName() {
+			return null;
+		}
+
+		public String getNotation() {
+			return null;
+		}
+
+		public List<Role> getRoles() {
+			return null;
+		}
+		
+		private java.util.List<Definition> m_definitions=
+						new java.util.Vector<Definition>();
+	}
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/model/util/InteractionUtilTest.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/model/util/InteractionUtilTest.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/model/util/InteractionUtilTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,177 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 8 November 2009 : Initial version created by gary
+ */
+package org.scribble.model.util;
+
+import junit.framework.TestCase;
+
+import org.scribble.model.*;
+
+public class InteractionUtilTest extends TestCase {
+
+	public void testGetInitialInteractions() {
+		Definition defn=new TestDefinition();
+		
+		Interaction i1=new Interaction();
+		
+		defn.getBlock().getContents().add(i1);
+		
+		Interaction i2=new Interaction();
+		
+		defn.getBlock().getContents().add(i2);
+		
+		java.util.List<Interaction> results=InteractionUtil.getInitialInteractions(defn);
+		
+		if (results.size() != 1) {
+			fail("Only expecting 1 result: "+results.size());
+		}
+		
+		if (results.get(0) != i1) {
+			fail("Interaction not the expected one");
+		}
+	}
+	
+	public void testGetInitialInteractionsInSinglePath() {
+		Definition defn=new TestDefinition();
+		
+		TestSinglePathBehaviour spb=new TestSinglePathBehaviour();
+		
+		Interaction i1=new Interaction();
+		spb.getBlock().getContents().add(i1);
+		
+		defn.getBlock().getContents().add(spb);
+		
+		java.util.List<Interaction> results=InteractionUtil.getInitialInteractions(defn);
+		
+		if (results.size() != 1) {
+			fail("Only expecting 1 result: "+results.size());
+		}
+		
+		if (results.get(0) != i1) {
+			fail("Interaction not the expected one");
+		}
+	}	
+	
+	public void testGetInitialInteractionsInMultiPath() {
+		Definition defn=new TestDefinition();
+		
+		TestMultiPathBehaviour mpb=new TestMultiPathBehaviour();
+		
+		Interaction i1=new Interaction();
+		
+		Block b1=mpb.createNewPath();
+		
+		b1.getContents().add(i1);
+		
+		Interaction i2=new Interaction();
+		
+		Block b2=mpb.createNewPath();
+		
+		b2.getContents().add(i2);
+		
+		defn.getBlock().getContents().add(mpb);
+		
+		java.util.List<Interaction> results=InteractionUtil.getInitialInteractions(defn);
+		
+		if (results.size() != 2) {
+			fail("Only expecting 2 results: "+results.size());
+		}
+		
+		if (results.contains(i1) == false) {
+			fail("Interaction i1 not in the results");
+		}
+		
+		if (results.contains(i2) == false) {
+			fail("Interaction i2 not in the results");
+		}
+	}
+	
+	public void testIsInitialInteraction() {
+		
+		TestModel model=new TestModel();
+		
+		Definition defn=new TestDefinition();
+		model.setDefinition(defn);
+		
+		Interaction i1=new Interaction();
+		
+		defn.getBlock().getContents().add(i1);
+		
+		Interaction i2=new Interaction();
+	
+		defn.getBlock().getContents().add(i2);
+		
+		if (InteractionUtil.isInitialInteraction(i1) == false) {
+			fail("Should be initial interaction");
+		}
+		
+		if (InteractionUtil.isInitialInteraction(i2)) {
+			fail("Should NOT be initial interaction");
+		}
+	}
+	
+	public void testIsInitialInteractionInSinglePath() {
+		TestModel model=new TestModel();
+		
+		Definition defn=new TestDefinition();
+		model.setDefinition(defn);
+		
+		TestSinglePathBehaviour spb=new TestSinglePathBehaviour();
+		
+		Interaction i1=new Interaction();
+		spb.getBlock().getContents().add(i1);
+		
+		defn.getBlock().getContents().add(spb);
+		
+		if (InteractionUtil.isInitialInteraction(i1) == false) {
+			fail("Should be initial interaction");
+		}
+	}	
+	
+	public void testIsInitialInteractionInMultiPath() {
+		TestModel model=new TestModel();
+		
+		Definition defn=new TestDefinition();
+		model.setDefinition(defn);
+		
+		TestMultiPathBehaviour mpb=new TestMultiPathBehaviour();
+		
+		Interaction i1=new Interaction();
+		
+		Block b1=mpb.createNewPath();
+		
+		b1.getContents().add(i1);
+		
+		Interaction i2=new Interaction();
+		
+		Block b2=mpb.createNewPath();
+		
+		b2.getContents().add(i2);
+		
+		defn.getBlock().getContents().add(mpb);
+		
+		if (InteractionUtil.isInitialInteraction(i1) == false) {
+			fail("Interaction i1 not initial");
+		}
+		
+		if (InteractionUtil.isInitialInteraction(i2) == false) {
+			fail("Interaction i2 not initial");
+		}
+	}	
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/parser/ChannelListParserRuleTest.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/parser/ChannelListParserRuleTest.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/parser/ChannelListParserRuleTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,176 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 5 May 2008 : Initial version created by gary
+ */
+package org.scribble.parser;
+
+import junit.framework.TestCase;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ErrorRecorder;
+
+public class ChannelListParserRuleTest extends TestCase {
+
+	protected void setUp() throws Exception {
+		org.scribble.extensions.TestRegistry reg=
+				new org.scribble.extensions.TestRegistry();
+		
+		reg.addExtension(GenericKeyWordProvider.class);
+		reg.addExtension(GenericParser.class);
+		reg.addExtension(org.scribble.parser.ChannelListParserRule.class);
+		reg.addExtension(TestModelRepository.class);
+		
+		org.scribble.extensions.RegistryFactory.setRegistry(reg);
+	}
+	
+	protected void tearDown() throws Exception {
+		// Clear registry
+		org.scribble.extensions.RegistryFactory.setRegistry(null);
+	}
+	
+	public void testValidChannelList() {
+		String role1Name="Customer";
+		Role role1=new Role(role1Name);
+		String role2Name="Supplier";
+		Role role2=new Role(role2Name);
+		String channel1Name="Ch1";
+		String channel2Name="Ch2";
+
+		String text="channel "+channel1Name+" from "+role1Name+" to "+role2Name+
+					", "+channel2Name+";";
+		
+		ModelReference ref=new ModelReference("");
+		TestParserContext context=new TestParserContext(ref, text);
+		ErrorRecorder l=new ErrorRecorder();
+		
+		context.setState(role1Name, role1);
+		context.setState(role2Name, role2);
+		
+		Object obj=context.parse(ChannelList.class, l);
+		
+		if (obj instanceof ChannelList) {
+			ChannelList chlist=(ChannelList)obj;
+			
+			if (chlist.getChannels().size() != 2) {
+				fail("Two channels expected: "+
+						chlist.getChannels().size());
+			}
+			
+			if (chlist.getChannels().get(0).getFromRole() == null) {
+				fail("First channel From role not set");
+			} else if (chlist.getChannels().get(0).getFromRole() != role1) {
+				fail("First channel From role not expected: "+chlist.getChannels().get(0).getFromRole());
+			}
+			
+			if (chlist.getChannels().get(0).getToRole() == null) {
+				fail("First channel To role not set");
+			} else if (chlist.getChannels().get(0).getFromRole() != role1) {
+				fail("First channel To role not expected: "+chlist.getChannels().get(0).getToRole());
+			}
+			
+			if (chlist.getChannels().get(1).getFromRole() != null) {
+				fail("Second channel should not have 'from' role");
+			}
+			
+			if (chlist.getChannels().get(1).getToRole() != null) {
+				fail("Second channel should not have 'to' role");
+			}
+			
+			Channel ch1=(Channel)context.getState(channel1Name);
+			Channel ch2=(Channel)context.getState(channel2Name);
+			
+			if (ch1 == null) {
+				fail("Channel1 not created");
+			}
+			
+			if (ch2 == null) {
+				fail("Channel2 not created");
+			}
+			
+			// Check no errors or warnings
+			if (l.getErrors().size() > 0) {
+				fail("Not expecting "+l.getErrors().size()+" errors");
+			} else if (l.getWarnings().size() > 0) {
+				fail("Not expecting "+l.getWarnings().size()+" warnings");
+			}
+			
+		} else if (obj == null) {
+			fail("No object returned");
+		} else {
+			fail("Unexpected object type: "+obj.getClass());
+		}
+	}
+
+	public void testInvalidChannelListToRole() {
+		String role1Name="Customer";
+		Role role1=new Role(role1Name);
+		String role2Name="Supplier";
+		Role role2=new Role(role2Name);
+		String channel1Name="Ch1";
+		String channel2Name="Ch2";
+
+		String text="channel "+channel1Name+" from "+role1Name+" to "+role2Name+
+					", "+channel2Name+";";
+		
+		ModelReference ref=new ModelReference("");
+		TestParserContext context=new TestParserContext(ref, text);
+		ErrorRecorder l=new ErrorRecorder();
+		
+		context.setState(role1Name, role1);
+		//context.setState(role2Name, role2);
+		
+		context.parse(ChannelList.class, l);
+		
+		if (l.hasError(org.scribble.util.MessageUtil.format(
+					java.util.PropertyResourceBundle.getBundle(
+						"org.scribble.parser.Messages"),
+							"_UNKNOWN_ROLE",
+						new String[]{role2Name})) == false) {
+			fail("Should register 'unknown role' error");
+		}
+	}
+
+	public void testInvalidChannelListFromRole() {
+		String role1Name="Customer";
+		Role role1=new Role(role1Name);
+		String role2Name="Supplier";
+		Role role2=new Role(role2Name);
+		String channel1Name="Ch1";
+		String channel2Name="Ch2";
+
+		String text="channel "+channel1Name+" from "+role1Name+" to "+role2Name+
+					", "+channel2Name+";";
+		
+		ModelReference ref=new ModelReference("");
+		TestParserContext context=new TestParserContext(ref, text);
+		ErrorRecorder l=new ErrorRecorder();
+		
+		//context.setState(role1Name, role1);
+		context.setState(role2Name, role2);
+		
+		context.parse(ChannelList.class, l);
+		
+		if (l.hasError(org.scribble.util.MessageUtil.format(
+					java.util.PropertyResourceBundle.getBundle(
+						"org.scribble.parser.Messages"),
+							"_UNKNOWN_ROLE",
+						new String[]{role1Name})) == false) {
+			fail("Should register 'unknown role' error");
+		}
+	}
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/parser/ConformanceReferenceParserRuleTest.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/parser/ConformanceReferenceParserRuleTest.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/parser/ConformanceReferenceParserRuleTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,266 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 7 May 2008 : Initial version created by gary
+ */
+package org.scribble.parser;
+
+import junit.framework.TestCase;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ErrorRecorder;
+
+public class ConformanceReferenceParserRuleTest extends TestCase {
+
+	protected void setUp() throws Exception {
+		org.scribble.extensions.TestRegistry reg=
+				new org.scribble.extensions.TestRegistry();
+		
+		reg.addExtension(GenericKeyWordProvider.class);
+		reg.addExtension(GenericParser.class);
+		reg.addExtension(org.scribble.parser.ConformanceReferenceParserRule.class);
+		reg.addExtension(TestModelRepository.class);
+		
+		org.scribble.extensions.RegistryFactory.setRegistry(reg);
+	}
+	
+	protected void tearDown() throws Exception {
+		// Clear registry
+		org.scribble.extensions.RegistryFactory.setRegistry(null);
+	}
+	
+	public void testValidConformanceReference() {
+		String type="TestType";
+		String located="Buyer";
+		String text=type+"@"+located;
+		
+		ModelReference ref=new ModelReference("");
+		TestParserContext context=new TestParserContext(ref, text);
+		ErrorRecorder l=new ErrorRecorder();
+		
+		Object obj=context.parse(ConformanceReference.class, l);
+		
+		if (obj instanceof ConformanceReference) {
+			ConformanceReference cref=(ConformanceReference)obj;
+			
+			if (cref.getAlias() == null ||
+					cref.getAlias().equals(type) == false) {
+				fail("Incorrect alias: "+cref.getLocalpart());
+			}
+			
+			if (cref.getLocatedRole() == null ||
+					cref.getLocatedRole().equals(located) == false) {
+				fail("Incorrect located role: "+cref.getLocatedRole());
+			}
+			
+			// Check no errors or warnings
+			if (l.getErrors().size() > 0) {
+				fail("Not expecting "+l.getErrors().size()+" errors");
+			} else if (l.getWarnings().size() > 0) {
+				fail("Not expecting "+l.getWarnings().size()+" warnings");
+			}
+			
+		} else if (obj == null) {
+			fail("No object returned");
+		} else {
+			fail("Unexpected object type: "+obj.getClass());
+		}
+	}
+	
+	public void testValidConformanceReferenceWithBindings() {
+		String type="TestType";
+		String located="Buyer";
+		String varLocal1="varA";
+		String varRemote1="varB";
+		String text=type+"@"+located+"("+varLocal1+" for "+varRemote1+")";
+		
+		ModelReference ref=new ModelReference("");
+		TestParserContext context=new TestParserContext(ref, text);
+		ErrorRecorder l=new ErrorRecorder();
+		
+		Object obj=context.parse(ConformanceReference.class, l);
+		
+		if (obj instanceof ConformanceReference) {
+			ConformanceReference cref=(ConformanceReference)obj;
+			
+			if (cref.getAlias() == null ||
+					cref.getAlias().equals(type) == false) {
+				fail("Incorrect alias: "+cref.getLocalpart());
+			}
+			
+			if (cref.getLocatedRole() == null ||
+					cref.getLocatedRole().equals(located) == false) {
+				fail("Incorrect located role: "+cref.getLocatedRole());
+			}
+			
+			if (cref.getNameMapping().size() != 1) {
+				fail("Should only be 1 name mapping: "+cref.getNameMapping().size());
+			}
+			
+			if (cref.getNameMapping().get(varRemote1).equals(varLocal1) == false) {
+				fail("Invalid name maping: "+cref.getNameMapping().get(varRemote1));
+			}
+			
+			// Check no errors or warnings
+			if (l.getErrors().size() > 0) {
+				fail("Not expecting "+l.getErrors().size()+" errors");
+			} else if (l.getWarnings().size() > 0) {
+				fail("Not expecting "+l.getWarnings().size()+" warnings");
+			}
+			
+		} else if (obj == null) {
+			fail("No object returned");
+		} else {
+			fail("Unexpected object type: "+obj.getClass());
+		}
+	}
+	
+	public void testInvalidConformanceReference1() {
+		String type="TestType";
+		String text=type;
+		
+		ModelReference ref=new ModelReference("");
+		TestParserContext context=new TestParserContext(ref, text);
+		ErrorRecorder l=new ErrorRecorder();
+		
+		Object obj=context.parse(ConformanceReference.class, l);
+		
+		if (obj instanceof ConformanceReference) {
+			
+			if (l.hasError(java.util.PropertyResourceBundle.getBundle(
+								"org.scribble.parser.Messages").
+							getString("_EXPECTING_LOCATED_REFERENCE")) == false) {
+				fail("Expecting located reference");
+			}
+			
+		} else if (obj == null) {
+			fail("No object returned");
+		} else {
+			fail("Unexpected object type: "+obj.getClass());
+		}
+	}
+	
+	public void testInvalidConformanceReference2() {
+		String type="TestType";
+		String located="Buyer";
+		String text=type+"@"+located+"(";
+		
+		ModelReference ref=new ModelReference("");
+		TestParserContext context=new TestParserContext(ref, text);
+		ErrorRecorder l=new ErrorRecorder();
+		
+		Object obj=context.parse(ConformanceReference.class, l);
+		
+		if (obj instanceof ConformanceReference) {
+			
+			if (l.hasError(java.util.PropertyResourceBundle.getBundle(
+					"org.scribble.parser.Messages").
+					getString("_EXPECTING_IDENTIFIER")) == false) {
+				fail("Expecting identifier");
+			}
+			
+		} else if (obj == null) {
+			fail("No object returned");
+		} else {
+			fail("Unexpected object type: "+obj.getClass());
+		}
+	}
+
+	public void testInvalidConformanceReference3() {
+		String type="TestType";
+		String located="Buyer";
+		String varLocal1="varA";
+		String text=type+"@"+located+"("+varLocal1+" to ";
+		
+		ModelReference ref=new ModelReference("");
+		TestParserContext context=new TestParserContext(ref, text);
+		ErrorRecorder l=new ErrorRecorder();
+		
+		Object obj=context.parse(ConformanceReference.class, l);
+		
+		if (obj instanceof ConformanceReference) {
+			
+			if (l.hasError(org.scribble.util.MessageUtil.format(
+					java.util.PropertyResourceBundle.getBundle(
+							"org.scribble.parser.Messages"),
+								"_EXPECTING_KEYWORD",
+								new String[]{"for"})) == false) {
+				fail("Expecting located reference");
+			}
+			
+		} else if (obj == null) {
+			fail("No object returned");
+		} else {
+			fail("Unexpected object type: "+obj.getClass());
+		}
+	}
+
+	public void testInvalidConformanceReference4() {
+		String type="TestType";
+		String located="Buyer";
+		String varLocal1="varA";
+		String text=type+"@"+located+"("+varLocal1+" for ";
+		
+		ModelReference ref=new ModelReference("");
+		TestParserContext context=new TestParserContext(ref, text);
+		ErrorRecorder l=new ErrorRecorder();
+		
+		Object obj=context.parse(ConformanceReference.class, l);
+		
+		if (obj instanceof ConformanceReference) {
+			
+			if (l.hasError(java.util.PropertyResourceBundle.getBundle(
+						"org.scribble.parser.Messages").
+						getString("_EXPECTING_IDENTIFIER")) == false) {
+				fail("Expecting identifier");
+			}
+			
+		} else if (obj == null) {
+			fail("No object returned");
+		} else {
+			fail("Unexpected object type: "+obj.getClass());
+		}
+	}
+
+	public void testInvalidConformanceReference5() {
+		String type="TestType";
+		String located="Buyer";
+		String varLocal1="varA";
+		String varRemote1="varB";
+		String text=type+"@"+located+"("+varLocal1+" for "+varRemote1;
+		
+		ModelReference ref=new ModelReference("");
+		TestParserContext context=new TestParserContext(ref, text);
+		ErrorRecorder l=new ErrorRecorder();
+		
+		Object obj=context.parse(ConformanceReference.class, l);
+		
+		if (obj instanceof ConformanceReference) {
+			
+			if (l.hasError(java.util.PropertyResourceBundle.getBundle(
+					"org.scribble.parser.Messages").
+					getString("_EXPECTING_PARAMETER_LIST_DELIMITER")) == false) {
+				fail("Expecting delimiter");
+			}
+			
+		} else if (obj == null) {
+			fail("No object returned");
+		} else {
+			fail("Unexpected object type: "+obj.getClass());
+		}
+	}
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/parser/DefaultParserContextTest.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/parser/DefaultParserContextTest.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/parser/DefaultParserContextTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,145 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 19 May 2008 : Initial version created by gary
+ */
+package org.scribble.parser;
+
+import org.scribble.model.ModelReference;
+
+import junit.framework.TestCase;
+
+public class DefaultParserContextTest extends TestCase {
+
+	protected void setUp() throws Exception {
+		org.scribble.extensions.TestRegistry reg=
+				new org.scribble.extensions.TestRegistry();
+		
+		reg.addExtension(GenericKeyWordProvider.class);
+		reg.addExtension(GenericParser.class);
+		reg.addExtension(TestModelRepository.class);
+		
+		org.scribble.extensions.RegistryFactory.setRegistry(reg);
+	}
+	
+	protected void tearDown() throws Exception {
+		// Clear registry
+		org.scribble.extensions.RegistryFactory.setRegistry(null);
+	}
+	
+	public void testTokenLineComment() {
+		String id1="ID1";
+		String id2="ID2";
+		String text=id1+"\r\n // Line comment \r\n"+id2;
+		
+		ModelReference ref=new ModelReference("");
+		DefaultParserContext context=new DefaultParserContext(ref,
+				new java.io.ByteArrayInputStream(text.getBytes()),
+				new DefaultTokenizer(), null);
+		
+		// Should be 2 tokens, as comment is filtered out
+		if (context.getTokenCount() != 2) {
+			fail("Expecting 2 tokens, but got: "+context.getTokenCount());
+		}
+	}
+	
+	public void testTokenBlockComment() {
+		String id1="ID1";
+		String id2="ID2";
+		String text=id1+"\r\n /* Block comment starts \r\n and continues */ \r\n"+id2;
+		
+		ModelReference ref=new ModelReference("");
+		DefaultParserContext context=new DefaultParserContext(ref,
+				new java.io.ByteArrayInputStream(text.getBytes()),
+				new DefaultTokenizer(), null);
+		
+		// Should be 2 tokens, as comment is filtered out
+		if (context.getTokenCount() != 2) {
+			fail("Expecting 2 tokens, but got: "+context.getTokenCount());
+		}
+	}
+	
+	public void testTokenKeyword() {
+		String id1="ID1";
+		String id2="ID2";
+		String keyword="role";
+		String text=id1+" "+keyword+" "+id2;
+		
+		ModelReference ref=new ModelReference("");
+		DefaultParserContext context=new DefaultParserContext(ref,
+				new java.io.ByteArrayInputStream(text.getBytes()),
+				new DefaultTokenizer(), null);
+		
+		if (context.getTokenCount() != 3) {
+			fail("Expecting 3 tokens, but got: "+context.getTokenCount());
+		}
+		
+		if (context.lookahead(1).getType() != TokenType.Keyword) {
+			fail("Expecting keyword type, but got: "+context.lookahead(1).getType());
+		}
+	}
+	
+	public void testTokenStringLiteral() {
+		String str="hello world";
+		String text="first \""+str+"\" second";
+		
+		ModelReference ref=new ModelReference("");
+		DefaultParserContext context=new DefaultParserContext(ref,
+				new java.io.ByteArrayInputStream(text.getBytes()),
+				new DefaultTokenizer(), null);
+		
+		// Should be 3 tokens
+		if (context.getTokenCount() != 3) {
+			fail("Expecting 3 tokens, but got: "+context.getTokenCount());
+		}
+		
+		Token token=context.lookahead(1);
+		
+		if (token.getType() != TokenType.StringLiteral) {
+			fail("Not string literal");
+		}
+		
+		if (token.getText().equals(str) == false) {
+			fail("String '"+token.getText()+"' incorrect, expecting: "+str);
+		}
+	}	
+	
+	public void testTokenStringLiteralLineTerminated() {
+		String str="hello world";
+		String text="first \""+str+"\r\n";
+		
+		ModelReference ref=new ModelReference("");
+		DefaultParserContext context=new DefaultParserContext(ref,
+				new java.io.ByteArrayInputStream(text.getBytes()),
+				new DefaultTokenizer(), null);
+		
+		// Should be 2 tokens
+		if (context.getTokenCount() != 2) {
+			fail("Expecting 2 tokens, but got: "+context.getTokenCount());
+		}
+		
+		Token token=context.lookahead(1);
+		
+		if (token.getType() != TokenType.StringLiteral) {
+			fail("Not string literal");
+		}
+		
+		if (token.getText().equals(str) == false) {
+			fail("String '"+token.getText()+"' incorrect, expecting: "+str);
+		}
+	}	
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/parser/GenericKeyWordProvider.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/parser/GenericKeyWordProvider.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/parser/GenericKeyWordProvider.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 2 May 2008 : Initial version created by gary
+ */
+package org.scribble.parser;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.parser.DefaultKeyWordProvider;
+import org.scribble.parser.KeyWordProvider;
+
+/**
+ * The generic notation keyword provider.
+ */
+ at RegistryInfo(extension=KeyWordProvider.class,notation="")
+public class GenericKeyWordProvider extends DefaultKeyWordProvider {
+	
+	public GenericKeyWordProvider() {
+		super(GENERIC_KEYWORDS);
+	}
+	
+	private static final String[] GENERIC_KEYWORDS={
+		"namespace",
+		"import",
+		"as",
+		"role",
+		"channel",
+		"via",
+		"for",
+		"from",
+		"to"
+	};
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/parser/GenericParser.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/parser/GenericParser.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/parser/GenericParser.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2007-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 2 May 2008 : Initial version created by gary
+ */
+package org.scribble.parser;
+
+import org.scribble.extensions.*;
+
+ at RegistryInfo(extension=Parser.class,notation="")
+public class GenericParser extends org.scribble.parser.DefaultParser {
+
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/parser/ImportParserRuleTest.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/parser/ImportParserRuleTest.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/parser/ImportParserRuleTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,169 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 7 May 2008 : Initial version created by gary
+ */
+package org.scribble.parser;
+
+import junit.framework.TestCase;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ErrorRecorder;
+
+public class ImportParserRuleTest extends TestCase {
+
+	protected void setUp() throws Exception {
+		org.scribble.extensions.TestRegistry reg=
+				new org.scribble.extensions.TestRegistry();
+		
+		reg.addExtension(GenericKeyWordProvider.class);
+		reg.addExtension(GenericParser.class);
+		reg.addExtension(org.scribble.parser.ImportParserRule.class);
+		reg.addExtension(TestModelRepository.class);
+		
+		org.scribble.extensions.RegistryFactory.setRegistry(reg);
+	}
+	
+	protected void tearDown() throws Exception {
+		// Clear registry
+		org.scribble.extensions.RegistryFactory.setRegistry(null);
+	}
+	
+	public void testValidImport() {
+		String type="com.hello.*";
+		String text="import "+type+";";
+		
+		ModelReference ref=new ModelReference("");
+		TestParserContext context=new TestParserContext(ref, text);
+		ErrorRecorder l=new ErrorRecorder();
+		
+		Object obj=context.parse(Import.class, l);
+		
+		if (obj instanceof Import) {
+			Import imp=(Import)obj;
+			
+			if (imp.getName() == null ||
+					imp.getName().equals(type) == false) {
+				fail("Incorrect name: "+imp.getName());
+			}
+			
+			if (imp.getAlias() != null) {
+				fail("Not expecting alias: "+imp.getAlias());
+			}
+			
+			// Check no errors or warnings
+			if (l.getErrors().size() > 0) {
+				fail("Not expecting "+l.getErrors().size()+" errors");
+			} else if (l.getWarnings().size() > 0) {
+				fail("Not expecting "+l.getWarnings().size()+" warnings");
+			}
+			
+		} else if (obj == null) {
+			fail("No object returned");
+		} else {
+			fail("Unexpected object type: "+obj.getClass());
+		}
+	}
+	
+	public void testValidImportWithAlias() {
+		String type="com.hello.MyValue";
+		String alias="Value";
+		String text="import "+type+" as "+alias+";";
+		
+		ModelReference ref=new ModelReference("");
+		TestParserContext context=new TestParserContext(ref, text);
+		ErrorRecorder l=new ErrorRecorder();
+		
+		Object obj=context.parse(Import.class, l);
+		
+		if (obj instanceof Import) {
+			Import imp=(Import)obj;
+			
+			if (imp.getName() == null ||
+					imp.getName().equals(type) == false) {
+				fail("Incorrect name: "+imp.getName());
+			}
+			
+			if (imp.getAlias() == null ||
+					imp.getAlias().equals(alias) == false) {
+				fail("Invalid alias: "+imp.getAlias());
+			}
+			
+			// Check no errors or warnings
+			if (l.getErrors().size() > 0) {
+				fail("Not expecting "+l.getErrors().size()+" errors");
+			} else if (l.getWarnings().size() > 0) {
+				fail("Not expecting "+l.getWarnings().size()+" warnings");
+			}
+			
+		} else if (obj == null) {
+			fail("No object returned");
+		} else {
+			fail("Unexpected object type: "+obj.getClass());
+		}
+	}
+	
+	public void testInvalidImport1() {
+		String type="com.hello.";
+		String text="import "+type+";";
+		
+		ModelReference ref=new ModelReference("");
+		TestParserContext context=new TestParserContext(ref, text);
+		ErrorRecorder l=new ErrorRecorder();
+		
+		Object obj=context.parse(Import.class, l);
+		
+		if (obj instanceof Import) {
+
+			if (l.hasError(java.util.PropertyResourceBundle.getBundle(
+							"org.scribble.parser.Messages").
+								getString("_EXPECTING_IDENTIFIER")) == false) {
+				fail("Expecting identifier");
+			}
+			
+		} else if (obj == null) {
+			fail("No object returned");
+		} else {
+			fail("Unexpected object type: "+obj.getClass());
+		}
+	}
+	
+	public void testInvalidImport2() {
+		String type="com.hello.MyValue";
+		String text="import "+type+" as;";
+		
+		ModelReference ref=new ModelReference("");
+		TestParserContext context=new TestParserContext(ref, text);
+		ErrorRecorder l=new ErrorRecorder();
+		
+		Object obj=context.parse(Import.class, l);
+		
+		if (obj instanceof Import) {
+
+			if (l.hasError(java.util.PropertyResourceBundle.getBundle(
+							"org.scribble.parser.Messages").
+								getString("_EXPECTING_IDENTIFIER")) == false) {
+				fail("Expecting identifier");
+			}
+			
+		} else if (obj == null) {
+			fail("No object returned");
+		} else {
+			fail("Unexpected object type: "+obj.getClass());
+		}
+	}
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/parser/InteractionParserRuleTest.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/parser/InteractionParserRuleTest.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/parser/InteractionParserRuleTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,288 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 2 May 2008 : Initial version created by gary
+ */
+package org.scribble.parser;
+
+import junit.framework.TestCase;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ErrorRecorder;
+
+public class InteractionParserRuleTest extends TestCase {
+
+	protected void setUp() throws Exception {
+		org.scribble.extensions.TestRegistry reg=
+				new org.scribble.extensions.TestRegistry();
+		
+		reg.addExtension(GenericKeyWordProvider.class);
+		reg.addExtension(GenericParser.class);
+		reg.addExtension(org.scribble.parser.InteractionParserRule.class);
+		reg.addExtension(org.scribble.parser.MessageSignatureParserRule.class);
+		reg.addExtension(org.scribble.parser.TypeReferenceParserRule.class);
+		reg.addExtension(TestModelRepository.class);
+		
+		org.scribble.extensions.RegistryFactory.setRegistry(reg);
+	}
+	
+	protected void tearDown() throws Exception {
+		// Clear registry
+		org.scribble.extensions.RegistryFactory.setRegistry(null);
+	}
+	
+	public void testValidInteraction() {
+		String type="Order";
+		String role1Name="Customer";
+		Role role1=new Role(role1Name);
+		String role2Name="Supplier";
+		Role role2=new Role(role2Name);
+		String channelName="Ch1";
+		Channel ch1=new Channel(channelName);
+
+		String text=type+" from "+role1Name+" to "+role2Name+
+					" via "+channelName+";";
+		
+		ModelReference ref=new ModelReference("");
+		TestParserContext context=new TestParserContext(ref, text);
+		ErrorRecorder l=new ErrorRecorder();
+		
+		context.setState(role1Name, role1);
+		context.setState(role2Name, role2);
+		context.setState(channelName, ch1);
+		
+		Object obj=context.parse(Interaction.class, l);
+		
+		if (obj instanceof Interaction) {
+			Interaction interaction=(Interaction)obj;
+			
+			if (interaction.getMessageSignature() == null) {
+				fail("No message signature");
+			} else if (interaction.getMessageSignature().getOperation() != null) {
+				fail("No operation expected");
+			} else if (interaction.getMessageSignature().getTypes().size() != 1) {
+				fail("Only one message sig type expected: "+
+						interaction.getMessageSignature().getTypes().size());
+			} else if (interaction.getMessageSignature().getTypes().get(0).
+						getAlias().equals(type) == false) {
+				fail("Message sig type not expected '"+type+"': "+
+						interaction.getMessageSignature().getTypes().get(0).
+						getAlias());
+			}
+			
+			if (interaction.getFromRole() == null) {
+				fail("From role not set");
+			} else if (interaction.getFromRole().equals(role1) == false) {
+				fail("From role not expected: "+interaction.getFromRole());
+			}
+			
+			if (interaction.getToRole() == null) {
+				fail("To role not set");
+			} else if (interaction.getToRole().equals(role2) == false) {
+				fail("To role not expected: "+interaction.getToRole());
+			}
+			
+			if (interaction.getChannel() == null) {
+				fail("Channel not set");
+			} else if (interaction.getChannel().equals(ch1) == false) {
+				fail("Channel not expected");
+			}
+			
+			// Check no errors or warnings
+			if (l.getErrors().size() > 0) {
+				fail("Not expecting "+l.getErrors().size()+" errors");
+			} else if (l.getWarnings().size() > 0) {
+				fail("Not expecting "+l.getWarnings().size()+" warnings");
+			}
+			
+		} else if (obj == null) {
+			fail("No object returned");
+		} else {
+			fail("Unexpected object type: "+obj.getClass());
+		}
+	}
+
+	public void testInvalidInteractionToRole() {
+		String type="Order";
+		String role1Name="Customer";
+		Role role1=new Role(role1Name);
+		String role2Name="Supplier";
+		//Role role2=new Role(role2Name);
+
+		String text=type+" from "+role1Name+" to "+role2Name+";";
+		
+		ModelReference ref=new ModelReference("");
+		TestParserContext context=new TestParserContext(ref, text);
+		ErrorRecorder l=new ErrorRecorder();
+		
+		context.setState(role1Name, role1);
+		//context.setState(role2Name, role2);
+		
+		context.parse(Interaction.class, l);
+		
+		if (l.hasError(org.scribble.util.MessageUtil.format(
+					java.util.PropertyResourceBundle.getBundle(
+						"org.scribble.parser.Messages"),
+							"_UNKNOWN_ROLE",
+						new String[]{role2Name})) == false) {
+			fail("Should register 'unknown role' error");
+		}
+	}
+
+	public void testInvalidInteractionToRole2() {
+		String type="Order";
+		String role1Name="Customer";
+		Role role1=new Role(role1Name);
+		String role2Name="Supplier";
+		//Role role2=new Role(role2Name);
+
+		String text=type+" from "+role1Name+" to "+role2Name+";";
+		
+		ModelReference ref=new ModelReference("");
+		TestParserContext context=new TestParserContext(ref, text);
+		ErrorRecorder l=new ErrorRecorder();
+		
+		context.setState(role1Name, role1);
+		context.setState(role2Name, "INVALID");
+		
+		context.parse(Interaction.class, l);
+		
+		if (l.hasError(org.scribble.util.MessageUtil.format(
+					java.util.PropertyResourceBundle.getBundle(
+						"org.scribble.parser.Messages"),
+							"_REQUIRED_ROLE",
+						new String[]{role2Name})) == false) {
+			fail("Should register 'required role' error");
+		}
+	}
+
+	public void testInvalidInteractionFromRole() {
+		String type="Order";
+		String role1Name="Customer";
+		//Role role1=new Role(role1Name);
+		String role2Name="Supplier";
+		Role role2=new Role(role2Name);
+
+		String text=type+" from "+role1Name+" to "+role2Name+";";
+		
+		ModelReference ref=new ModelReference("");
+		TestParserContext context=new TestParserContext(ref, text);
+		ErrorRecorder l=new ErrorRecorder();
+		
+		//context.setState(role1Name, role1);
+		context.setState(role2Name, role2);
+		
+		context.parse(Interaction.class, l);
+		
+		if (l.hasError(org.scribble.util.MessageUtil.format(
+					java.util.PropertyResourceBundle.getBundle(
+						"org.scribble.parser.Messages"),
+							"_UNKNOWN_ROLE",
+						new String[]{role1Name})) == false) {
+			fail("Should register 'unknown role' error");
+		}
+	}
+
+	public void testInvalidInteractionFromRole2() {
+		String type="Order";
+		String role1Name="Customer";
+		//Role role1=new Role(role1Name);
+		String role2Name="Supplier";
+		Role role2=new Role(role2Name);
+
+		String text=type+" from "+role1Name+" to "+role2Name+";";
+		
+		ModelReference ref=new ModelReference("");
+		TestParserContext context=new TestParserContext(ref, text);
+		ErrorRecorder l=new ErrorRecorder();
+		
+		context.setState(role1Name, "INVALID");
+		context.setState(role2Name, role2);
+		
+		context.parse(Interaction.class, l);
+		
+		if (l.hasError(org.scribble.util.MessageUtil.format(
+					java.util.PropertyResourceBundle.getBundle(
+						"org.scribble.parser.Messages"),
+							"_REQUIRED_ROLE",
+						new String[]{role1Name})) == false) {
+			fail("Should register 'required role' error");
+		}
+	}
+
+	public void testInvalidInteractionChannel() {
+		String type="Order";
+		String role1Name="Customer";
+		Role role1=new Role(role1Name);
+		String role2Name="Supplier";
+		Role role2=new Role(role2Name);
+		String channelName="Ch1";
+		//Channel ch1=new Channel(channelName);
+
+		String text=type+" from "+role1Name+" to "+role2Name+
+					" via "+channelName+";";
+		
+		ModelReference ref=new ModelReference("");
+		TestParserContext context=new TestParserContext(ref, text);
+		ErrorRecorder l=new ErrorRecorder();
+		
+		context.setState(role1Name, role1);
+		context.setState(role2Name, role2);
+		//context.setState(channelName, ch1);
+		
+		context.parse(Interaction.class, l);
+		
+		if (l.hasError(org.scribble.util.MessageUtil.format(
+					java.util.PropertyResourceBundle.getBundle(
+						"org.scribble.parser.Messages"),
+							"_UNKNOWN_CHANNEL",
+						new String[]{channelName})) == false) {
+			fail("Should register 'unknown channel' error");
+		}
+	}
+
+	public void testInvalidInteractionChannel2() {
+		String type="Order";
+		String role1Name="Customer";
+		Role role1=new Role(role1Name);
+		String role2Name="Supplier";
+		Role role2=new Role(role2Name);
+		String channelName="Ch1";
+		//Channel ch1=new Channel(channelName);
+
+		String text=type+" from "+role1Name+" to "+role2Name+
+					" via "+channelName+";";
+		
+		ModelReference ref=new ModelReference("");
+		TestParserContext context=new TestParserContext(ref, text);
+		ErrorRecorder l=new ErrorRecorder();
+		
+		context.setState(role1Name, role1);
+		context.setState(role2Name, role2);
+		context.setState(channelName, "INVALAID");
+		
+		context.parse(Interaction.class, l);
+		
+		if (l.hasError(org.scribble.util.MessageUtil.format(
+					java.util.PropertyResourceBundle.getBundle(
+						"org.scribble.parser.Messages"),
+							"_REQUIRED_CHANNEL",
+						new String[]{channelName})) == false) {
+			fail("Should register 'required channel' error");
+		}
+	}
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/parser/MessageSignatureParserRuleTest.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/parser/MessageSignatureParserRuleTest.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/parser/MessageSignatureParserRuleTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,183 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 7 May 2008 : Initial version created by gary
+ */
+package org.scribble.parser;
+
+import junit.framework.TestCase;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ErrorRecorder;
+
+public class MessageSignatureParserRuleTest extends TestCase {
+
+	protected void setUp() throws Exception {
+		org.scribble.extensions.TestRegistry reg=
+				new org.scribble.extensions.TestRegistry();
+		
+		reg.addExtension(GenericKeyWordProvider.class);
+		reg.addExtension(GenericParser.class);
+		reg.addExtension(org.scribble.parser.MessageSignatureParserRule.class);
+		reg.addExtension(org.scribble.parser.TypeReferenceParserRule.class);
+		reg.addExtension(TestModelRepository.class);
+		
+		org.scribble.extensions.RegistryFactory.setRegistry(reg);
+	}
+	
+	protected void tearDown() throws Exception {
+		// Clear registry
+		org.scribble.extensions.RegistryFactory.setRegistry(null);
+	}
+	
+	public void testValidMessageSignature() {
+		String type="Order";
+
+		String text=type;
+		
+		ModelReference ref=new ModelReference("");
+		TestParserContext context=new TestParserContext(ref, text);
+		ErrorRecorder l=new ErrorRecorder();
+		
+		Object obj=context.parse(MessageSignature.class, l);
+		
+		if (obj instanceof MessageSignature) {
+			MessageSignature msig=(MessageSignature)obj;
+			
+			if (msig.getOperation() != null) {
+				fail("No operation should be defined");
+			}
+			
+			if (msig.getTypes().size() != 1) {
+				fail("Only one type should be defined");
+			}
+			
+			if (msig.getTypes().get(0).getAlias().equals(type) == false) {
+				fail("Invalid type: "+msig.getTypes().get(0).getAlias());
+			}
+			
+			// Check no errors or warnings
+			if (l.getErrors().size() > 0) {
+				fail("Not expecting "+l.getErrors().size()+" errors");
+			} else if (l.getWarnings().size() > 0) {
+				fail("Not expecting "+l.getWarnings().size()+" warnings");
+			}
+			
+		} else if (obj == null) {
+			fail("No object returned");
+		} else {
+			fail("Unexpected object type: "+obj.getClass());
+		}
+	}
+	
+	public void testValidMessageSignature2() {
+		String type1="Order";
+		String type2="Invoice";
+		String op="placeOrder";
+		String text=op+"("+type1+","+type2+")";
+		
+		ModelReference ref=new ModelReference("");
+		TestParserContext context=new TestParserContext(ref, text);
+		ErrorRecorder l=new ErrorRecorder();
+		
+		Object obj=context.parse(MessageSignature.class, l);
+		
+		if (obj instanceof MessageSignature) {
+			MessageSignature msig=(MessageSignature)obj;
+			
+			if (msig.getOperation() == null ||
+					msig.getOperation().equals(op) == false) {
+				fail("Invalid operation: "+msig.getOperation());
+			}
+			
+			if (msig.getTypes().size() != 2) {
+				fail("Only two types should be defined");
+			}
+			
+			if (msig.getTypes().get(0).getAlias().equals(type1) == false) {
+				fail("Invalid type1: "+msig.getTypes().get(0).getAlias());
+			}
+			
+			if (msig.getTypes().get(1).getAlias().equals(type2) == false) {
+				fail("Invalid type2: "+msig.getTypes().get(1).getAlias());
+			}
+			
+			// Check no errors or warnings
+			if (l.getErrors().size() > 0) {
+				fail("Not expecting "+l.getErrors().size()+" errors");
+			} else if (l.getWarnings().size() > 0) {
+				fail("Not expecting "+l.getWarnings().size()+" warnings");
+			}
+			
+		} else if (obj == null) {
+			fail("No object returned");
+		} else {
+			fail("Unexpected object type: "+obj.getClass());
+		}
+	}
+
+	public void testInvalidMessageSignature1() {
+		String op="placeOrder";
+		String text=op+"()";
+		
+		ModelReference ref=new ModelReference("");
+		TestParserContext context=new TestParserContext(ref, text);
+		ErrorRecorder l=new ErrorRecorder();
+		
+		Object obj=context.parse(MessageSignature.class, l);
+		
+		if (obj instanceof MessageSignature) {
+			
+			if (l.hasError(java.util.PropertyResourceBundle.getBundle(
+					"org.scribble.parser.Messages").
+						getString("_EXPECTING_TYPE")) == false) {
+				fail("Expecting type");
+			}
+			
+		} else if (obj == null) {
+			fail("No object returned");
+		} else {
+			fail("Unexpected object type: "+obj.getClass());
+		}
+	}
+
+	public void testInvalidMessageSignature2() {
+		String type1="Order";
+		String op="placeOrder";
+		String text=op+"("+type1+":";
+		
+		ModelReference ref=new ModelReference("");
+		TestParserContext context=new TestParserContext(ref, text);
+		ErrorRecorder l=new ErrorRecorder();
+		
+		Object obj=context.parse(MessageSignature.class, l);
+		
+		if (obj instanceof MessageSignature) {
+			
+			if (l.hasError(java.util.PropertyResourceBundle.getBundle(
+					"org.scribble.parser.Messages").
+						getString("_EXPECTING_PARAMETER_LIST_DELIMITER")) == false) {
+				fail("Expecting , or )");
+			}
+			
+		} else if (obj == null) {
+			fail("No object returned");
+		} else {
+			fail("Unexpected object type: "+obj.getClass());
+		}
+	}
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/parser/ModelNameParserRuleTest.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/parser/ModelNameParserRuleTest.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/parser/ModelNameParserRuleTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,150 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 14 May 2008 : Initial version created by gary
+ */
+package org.scribble.parser;
+
+import junit.framework.TestCase;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ErrorRecorder;
+
+public class ModelNameParserRuleTest extends TestCase {
+
+	protected void setUp() throws Exception {
+		org.scribble.extensions.TestRegistry reg=
+				new org.scribble.extensions.TestRegistry();
+		
+		reg.addExtension(GenericKeyWordProvider.class);
+		reg.addExtension(GenericParser.class);
+		reg.addExtension(org.scribble.parser.ModelNameParserRule.class);
+		reg.addExtension(TestModelRepository.class);
+		
+		org.scribble.extensions.RegistryFactory.setRegistry(reg);
+	}
+	
+	protected void tearDown() throws Exception {
+		// Clear registry
+		org.scribble.extensions.RegistryFactory.setRegistry(null);
+	}
+	
+	public void testValidModelName1() {
+		String text="PurchaseGoods";
+
+		ModelReference ref=new ModelReference("");
+		TestParserContext context=new TestParserContext(ref, text);
+		ErrorRecorder l=new ErrorRecorder();
+		
+		Object obj=context.parse(LocatedName.class, l);
+		
+		if (obj instanceof LocatedName) {
+			LocatedName modelName=(LocatedName)obj;
+			
+			if (modelName.getName().equals(text) == false) {
+				fail("Unexpected model name: "+modelName.getName());
+			}
+			
+			if (modelName.getRole() != null) {
+				fail("Role not expected: "+modelName.getRole());
+			}
+			
+			// Check no errors or warnings
+			if (l.getErrors().size() > 0) {
+				fail("Not expecting "+l.getErrors().size()+" errors");
+			} else if (l.getWarnings().size() > 0) {
+				fail("Not expecting "+l.getWarnings().size()+" warnings");
+			}
+			
+		} else if (obj == null) {
+			fail("No object returned");
+		} else {
+			fail("Unexpected object type: "+obj.getClass());
+		}
+	}
+	
+	public void testValidModelName2() {
+		String name="PurchaseGoods";
+		String roleName="Buyer";
+		
+		String text=name+"@"+roleName;
+
+		ModelReference ref=new ModelReference("");
+		TestParserContext context=new TestParserContext(ref, text);
+		ErrorRecorder l=new ErrorRecorder();
+		
+		Object obj=context.parse(LocatedName.class, l);
+		
+		if (obj instanceof LocatedName) {
+			LocatedName modelName=(LocatedName)obj;
+			
+			if (modelName.getName().equals(name) == false) {
+				fail("Unexpected model name: "+modelName.getName());
+			}
+			
+			if (modelName.getRole().getName().equals(roleName) == false) {
+				fail("Unexpected role: "+modelName.getRole());
+			}
+			
+			// Check no errors or warnings
+			if (l.getErrors().size() > 0) {
+				fail("Not expecting "+l.getErrors().size()+" errors");
+			} else if (l.getWarnings().size() > 0) {
+				fail("Not expecting "+l.getWarnings().size()+" warnings");
+			}
+			
+		} else if (obj == null) {
+			fail("No object returned");
+		} else {
+			fail("Unexpected object type: "+obj.getClass());
+		}
+	}
+	
+	public void testInvalidModelName1() {
+		String name="@";
+		
+		ModelReference ref=new ModelReference("");
+		TestParserContext context=new TestParserContext(ref, name);
+		ErrorRecorder l=new ErrorRecorder();
+		
+		context.parse(LocatedName.class, l);
+		
+		if (l.hasError(java.util.PropertyResourceBundle.getBundle(
+					"org.scribble.parser.Messages").
+						getString("_EXPECTING_IDENTIFIER")) == false) {
+			fail("Should report error regarding expected identifier");
+		}
+	}
+	
+	public void testInvalidModelName2() {
+		String name="PurchaseGoods";
+		
+		String text=name+"@"+";";
+
+		ModelReference ref=new ModelReference("");
+		TestParserContext context=new TestParserContext(ref, text);
+		ErrorRecorder l=new ErrorRecorder();
+		
+		context.parse(LocatedName.class, l);
+		
+		if (l.hasError(java.util.PropertyResourceBundle.getBundle(
+					"org.scribble.parser.Messages").
+						getString("_EXPECTING_ROLE_NAME")) == false) {
+			fail("Should report error regarding expected role name");
+		}
+	}
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/parser/NamespaceParserRuleTest.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/parser/NamespaceParserRuleTest.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/parser/NamespaceParserRuleTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,141 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 14 May 2008 : Initial version created by gary
+ */
+package org.scribble.parser;
+
+import junit.framework.TestCase;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ErrorRecorder;
+
+public class NamespaceParserRuleTest extends TestCase {
+
+	protected void setUp() throws Exception {
+		org.scribble.extensions.TestRegistry reg=
+				new org.scribble.extensions.TestRegistry();
+		
+		reg.addExtension(GenericKeyWordProvider.class);
+		reg.addExtension(GenericParser.class);
+		reg.addExtension(org.scribble.parser.NamespaceParserRule.class);
+		reg.addExtension(TestModelRepository.class);
+		
+		org.scribble.extensions.RegistryFactory.setRegistry(reg);
+	}
+	
+	protected void tearDown() throws Exception {
+		// Clear registry
+		org.scribble.extensions.RegistryFactory.setRegistry(null);
+	}
+	
+	public void testValidNamespace1() {
+		String namespace="simple";
+		String text="namespace "+namespace+";";
+
+		ModelReference ref=new ModelReference("");
+		TestParserContext context=new TestParserContext(ref, text);
+		ErrorRecorder l=new ErrorRecorder();
+		
+		Object obj=context.parse(Namespace.class, l);
+		
+		if (obj instanceof Namespace) {
+			Namespace ns=(Namespace)obj;
+			
+			if (ns.getName().equals(namespace) == false) {
+				fail("Unexpected namespace: "+ns.getName());
+			}
+						
+			// Check no errors or warnings
+			if (l.getErrors().size() > 0) {
+				fail("Not expecting "+l.getErrors().size()+" errors");
+			} else if (l.getWarnings().size() > 0) {
+				fail("Not expecting "+l.getWarnings().size()+" warnings");
+			}
+			
+		} else if (obj == null) {
+			fail("No object returned");
+		} else {
+			fail("Unexpected object type: "+obj.getClass());
+		}
+	}
+	
+	public void testValidNamespace2() {
+		String namespace="scoped.package.name";
+		String text="namespace "+namespace+";";
+
+		ModelReference ref=new ModelReference("");
+		TestParserContext context=new TestParserContext(ref, text);
+		ErrorRecorder l=new ErrorRecorder();
+		
+		Object obj=context.parse(Namespace.class, l);
+		
+		if (obj instanceof Namespace) {
+			Namespace ns=(Namespace)obj;
+			
+			if (ns.getName().equals(namespace) == false) {
+				fail("Unexpected namespace: "+ns.getName());
+			}
+						
+			// Check no errors or warnings
+			if (l.getErrors().size() > 0) {
+				fail("Not expecting "+l.getErrors().size()+" errors");
+			} else if (l.getWarnings().size() > 0) {
+				fail("Not expecting "+l.getWarnings().size()+" warnings");
+			}
+			
+		} else if (obj == null) {
+			fail("No object returned");
+		} else {
+			fail("Unexpected object type: "+obj.getClass());
+		}
+	}
+	
+	public void testInvalidNamespace1() {
+		String namespace="scoped.";
+		String text="namespace "+namespace+";";
+		
+		ModelReference ref=new ModelReference("");
+		TestParserContext context=new TestParserContext(ref, text);
+		ErrorRecorder l=new ErrorRecorder();
+		
+		context.parse(Namespace.class, l);
+		
+		if (l.hasError(java.util.PropertyResourceBundle.getBundle(
+					"org.scribble.parser.Messages").
+						getString("_EXPECTING_IDENTIFIER")) == false) {
+			fail("Should report error regarding expected identifier");
+		}
+	}
+
+	public void testInvalidNamespace2() {
+		String namespace="scoped.*.notallowed";
+		String text="namespace "+namespace+";";
+		
+		ModelReference ref=new ModelReference("");
+		TestParserContext context=new TestParserContext(ref, text);
+		ErrorRecorder l=new ErrorRecorder();
+		
+		context.parse(Namespace.class, l);
+		
+		if (l.hasError(java.util.PropertyResourceBundle.getBundle(
+					"org.scribble.parser.Messages").
+						getString("_EXPECTING_IDENTIFIER")) == false) {
+			fail("Should report error regarding expected identifier");
+		}
+	}
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/parser/RoleListParserRuleTest.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/parser/RoleListParserRuleTest.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/parser/RoleListParserRuleTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,133 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 19 May 2008 : Initial version created by gary
+ */
+package org.scribble.parser;
+
+import junit.framework.TestCase;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ErrorRecorder;
+
+public class RoleListParserRuleTest extends TestCase {
+
+	protected void setUp() throws Exception {
+		org.scribble.extensions.TestRegistry reg=
+				new org.scribble.extensions.TestRegistry();
+		
+		reg.addExtension(GenericKeyWordProvider.class);
+		reg.addExtension(GenericParser.class);
+		reg.addExtension(org.scribble.parser.RoleListParserRule.class);
+		reg.addExtension(TestModelRepository.class);
+		
+		org.scribble.extensions.RegistryFactory.setRegistry(reg);
+	}
+	
+	protected void tearDown() throws Exception {
+		// Clear registry
+		org.scribble.extensions.RegistryFactory.setRegistry(null);
+	}
+	
+	public void testValidRoleList() {
+		String role1Name="Customer";
+		String role2Name="Supplier";
+
+		String text="role "+role1Name+", "+role2Name+";";
+		
+		ModelReference ref=new ModelReference("");
+		TestParserContext context=new TestParserContext(ref, text);
+		ErrorRecorder l=new ErrorRecorder();
+		
+		Object obj=context.parse(RoleList.class, l);
+		
+		if (obj instanceof RoleList) {
+			RoleList rolelist=(RoleList)obj;
+			
+			if (rolelist.getRoles().size() != 2) {
+				fail("Two roles expected: "+
+						rolelist.getRoles().size());
+			}
+			
+			if (rolelist.getRoles().get(0).getName() == null) {
+				fail("First role name not set");
+			} else if (rolelist.getRoles().get(0).getName().equals(role1Name) == false) {
+				fail("First role name not expected: "+rolelist.getRoles().get(0).getName());
+			} else if (context.getState(role1Name) != rolelist.getRoles().get(0)) {
+				fail("First role not in context state");
+			}
+						
+			if (rolelist.getRoles().get(1).getName() == null) {
+				fail("Second role name not set");
+			} else if (rolelist.getRoles().get(1).getName().equals(role2Name) == false) {
+				fail("Second role name not expected: "+rolelist.getRoles().get(1).getName());
+			} else if (context.getState(role2Name) != rolelist.getRoles().get(1)) {
+				fail("Second role not in context state");
+			}
+						
+			// Check no errors or warnings
+			if (l.getErrors().size() > 0) {
+				fail("Not expecting "+l.getErrors().size()+" errors");
+			} else if (l.getWarnings().size() > 0) {
+				fail("Not expecting "+l.getWarnings().size()+" warnings");
+			}
+			
+		} else if (obj == null) {
+			fail("No object returned");
+		} else {
+			fail("Unexpected object type: "+obj.getClass());
+		}
+	}
+
+	public void testInvalidRoleListNoIdentifier() {
+		String role1Name="Customer";
+
+		String text="role "+role1Name+", "+";";
+				
+		ModelReference ref=new ModelReference("");
+		TestParserContext context=new TestParserContext(ref, text);
+		ErrorRecorder l=new ErrorRecorder();
+		
+		context.parse(RoleList.class, l);
+		
+		if (l.hasError(java.util.PropertyResourceBundle.getBundle(
+					"org.scribble.parser.Messages").
+						getString("_EXPECTING_ROLE_NAME")) == false) {
+			fail("Should register 'expecting role name' error");
+		}
+	}
+
+	public void testInvalidRoleListDuplicateRole() {
+		String role1Name="Customer";
+
+		String text="role "+role1Name+", "+role1Name+";";
+				
+		ModelReference ref=new ModelReference("");
+		TestParserContext context=new TestParserContext(ref, text);
+		ErrorRecorder l=new ErrorRecorder();
+		
+		context.parse(RoleList.class, l);
+		
+		if (l.hasError(org.scribble.util.MessageUtil.format(
+				java.util.PropertyResourceBundle.getBundle(
+						"org.scribble.parser.Messages"),
+							"_DUPLICATE_DECLARATION",
+							new String[]{role1Name})) == false) {
+			fail("Should register 'duplicate declaration' error");
+		}
+	}
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/parser/TestModelRepository.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/parser/TestModelRepository.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/parser/TestModelRepository.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 2 May 2008 : Initial version created by gary
+ */
+package org.scribble.parser;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelChangeListener;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.model.admin.ModelRepository;
+
+ at RegistryInfo(extension=ModelRepository.class)
+public class TestModelRepository implements org.scribble.model.admin.ModelRepository {
+
+	public void addModelChangeListener(ModelChangeListener l) {
+		// TODO Auto-generated method stub
+		
+	}
+
+	public boolean exists(ModelReference ref, ModelReference source) {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	public Model getModel(ModelReference ref, ModelListener l) {
+		// TODO Auto-generated method stub
+		return(null);
+	}
+
+	public void locate(ModelReference newRef, ModelReference base) {
+		// TODO Auto-generated method stub
+		
+	}
+
+	public void removeModelChangeListener(ModelChangeListener l) {
+		// TODO Auto-generated method stub
+		
+	}
+
+	public ModelReference getSource(ModelReference ref) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	public void updateModel(ModelReference ref, Model model) {
+		// TODO Auto-generated method stub
+		
+	}
+
+	public boolean canAccess(ModelReference srcRef,
+			ModelReference targetRef, boolean allowSelfAccess) {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/parser/TestParserContext.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/parser/TestParserContext.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/parser/TestParserContext.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 1 May 2008 : Initial version created by gary
+ */
+package org.scribble.parser;
+
+public class TestParserContext extends DefaultParserContext {
+
+	public TestParserContext(org.scribble.model.ModelReference ref,
+								String text) {
+		super(ref, new java.io.ByteArrayInputStream(text.getBytes()),
+				new DefaultTokenizer(), null);
+	}
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/parser/TestTypeReferenceParserRule.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/parser/TestTypeReferenceParserRule.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/parser/TestTypeReferenceParserRule.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 24 Oct 2007 : Initial version created by gary
+ */
+package org.scribble.parser;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class provides the parser rule for the Type Reference.
+ */
+ at RegistryInfo(extension=ParserRule.class)
+public class TestTypeReferenceParserRule extends AbstractParserRule {
+
+	/**
+	 * This is the default constructor.
+	 */
+	public TestTypeReferenceParserRule() {
+		super(ParserRuleType.Clause);
+	}
+	
+	/**
+	 * This method determines whether the parser rules is
+	 * appropriate to return a model object of the required
+	 * type.
+	 * 
+	 * @param type The required type
+	 * @return Whether the parser rule returns a
+	 * 				model object of the required type
+	 */
+	public boolean isSupported(Class<?> type) {
+		return(type.isAssignableFrom(TypeReference.class));
+	}
+
+	/**
+	 * This method parses the description to obtain
+	 * a model object of the appropriate type.
+	 * 
+	 * @param context The context
+	 * @param l The listener
+	 * @return The model object
+	 */
+	public Object parse(ParserContext context, ModelListener l) {
+		ModelReference ret=null;
+		
+		Token t=context.nextToken();
+		
+		if (t.getType() == TokenType.Identifier) {
+			ret = new TypeReference();
+			
+			ret.setLocalpart(t.getText());
+			
+		} else {
+			l.error(new ModelIssue(t, java.util.PropertyResourceBundle.getBundle(
+						"org.scribble.parser.Messages").
+						getString("_EXPECTING_IDENTIFIER")));
+		}
+		
+		return(ret);
+	}
+	
+	private boolean m_located=false;
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/parser/TypeReferenceParserRuleTest.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/parser/TypeReferenceParserRuleTest.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/parser/TypeReferenceParserRuleTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,135 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 19 May 2008 : Initial version created by gary
+ */
+package org.scribble.parser;
+
+import junit.framework.TestCase;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ErrorRecorder;
+
+public class TypeReferenceParserRuleTest extends TestCase {
+
+	protected void setUp() throws Exception {
+		org.scribble.extensions.TestRegistry reg=
+				new org.scribble.extensions.TestRegistry();
+		
+		reg.addExtension(GenericKeyWordProvider.class);
+		reg.addExtension(GenericParser.class);
+		reg.addExtension(org.scribble.parser.TypeReferenceParserRule.class);
+		reg.addExtension(TestModelRepository.class);
+		
+		org.scribble.extensions.RegistryFactory.setRegistry(reg);
+	}
+	
+	protected void tearDown() throws Exception {
+		// Clear registry
+		org.scribble.extensions.RegistryFactory.setRegistry(null);
+	}
+	
+	public void testValidTypeReference() {
+		String type="TestType";
+		String text=type;
+		
+		ModelReference ref=new ModelReference("");
+		TestParserContext context=new TestParserContext(ref, text);
+		ErrorRecorder l=new ErrorRecorder();
+		
+		Object obj=context.parse(TypeReference.class, l);
+		
+		if (obj instanceof TypeReference) {
+			TypeReference tref=(TypeReference)obj;
+			
+			if (tref.getAlias() == null ||
+					tref.getAlias().equals(type) == false) {
+				fail("Incorrect alias: "+tref.getLocalpart());
+			}
+			
+			if (tref.getLocatedRole() != null) {
+				fail("Should not be located");
+			}
+			
+			// Check no errors or warnings
+			if (l.getErrors().size() > 0) {
+				fail("Not expecting "+l.getErrors().size()+" errors");
+			} else if (l.getWarnings().size() > 0) {
+				fail("Not expecting "+l.getWarnings().size()+" warnings");
+			}
+			
+		} else if (obj == null) {
+			fail("No object returned");
+		} else {
+			fail("Unexpected object type: "+obj.getClass());
+		}
+	}
+
+	public void testValidTypeReferenceNotLocated() {
+		String type="TestType";
+		String located="Buyer";
+		String text=type+"@"+located;
+		
+		ModelReference ref=new ModelReference("");
+		TestParserContext context=new TestParserContext(ref, text);
+		ErrorRecorder l=new ErrorRecorder();
+		
+		Object obj=context.parse(TypeReference.class, l);
+		
+		if (obj instanceof TypeReference) {
+			TypeReference tref=(TypeReference)obj;
+			
+			if (tref.getAlias() == null ||
+					tref.getAlias().equals(type) == false) {
+				fail("Incorrect alias: "+tref.getLocalpart());
+			}
+			
+			if (tref.getLocatedRole() != null) {
+				fail("Type reference should not be located");
+			}
+			
+			// Check no errors or warnings
+			if (l.getErrors().size() > 0) {
+				fail("Not expecting "+l.getErrors().size()+" errors");
+			} else if (l.getWarnings().size() > 0) {
+				fail("Not expecting "+l.getWarnings().size()+" warnings");
+			}
+			
+		} else if (obj == null) {
+			fail("No object returned");
+		} else {
+			fail("Unexpected object type: "+obj.getClass());
+		}
+	}
+
+	public void testInvalidTypeReference1() {
+		String type=":";
+		String text=type;
+		
+		ModelReference ref=new ModelReference("");
+		TestParserContext context=new TestParserContext(ref, text);
+		ErrorRecorder l=new ErrorRecorder();
+		
+		context.parse(TypeReference.class, l);
+		
+		if (l.hasError(java.util.PropertyResourceBundle.getBundle(
+						"org.scribble.parser.Messages").
+							getString("_EXPECTING_IDENTIFIER")) == false) {
+			fail("Expecting identifier error");
+		}
+	}
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/projector/TestProjector.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/projector/TestProjector.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/projector/TestProjector.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2005-9 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 28 Feb 2009 : Initial version created by gary
+ */
+package org.scribble.projector;
+
+import org.scribble.model.Model;
+import org.scribble.model.ModelReference;
+import org.scribble.model.SubDefinitionPath;
+import org.scribble.model.Role;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.extensions.*;
+
+ at RegistryInfo(extension=Projector.class)
+public class TestProjector implements Projector {
+
+	public void setProjectedMode(Model from, Model to) {
+		m_map.put(from, to);
+	}
+	
+	public Model project(ModelReference ref, Model model, Role role,
+			ModelListener l) {
+		return(project(ref, model, null, role, l));
+	}
+
+	public Model project(ModelReference ref, Model model,
+			SubDefinitionPath subDefinitionPath, Role role,
+			ModelListener l) {
+		return(m_map.get(model));
+	}
+
+	private java.util.Map<Model,Model> m_map=new java.util.HashMap<Model, Model>();
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/util/ModelIssueUtilTest.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/util/ModelIssueUtilTest.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/util/ModelIssueUtilTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,160 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 7 Sep 2008 : Initial version created by gary
+ */
+package org.scribble.util;
+
+import junit.framework.TestCase;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.DefaultResolution;
+import org.scribble.model.resolutions.Resolution;
+
+public class ModelIssueUtilTest extends TestCase {
+
+	public void testSerDeSerResolutions() {
+		
+		// 1) Implement ser/de-ser test
+		// 2) Need to make resolution manager generic
+		//   so that current resolutions can be
+		//   Eclipse independent and called from an
+		//   Eclipse specific harness
+		
+		java.util.List<Resolution> res=new java.util.Vector<Resolution>();
+		
+		Resolution res1=new Resolution1();
+		
+		res1.getProperties().put("p1", "prop1");
+		res1.getProperties().put("p2", 2);
+		
+		Resolution res2=new Resolution2();
+		
+		res2.getProperties().put("p3", true);
+		res2.getProperties().put("p4", "prop4");
+		res2.getProperties().put("p5", "prop5");
+		
+		res.add(res1);
+		res.add(res2);
+		
+		java.util.Map<String,Object> props=ModelIssueUtil.serializeResolutions(res);
+		
+		java.util.List<Resolution> results=ModelIssueUtil.deserializeResolutions(props);
+		
+		// Check resolutions against originals
+		if (results.size() != 2) {
+			fail("Should be 2 results: "+results.size());
+		}
+		
+		Resolution result1=results.get(0);
+		Resolution result2=results.get(1);
+		
+		if (result1.getClass() != res1.getClass()) {
+			fail("First resolution not correct class");
+		}
+		
+		if (result2.getClass() != res2.getClass()) {
+			fail("Second resolution not correct class");
+		}
+		
+		if (result1.getProperties().size() != 2) {
+			fail("Result 1 should have 2 properties: "+result1.getProperties().size());
+		}
+		
+		if (result2.getProperties().size() != 3) {
+			fail("Result 2 should have 3 properties: "+result2.getProperties().size());
+		}
+		
+		if (result1.getProperties().get("p1").equals("prop1") == false) {
+			fail("Property p1 not correct");
+		}
+		
+		if (result1.getProperties().get("p2").equals(2) == false) {
+			fail("Property p2 not correct");
+		}
+		
+		if (result2.getProperties().get("p3").equals(true) == false) {
+			fail("Property p3 not correct");
+		}
+		
+		if (result2.getProperties().get("p4").equals("prop4") == false) {
+			fail("Property p4 not correct");
+		}
+
+		if (result2.getProperties().get("p5").equals("prop5") == false) {
+			fail("Property p5 not correct");
+		}
+	}
+	
+	public void testDuplicateProperties() {
+		
+		java.util.List<Resolution> res=new java.util.Vector<Resolution>();
+		
+		Resolution res1=new Resolution1();		
+		res1.getProperties().put("p1", "prop1");
+		
+		Resolution res2=new Resolution2();
+		res2.getProperties().put("p1", "prop2");
+		
+		res.add(res1);
+		res.add(res2);
+		
+		java.util.Map<String,Object> props=ModelIssueUtil.serializeResolutions(res);
+		
+		java.util.List<Resolution> results=ModelIssueUtil.deserializeResolutions(props);
+		
+		// Check resolutions against originals
+		if (results.size() != 2) {
+			fail("Should be 2 results: "+results.size());
+		}
+		
+		Resolution result1=results.get(0);
+		Resolution result2=results.get(1);
+		
+		if (result1.getClass() != res1.getClass()) {
+			fail("First resolution not correct class");
+		}
+		
+		if (result2.getClass() != res2.getClass()) {
+			fail("Second resolution not correct class");
+		}
+		
+		if (result1.getProperties().size() != 1) {
+			fail("Result 1 should have 1 properties: "+result1.getProperties().size());
+		}
+		
+		if (result2.getProperties().size() != 1) {
+			fail("Result 2 should have 1 properties: "+result2.getProperties().size());
+		}
+		
+		if (result1.getProperties().get("p1").equals("prop1") == false) {
+			fail("Property p1 in result 1 not correct");
+		}
+		
+		if (result2.getProperties().get("p1").equals("prop2") == false) {
+			fail("Property p1 in result 2 not correct");
+		}		
+	}
+	
+	public static class Resolution1 extends DefaultResolution {
+		
+	}
+	
+	public static class Resolution2 extends DefaultResolution {
+		
+	}
+}

Added: trunk/bundles/org.scribble.core/src/test/org/scribble/util/ScopeTest.java
===================================================================
--- trunk/bundles/org.scribble.core/src/test/org/scribble/util/ScopeTest.java	                        (rev 0)
+++ trunk/bundles/org.scribble.core/src/test/org/scribble/util/ScopeTest.java	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2007 Pi4 Technologies Ltd
+ *
+ * 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.
+ *
+ *
+ * Change History:
+ * 7 Nov 2007 : Initial version created by gary
+ */
+package org.scribble.util;
+
+import junit.framework.TestCase;
+
+public class ScopeTest extends TestCase {
+
+	public void testCopyConstructor1() {
+		
+		Scope scope=new Scope();
+		scope.setLocatedRole("hello");
+		
+		Scope copy=new Scope(scope);
+		
+		if (copy.getLocatedRole() == null) {
+			fail("Located role should not be null '"+
+					copy.getLocatedRole()+"'");
+		}
+		
+		if (copy.getLocatedRole().equals(scope.getLocatedRole()) == false) {
+			fail("Located role should be '"+
+					scope.getLocatedRole()+"', but was: "+
+					copy.getLocatedRole());
+		}
+	}
+	
+	public void testCopyConstructor2() {
+		
+		Scope scope=new Scope();
+		scope.setState("name1", "value1");
+		
+		Scope copy=new Scope(scope);
+		
+		if (copy.getState("name1") == null) {
+			fail("No state found for 'name1'");
+		}
+		
+		if (copy.getState("name1").equals(scope.getState("name1")) == false) {
+			fail("State for 'name1' was '"+copy.getState("name1")+
+					"', but was expecting: "+scope.getState("name1"));
+		}
+	}
+}

Added: trunk/bundles/pom.xml
===================================================================
--- trunk/bundles/pom.xml	                        (rev 0)
+++ trunk/bundles/pom.xml	2010-11-20 23:03:24 UTC (rev 491)
@@ -0,0 +1,72 @@
+<project
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+	xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>org.savara</groupId>
+	<artifactId>bundles</artifactId>
+	<packaging>pom</packaging>
+	<version>1.2.0-SNAPSHOT</version>
+	<name>Savara::Bundles</name>
+
+    <parent>
+	  <groupId>org</groupId>
+	  <artifactId>savara</artifactId>
+      <version>1.2.0-SNAPSHOT</version>
+	</parent>
+
+	<properties>
+        <jaxb.version>2.1</jaxb.version>
+        <osgi.version>1.4.0</osgi.version>
+	</properties>
+
+	<modules>
+		<module>org.scribble.conformance</module>
+		<module>org.scribble.conversation.comparator</module>
+		<module>org.scribble.conversation.export.text</module>
+		<module>org.scribble.conversation.model</module>
+		<module>org.scribble.conversation.parser</module>
+		<module>org.scribble.conversation.projector</module>
+		<module>org.scribble.conversation.validation</module>
+		<module>org.scribble.core</module>
+		<module>org.scribble.expression.xpath</module>
+		<module>org.scribble.lang.model</module>
+		<module>org.savara.core</module>
+		<module>org.savara.contract.model</module>
+		<module>org.savara.wsdl</module>
+		<module>org.savara.bpel</module>
+	</modules>
+ 
+	<build>
+		<!-- This section defines the default plugin settings inherited by child projects. -->
+		<pluginManagement>
+			<plugins>
+				<!-- Fixes how test resources of a project can be used in projects dependent on it  -->
+				<plugin>
+					<groupId>org.apache.maven.plugins</groupId>
+					<artifactId>maven-jar-plugin</artifactId>
+					<version>2.2</version>
+          			<configuration>
+          				<archive>
+            				<manifestFile>META-INF/MANIFEST.MF</manifestFile>
+          				</archive>
+        			</configuration>
+				</plugin>
+		      <plugin>
+		        <groupId>org.apache.felix</groupId>
+		        <artifactId>maven-bundle-plugin</artifactId>
+		        <executions>
+		          <execution>
+		            <id>bundle-manifest</id>
+		            <phase>process-classes</phase>
+		            <goals>
+		              <goal>manifest</goal>
+		            </goals>
+		          </execution>
+		        </executions>
+		      </plugin>
+			</plugins>
+		</pluginManagement>
+	</build>
+
+</project>
+



More information about the savara-commits mailing list